staging: comedi: me4000: refactor request_irq() during attach
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 5 Dec 2013 20:43:23 +0000 (13:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Dec 2013 21:07:15 +0000 (13:07 -0800)
Do the request_irq() before setting up the subdevices. This removes an
indent level and makes the code a bit cleaner.

Also, remove the dev_warn() noise about the 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/me4000.c

index e4afca44b5e06153c5f7a6b05af0a244768ef845..cb1032fb3248b6aacee1b73cd72ab0b1ddecd470 100644 (file)
@@ -1505,6 +1505,13 @@ static int me4000_auto_attach(struct comedi_device *dev,
 
        me4000_reset(dev);
 
+       if (pcidev->irq > 0) {
+               result = request_irq(pcidev->irq, me4000_ai_isr, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (result == 0)
+                       dev->irq = pcidev->irq;
+       }
+
        result = comedi_alloc_subdevices(dev, 4);
        if (result)
                return result;
@@ -1525,22 +1532,12 @@ static int me4000_auto_attach(struct comedi_device *dev,
                s->range_table = &me4000_ai_range;
                s->insn_read = me4000_ai_insn_read;
 
-               if (pcidev->irq > 0) {
-                       if (request_irq(pcidev->irq, me4000_ai_isr,
-                                       IRQF_SHARED, dev->board_name, dev)) {
-                               dev_warn(dev->class_dev,
-                                       "request_irq failed\n");
-                       } else {
-                               dev->read_subdev = s;
-                               s->subdev_flags |= SDF_CMD_READ;
-                               s->cancel = me4000_ai_cancel;
-                               s->do_cmdtest = me4000_ai_do_cmd_test;
-                               s->do_cmd = me4000_ai_do_cmd;
-
-                               dev->irq = pcidev->irq;
-                       }
-               } else {
-                       dev_warn(dev->class_dev, "No interrupt available\n");
+               if (dev->irq) {
+                       dev->read_subdev = s;
+                       s->subdev_flags |= SDF_CMD_READ;
+                       s->cancel = me4000_ai_cancel;
+                       s->do_cmdtest = me4000_ai_do_cmd_test;
+                       s->do_cmd = me4000_ai_do_cmd;
                }
        } else {
                s->type = COMEDI_SUBD_UNUSED;