staging: comedi: pcl818: tidy up the irq support in pcl818_attach()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 26 Nov 2013 23:42:18 +0000 (16:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Dec 2013 17:20:22 +0000 (09:20 -0800)
Tidy up the code that does the request_irq().

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcl818.c

index 945a5dd4ec483bb89c3a2d155783d74de6749a03..15b424733a9ebf823e04ff3eb0a3fa4260180656 100644 (file)
@@ -1204,7 +1204,6 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        const struct pcl818_board *board = comedi_board(dev);
        struct pcl818_private *devpriv;
        int ret;
-       unsigned int irq;
        int dma;
        unsigned long pages;
        struct comedi_subdevice *s;
@@ -1228,28 +1227,15 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return -EIO;
        }
 
-       /* grab our IRQ */
-       irq = 0;
-       if (board->IRQbits != 0) {      /* board support IRQ */
-               irq = it->options[1];
-               if (irq) {      /* we want to use IRQ */
-                       if (((1 << irq) & board->IRQbits) == 0) {
-                               irq = 0;        /* Bad IRQ */
-                       } else {
-                               if (request_irq(irq, interrupt_pcl818, 0,
-                                               dev->board_name, dev)) {
-                                       irq = 0;        /* Can't use IRQ */
-                               }
-                       }
+       if ((1 << it->options[1]) & board->IRQbits) {
+               ret = request_irq(it->options[1], interrupt_pcl818, 0,
+                                 dev->board_name, dev);
+               if (ret == 0) {
+                       dev->irq = it->options[1];
+                       devpriv->irq_free = 1;
                }
        }
 
-       dev->irq = irq;
-       if (irq)
-               devpriv->irq_free = 1;   /* 1=we have allocated irq */
-       else
-               devpriv->irq_free = 0;
-
        devpriv->irq_blocked = 0;       /* number of subdevice which use IRQ */
        devpriv->ai_mode = 0;   /* mode of irq */
 
@@ -1311,7 +1297,7 @@ no_dma:
                s->range_table = board->ai_range_type;
                s->cancel = pcl818_ai_cancel;
                s->insn_read = pcl818_ai_insn_read;
-               if (irq) {
+               if (dev->irq) {
                        dev->read_subdev = s;
                        s->subdev_flags |= SDF_CMD_READ;
                        s->do_cmdtest = ai_cmdtest;