提交 a7401cdd 编写于 作者: I Ian Abbott 提交者: Greg Kroah-Hartman

staging: comedi: make 'dev->attached' a bool bit-field

Change the `attached` member of `struct comedi_device` to a 1-bit
bit-field of type `bool`.  Change assigned values to `true` and `false`
and replace or remove comparison operations with simple boolean tests.

We'll put some extra bit-fields in the gap later to save space.
Signed-off-by: NIan Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 8bdfefb7
...@@ -207,7 +207,7 @@ struct comedi_device { ...@@ -207,7 +207,7 @@ struct comedi_device {
const char *board_name; const char *board_name;
const void *board_ptr; const void *board_ptr;
int attached; bool attached:1;
spinlock_t spinlock; spinlock_t spinlock;
struct mutex mutex; struct mutex mutex;
int in_request_module; int in_request_module;
......
...@@ -120,7 +120,7 @@ static void cleanup_device(struct comedi_device *dev) ...@@ -120,7 +120,7 @@ static void cleanup_device(struct comedi_device *dev)
static void __comedi_device_detach(struct comedi_device *dev) static void __comedi_device_detach(struct comedi_device *dev)
{ {
dev->attached = 0; dev->attached = false;
if (dev->driver) if (dev->driver)
dev->driver->detach(dev); dev->driver->detach(dev);
else else
...@@ -290,7 +290,7 @@ static int comedi_device_postconfig(struct comedi_device *dev) ...@@ -290,7 +290,7 @@ static int comedi_device_postconfig(struct comedi_device *dev)
dev->board_name = "BUG"; dev->board_name = "BUG";
} }
smp_wmb(); smp_wmb();
dev->attached = 1; dev->attached = true;
return 0; return 0;
} }
......
...@@ -1341,7 +1341,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) ...@@ -1341,7 +1341,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
static const int timeout = 10000; static const int timeout = 10000;
unsigned long flags; unsigned long flags;
if (dev->attached == 0) if (!dev->attached)
return IRQ_NONE; return IRQ_NONE;
async = s->async; async = s->async;
......
...@@ -3113,7 +3113,7 @@ static irqreturn_t handle_interrupt(int irq, void *d) ...@@ -3113,7 +3113,7 @@ static irqreturn_t handle_interrupt(int irq, void *d)
/* an interrupt before all the postconfig stuff gets done could /* an interrupt before all the postconfig stuff gets done could
* cause a NULL dereference if we continue through the * cause a NULL dereference if we continue through the
* interrupt handler */ * interrupt handler */
if (dev->attached == 0) { if (!dev->attached) {
DEBUG_PRINT("premature interrupt, ignoring\n"); DEBUG_PRINT("premature interrupt, ignoring\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -876,7 +876,7 @@ static void das16_interrupt(struct comedi_device *dev) ...@@ -876,7 +876,7 @@ static void das16_interrupt(struct comedi_device *dev)
int num_bytes, residue; int num_bytes, residue;
int buffer_index; int buffer_index;
if (dev->attached == 0) { if (!dev->attached) {
comedi_error(dev, "premature interrupt"); comedi_error(dev, "premature interrupt");
return; return;
} }
......
...@@ -499,7 +499,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d) ...@@ -499,7 +499,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d)
int status; int status;
struct comedi_device *dev = d; struct comedi_device *dev = d;
if (dev->attached == 0) { if (!dev->attached) {
comedi_error(dev, "premature interrupt"); comedi_error(dev, "premature interrupt");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -731,7 +731,7 @@ static irqreturn_t das1800_interrupt(int irq, void *d) ...@@ -731,7 +731,7 @@ static irqreturn_t das1800_interrupt(int irq, void *d)
struct comedi_device *dev = d; struct comedi_device *dev = d;
unsigned int status; unsigned int status;
if (dev->attached == 0) { if (!dev->attached) {
comedi_error(dev, "premature interrupt"); comedi_error(dev, "premature interrupt");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -887,7 +887,7 @@ static irqreturn_t ni_660x_interrupt(int irq, void *d) ...@@ -887,7 +887,7 @@ static irqreturn_t ni_660x_interrupt(int irq, void *d)
unsigned i; unsigned i;
unsigned long flags; unsigned long flags;
if (dev->attached == 0) if (!dev->attached)
return IRQ_NONE; return IRQ_NONE;
/* lock to avoid race with comedi_poll */ /* lock to avoid race with comedi_poll */
spin_lock_irqsave(&devpriv->interrupt_lock, flags); spin_lock_irqsave(&devpriv->interrupt_lock, flags);
......
...@@ -204,7 +204,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d) ...@@ -204,7 +204,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
short dpnt; short dpnt;
static const int sample_size = sizeof(devpriv->dma_buffer[0]); static const int sample_size = sizeof(devpriv->dma_buffer[0]);
if (dev->attached == 0) { if (!dev->attached) {
comedi_error(dev, "premature interrupt"); comedi_error(dev, "premature interrupt");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -1367,7 +1367,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) ...@@ -1367,7 +1367,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
struct comedi_async *async; struct comedi_async *async;
struct comedi_cmd *cmd; struct comedi_cmd *cmd;
if (dev->attached == 0) { if (!dev->attached) {
comedi_error(dev, "premature interrupt"); comedi_error(dev, "premature interrupt");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
...@@ -847,7 +847,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d) ...@@ -847,7 +847,7 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
struct mite_struct *mite = devpriv->mite; struct mite_struct *mite = devpriv->mite;
#endif #endif
if (dev->attached == 0) if (!dev->attached)
return IRQ_NONE; return IRQ_NONE;
smp_mb(); /* make sure dev->attached is checked before handler does anything else. */ smp_mb(); /* make sure dev->attached is checked before handler does anything else. */
......
...@@ -420,7 +420,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d) ...@@ -420,7 +420,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
unsigned int m_status = 0; unsigned int m_status = 0;
/* interrupcions parasites */ /* interrupcions parasites */
if (dev->attached == 0) { if (!dev->attached) {
/* assume it's from another card */ /* assume it's from another card */
return IRQ_NONE; return IRQ_NONE;
} }
......
...@@ -758,7 +758,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d) ...@@ -758,7 +758,7 @@ static irqreturn_t s626_irq_handler(int irq, void *d)
uint8_t group; uint8_t group;
uint16_t irqbit; uint16_t irqbit;
if (dev->attached == 0) if (!dev->attached)
return IRQ_NONE; return IRQ_NONE;
/* lock to avoid race with comedi_poll */ /* lock to avoid race with comedi_poll */
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册