From a5e6f3213ff0ecfe6c989c480fbea81ef22effce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 18 Oct 2016 13:14:54 +0200 Subject: [PATCH] Device: remove _irq_attached flag, test with _irq == 0 instead --- src/drivers/device/device_nuttx.cpp | 14 +++++--------- src/drivers/device/device_nuttx.h | 3 +-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/drivers/device/device_nuttx.cpp b/src/drivers/device/device_nuttx.cpp index 12d42d5bfe..7e8838f32d 100644 --- a/src/drivers/device/device_nuttx.cpp +++ b/src/drivers/device/device_nuttx.cpp @@ -91,8 +91,7 @@ Device::Device(const char *name, _name(name), _debug_enabled(false), // private - _irq(irq), - _irq_attached(false) + _irq(irq) { sem_init(&_lock, 0, 1); @@ -109,7 +108,7 @@ Device::~Device() { sem_destroy(&_lock); - if (_irq_attached) { + if (_irq) { unregister_interrupt(_irq); } } @@ -128,20 +127,17 @@ Device::init() ret = register_interrupt(_irq, this); if (ret != OK) { - goto out; + _irq = 0; } - - _irq_attached = true; } -out: return ret; } void Device::interrupt_enable() { - if (_irq_attached) { + if (_irq) { up_enable_irq(_irq); } } @@ -149,7 +145,7 @@ Device::interrupt_enable() void Device::interrupt_disable() { - if (_irq_attached) { + if (_irq) { up_disable_irq(_irq); } } diff --git a/src/drivers/device/device_nuttx.h b/src/drivers/device/device_nuttx.h index c0c9487bfd..2ef5c7ddfb 100644 --- a/src/drivers/device/device_nuttx.h +++ b/src/drivers/device/device_nuttx.h @@ -209,8 +209,7 @@ protected: sem_t _lock; /**< lock to protect access to all class members (also for derived classes) */ private: - int _irq; - bool _irq_attached; + int _irq; /**< if non-zero, it's a valid IRQ */ /** disable copy construction for this and all subclasses */ Device(const Device &);