staging: comedi: pcl812: all board types have analog inputs
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 17 Feb 2014 21:26:58 +0000 (14:26 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Feb 2014 19:53:54 +0000 (11:53 -0800)
All the boards supported by this driver have 16 or 32 analog input
channels.

Remove the unnecessary check in pcl812_attach() to reduce the indent
level of the code.

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

index 1d8366e97ebb5092fe19a273373d65ae8bbb8601..4909a106b2cedb97d9a046e10b6917a68578cea6 100644 (file)
@@ -1422,9 +1422,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                devpriv->hwdmasize[1] = PAGE_SIZE * (1 << pages);
        }
 
-       n_subdevices = 0;
-       if (board->n_aichan > 0)
-               n_subdevices++;
+       n_subdevices = 1;               /* all boardtypes have analog inputs */
        if (board->n_aochan > 0)
                n_subdevices++;
        if (board->has_dio)
@@ -1436,59 +1434,59 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        subdev = 0;
 
-       /* analog input */
-       if (board->n_aichan > 0) {
-               s = &dev->subdevices[subdev];
-               s->type = COMEDI_SUBD_AI;
-               s->subdev_flags = SDF_READABLE;
-               switch (board->board_type) {
-               case boardA821:
-                       if (it->options[2] == 1) {
-                               s->n_chan = board->n_aichan_diff;
-                               s->subdev_flags |= SDF_DIFF;
-                               devpriv->use_diff = 1;
-                       } else {
-                               s->n_chan = board->n_aichan;
-                               s->subdev_flags |= SDF_GROUND;
-                       }
-                       break;
-               case boardACL8112:
-               case boardACL8216:
-                       if (it->options[4] == 1) {
-                               s->n_chan = board->n_aichan_diff;
-                               s->subdev_flags |= SDF_DIFF;
-                               devpriv->use_diff = 1;
-                       } else {
-                               s->n_chan = board->n_aichan;
-                               s->subdev_flags |= SDF_GROUND;
-                       }
-                       break;
-               default:
-                       s->n_chan = board->n_aichan;
-                       s->subdev_flags |= SDF_GROUND;
-                       break;
+       /* Analog Input subdevice */
+       s = &dev->subdevices[subdev];
+       s->type         = COMEDI_SUBD_AI;
+       s->subdev_flags = SDF_READABLE;
+       switch (board->board_type) {
+       case boardA821:
+               if (it->options[2] == 1) {
+                       s->n_chan       = board->n_aichan_diff;
+                       s->subdev_flags |= SDF_DIFF;
+                       devpriv->use_diff = 1;
+               } else {
+                       s->n_chan       = board->n_aichan;
+                       s->subdev_flags |= SDF_GROUND;
                }
-               s->maxdata = board->ai_maxdata;
-
-               pcl812_set_ai_range_table(dev, s, it);
-
-               if (board->board_type == boardACL8216)
-                       s->insn_read = acl8216_ai_insn_read;
-               else
-                       s->insn_read = pcl812_ai_insn_read;
-
-               devpriv->use_MPC = board->has_mpc508_mux;
-               if (dev->irq) {
-                       dev->read_subdev = s;
-                       s->subdev_flags |= SDF_CMD_READ;
-                       s->len_chanlist = MAX_CHANLIST_LEN;
-                       s->do_cmdtest = pcl812_ai_cmdtest;
-                       s->do_cmd = pcl812_ai_cmd;
-                       s->poll = pcl812_ai_poll;
-                       s->cancel = pcl812_ai_cancel;
+               break;
+       case boardACL8112:
+       case boardACL8216:
+               if (it->options[4] == 1) {
+                       s->n_chan       = board->n_aichan_diff;
+                       s->subdev_flags |= SDF_DIFF;
+                       devpriv->use_diff = 1;
+               } else {
+                       s->n_chan       = board->n_aichan;
+                       s->subdev_flags |= SDF_GROUND;
                }
-               subdev++;
+               break;
+       default:
+               s->n_chan       = board->n_aichan;
+               s->subdev_flags |= SDF_GROUND;
+               break;
        }
+       s->maxdata      = board->ai_maxdata;
+
+       pcl812_set_ai_range_table(dev, s, it);
+
+       if (board->board_type == boardACL8216)
+               s->insn_read    = acl8216_ai_insn_read;
+       else
+               s->insn_read    = pcl812_ai_insn_read;
+
+       if (dev->irq) {
+               dev->read_subdev = s;
+               s->subdev_flags |= SDF_CMD_READ;
+               s->len_chanlist = MAX_CHANLIST_LEN;
+               s->do_cmdtest   = pcl812_ai_cmdtest;
+               s->do_cmd       = pcl812_ai_cmd;
+               s->poll         = pcl812_ai_poll;
+               s->cancel       = pcl812_ai_cancel;
+       }
+
+       devpriv->use_MPC = board->has_mpc508_mux;
+
+       subdev++;
 
        /* analog output */
        if (board->n_aochan > 0) {