staging: comedi: dt3000: don't fail attach if irq is not available
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 5 Dec 2013 20:43:37 +0000 (13:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Dec 2013 21:07:16 +0000 (13:07 -0800)
The irq is only needed to support async commands. Don't fail the attach
if it is not available.

Only hook up the command support if the request_irq() was successful.

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/dt3000.c

index 1410943807b9d90d1a253db8c2746503978feb25..50aaa011153c6e2148acd89f0c0cd286c04da2b4 100644 (file)
@@ -702,29 +702,33 @@ static int dt3000_auto_attach(struct comedi_device *dev,
        if (!devpriv->io_addr)
                return -ENOMEM;
 
-       ret = request_irq(pcidev->irq, dt3k_interrupt, IRQF_SHARED,
-                         dev->board_name, dev);
-       if (ret)
-               return ret;
-       dev->irq = pcidev->irq;
+       if (pcidev->irq) {
+               ret = request_irq(pcidev->irq, dt3k_interrupt, IRQF_SHARED,
+                                 dev->board_name, dev);
+               if (ret == 0)
+                       dev->irq = pcidev->irq;
+       }
 
        ret = comedi_alloc_subdevices(dev, 4);
        if (ret)
                return ret;
 
        s = &dev->subdevices[0];
-       dev->read_subdev = s;
        /* ai subdevice */
        s->type         = COMEDI_SUBD_AI;
-       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
+       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
        s->n_chan       = this_board->adchan;
        s->insn_read    = dt3k_ai_insn;
        s->maxdata      = (1 << this_board->adbits) - 1;
-       s->len_chanlist = 512;
        s->range_table  = &range_dt3000_ai;     /* XXX */
-       s->do_cmd       = dt3k_ai_cmd;
-       s->do_cmdtest   = dt3k_ai_cmdtest;
-       s->cancel       = dt3k_ai_cancel;
+       if (dev->irq) {
+               dev->read_subdev = s;
+               s->subdev_flags |= SDF_CMD_READ;
+               s->len_chanlist = 512;
+               s->do_cmd       = dt3k_ai_cmd;
+               s->do_cmdtest   = dt3k_ai_cmdtest;
+               s->cancel       = dt3k_ai_cancel;
+       }
 
        s = &dev->subdevices[1];
        /* ao subsystem */