mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 22:03:35 +08:00
Device: remove _irq_attached flag, test with _irq == 0 instead
This commit is contained in:
@@ -91,8 +91,7 @@ Device::Device(const char *name,
|
|||||||
_name(name),
|
_name(name),
|
||||||
_debug_enabled(false),
|
_debug_enabled(false),
|
||||||
// private
|
// private
|
||||||
_irq(irq),
|
_irq(irq)
|
||||||
_irq_attached(false)
|
|
||||||
{
|
{
|
||||||
sem_init(&_lock, 0, 1);
|
sem_init(&_lock, 0, 1);
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ Device::~Device()
|
|||||||
{
|
{
|
||||||
sem_destroy(&_lock);
|
sem_destroy(&_lock);
|
||||||
|
|
||||||
if (_irq_attached) {
|
if (_irq) {
|
||||||
unregister_interrupt(_irq);
|
unregister_interrupt(_irq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,20 +127,17 @@ Device::init()
|
|||||||
ret = register_interrupt(_irq, this);
|
ret = register_interrupt(_irq, this);
|
||||||
|
|
||||||
if (ret != OK) {
|
if (ret != OK) {
|
||||||
goto out;
|
_irq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_irq_attached = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Device::interrupt_enable()
|
Device::interrupt_enable()
|
||||||
{
|
{
|
||||||
if (_irq_attached) {
|
if (_irq) {
|
||||||
up_enable_irq(_irq);
|
up_enable_irq(_irq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +145,7 @@ Device::interrupt_enable()
|
|||||||
void
|
void
|
||||||
Device::interrupt_disable()
|
Device::interrupt_disable()
|
||||||
{
|
{
|
||||||
if (_irq_attached) {
|
if (_irq) {
|
||||||
up_disable_irq(_irq);
|
up_disable_irq(_irq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,8 +209,7 @@ protected:
|
|||||||
sem_t _lock; /**< lock to protect access to all class members (also for derived classes) */
|
sem_t _lock; /**< lock to protect access to all class members (also for derived classes) */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _irq;
|
int _irq; /**< if non-zero, it's a valid IRQ */
|
||||||
bool _irq_attached;
|
|
||||||
|
|
||||||
/** disable copy construction for this and all subclasses */
|
/** disable copy construction for this and all subclasses */
|
||||||
Device(const Device &);
|
Device(const Device &);
|
||||||
|
|||||||
Reference in New Issue
Block a user