The irq is only needed to support async commands. Tidy up the
code that does the request_irq() and remove the noise.

Only hookup the subdevice command support if the irq is available.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/ni_at_a2150.c | 45 +++++++++++++---------------
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c 
b/drivers/staging/comedi/drivers/ni_at_a2150.c
index cc69dde..8924fbd 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -689,7 +689,6 @@ static int a2150_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
        const struct a2150_board *thisboard = comedi_board(dev);
        struct a2150_private *devpriv;
        struct comedi_subdevice *s;
-       unsigned int irq = it->options[1];
        unsigned int dma = it->options[2];
        static const int timeout = 2000;
        int i;
@@ -703,21 +702,20 @@ static int a2150_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
        if (ret)
                return ret;
 
-       /* grab our IRQ */
-       if (irq) {
-               /*  check that irq is supported */
-               if (irq < 3 || irq == 8 || irq == 13 || irq > 15) {
-                       printk(" invalid irq line %u\n", irq);
-                       return -EINVAL;
-               }
-               if (request_irq(irq, a2150_interrupt, 0,
-                               dev->driver->driver_name, dev)) {
-                       printk("unable to allocate irq %u\n", irq);
-                       return -EINVAL;
+       dev->board_ptr = a2150_boards + a2150_probe(dev);
+       thisboard = comedi_board(dev);
+       dev->board_name = thisboard->name;
+
+       /* only irqs 3, 4, 5, 6, 7, 9, 10, 11, 12, 14 and 15 are valid */
+       if ((1 << it->options[1]) & 0xdef8) {
+               ret = request_irq(it->options[1], a2150_interrupt, 0,
+                                 dev->board_name, dev);
+               if (ret == 0) {
+                       dev->irq = it->options[1];
+                       devpriv->irq_dma_bits |= IRQ_LVL_BITS(dev->irq);
                }
-               devpriv->irq_dma_bits |= IRQ_LVL_BITS(irq);
-               dev->irq = irq;
        }
+
        /*  initialize dma */
        if (dma) {
                if (dma == 4 || dma > 7) {
@@ -740,27 +738,26 @@ static int a2150_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
                devpriv->irq_dma_bits |= DMA_CHAN_BITS(dma);
        }
 
-       dev->board_ptr = a2150_boards + a2150_probe(dev);
-       thisboard = comedi_board(dev);
-       dev->board_name = thisboard->name;
-
        ret = comedi_alloc_subdevices(dev, 1);
        if (ret)
                return ret;
 
        /* analog input subdevice */
        s = &dev->subdevices[0];
-       dev->read_subdev = s;
        s->type = COMEDI_SUBD_AI;
-       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_OTHER | SDF_CMD_READ;
+       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_OTHER;
        s->n_chan = 4;
-       s->len_chanlist = 4;
        s->maxdata = 0xffff;
        s->range_table = &range_a2150;
-       s->do_cmd = a2150_ai_cmd;
-       s->do_cmdtest = a2150_ai_cmdtest;
        s->insn_read = a2150_ai_rinsn;
-       s->cancel = a2150_cancel;
+       if (dev->irq) {
+               dev->read_subdev = s;
+               s->subdev_flags |= SDF_CMD_READ;
+               s->len_chanlist = 4;
+               s->do_cmd = a2150_ai_cmd;
+               s->do_cmdtest = a2150_ai_cmdtest;
+               s->cancel = a2150_cancel;
+       }
 
        /* need to do this for software counting of completed conversions, to
         * prevent hardware count from stopping acquisition */
-- 
1.8.4.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to