]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: pcmad: properly handle single/diff input configuration
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 5 Jun 2013 22:38:14 +0000 (15:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Jun 2013 19:01:35 +0000 (12:01 -0700)
The comedi_config utility is used to attach to this board. One of the
configuration options passed by the user sets the analog input reference
for single-ended or differential inputs.

Use the configuration option to correctly set the comedi_subdevice flags
as well as the number of channels.

Remove the 'differential' variable from the private data. Its not used
by the driver.

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

index 94f50f69e4d80479d99cf785c41d4a6d19f1966f..86597fcf23bf6ff0c9955d0ebbdfa3cc771d8c80 100644 (file)
@@ -30,9 +30,9 @@
  * Configuration options:
  *   [0] - I/O port base
  *   [1] - IRQ (unused)
- *   [2] - Analog input reference
- *        0 = single ended
- *        1 = differential
+ *   [2] - Analog input reference (must match jumpers)
+ *        0 = single-ended (16 channels)
+ *        1 = differential (8 channels)
  *   [3] - Analog input encoding (must match jumpers)
  *        0 = straight binary
  *        1 = two's complement
@@ -64,7 +64,6 @@ static const struct pcmad_board_struct pcmad_boards[] = {
 };
 
 struct pcmad_priv_struct {
-       int differential;
        int twos_comp;
 };
 
@@ -134,8 +133,15 @@ static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
        s = &dev->subdevices[0];
        s->type         = COMEDI_SUBD_AI;
-       s->subdev_flags = SDF_READABLE | AREF_GROUND;
-       s->n_chan       = 16;
+       if (it->options[1]) {
+               /* 8 differential channels */
+               s->subdev_flags = SDF_READABLE | AREF_DIFF;
+               s->n_chan       = 8;
+       } else {
+               /* 16 single-ended channels */
+               s->subdev_flags = SDF_READABLE | AREF_GROUND;
+               s->n_chan       = 16;
+       }
        s->len_chanlist = 1;
        s->maxdata      = board->ai_maxdata;
        s->range_table  = &range_unknown;