staging: comedi: pcl816: only init command support if irq is available
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 3 Dec 2013 19:07:12 +0000 (12:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Dec 2013 23:25:30 +0000 (15:25 -0800)
The async command support requires an irq. Only initialize the subdevice
command support if the request_irq was successfull.

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

index a102db34e131112ae8cf1beae52f5f2a00bab00c..ed4d57f8a1bd5dc60bdbeac64b8bcd49d8cd8aae 100644 (file)
@@ -949,18 +949,20 @@ no_dma:
        if (board->n_aichan > 0) {
                s->type = COMEDI_SUBD_AI;
                devpriv->sub_ai = s;
-               dev->read_subdev = s;
-               s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+               s->subdev_flags = SDF_CMD_READ | SDF_DIFF;
                s->n_chan = board->n_aichan;
-               s->subdev_flags |= SDF_DIFF;
                s->maxdata = board->ai_maxdata;
-               s->len_chanlist = board->ai_chanlist;
                s->range_table = board->ai_range_type;
-               s->cancel = pcl816_ai_cancel;
-               s->do_cmdtest = pcl816_ai_cmdtest;
-               s->do_cmd = pcl816_ai_cmd;
-               s->poll = pcl816_ai_poll;
                s->insn_read = pcl816_ai_insn_read;
+               if (dev->irq) {
+                       dev->read_subdev = s;
+                       s->subdev_flags |= SDF_CMD_READ;
+                       s->len_chanlist = board->ai_chanlist;
+                       s->do_cmdtest = pcl816_ai_cmdtest;
+                       s->do_cmd = pcl816_ai_cmd;
+                       s->poll = pcl816_ai_poll;
+                       s->cancel = pcl816_ai_cancel;
+               }
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }