staging: comedi: pcmmio: tidy up the ai subdevice init
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 9 Dec 2013 22:30:44 +0000 (15:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2013 18:01:50 +0000 (10:01 -0800)
Add some whitespace to the ai subdevice init and reorder it a bit
to follow the "norm" in comedi drivers.

Remove the init of s->len_chanlist. This member is only used with
subdevices that support async commands. The core will default the
value correctly..

The ai subdevice only uses the s->private member to pass the iobase
to the analog input registers. It's just a copy of the dev->iobase,
use that instead.

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

index 52f1085..704911c 100644 (file)
@@ -99,6 +99,7 @@ Configuration Options:
 #define PCMMIO_AI_STATUS_REG_SEL       (1 << 3)
 #define PCMMIO_AI_STATUS_CMD_DRQ_ENA   (1 << 1)
 #define PCMMIO_AI_STATUS_IRQ_ENA       (1 << 0)
+#define PCMMIO_AI_RESOURCE_REG         0x03
 #define PCMMIO_AI_2ND_ADC_OFFSET       0x04
 
 /* This stuff is all from pcmuio.c -- it refers to the DIO subdevices only */
@@ -790,7 +791,7 @@ static int pcmmio_ai_insn_read(struct comedi_device *dev,
                               struct comedi_insn *insn,
                               unsigned int *data)
 {
-       unsigned long iobase = subpriv->iobase;
+       unsigned long iobase = dev->iobase;
        unsigned int chan = CR_CHAN(insn->chanspec);
        unsigned int range = CR_RANGE(insn->chanspec);
        unsigned int aref = CR_AREF(insn->chanspec);
@@ -974,20 +975,19 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        if (ret)
                return ret;
 
-       /* First, AI */
+       /* Analog Input subdevice */
        s = &dev->subdevices[0];
-       s->private = &devpriv->sprivs[0];
-       s->maxdata = 0xffff;
-       s->range_table = &pcmmio_ai_ranges;
-       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
-       s->type = COMEDI_SUBD_AI;
-       s->n_chan = 16;
-       s->len_chanlist = s->n_chan;
-       s->insn_read = pcmmio_ai_insn_read;
-       subpriv->iobase = dev->iobase + 0;
+       s->type         = COMEDI_SUBD_AI;
+       s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
+       s->n_chan       = 16;
+       s->maxdata      = 0xffff;
+       s->range_table  = &pcmmio_ai_ranges;
+       s->insn_read    = pcmmio_ai_insn_read;
+
        /* initialize the resource enable register by clearing it */
-       outb(0, subpriv->iobase + 3);
-       outb(0, subpriv->iobase + 4 + 3);
+       outb(0, dev->iobase + PCMMIO_AI_RESOURCE_REG);
+       outb(0,
+            dev->iobase + PCMMIO_AI_2ND_ADC_OFFSET + PCMMIO_AI_RESOURCE_REG);
 
        /* Next, AO */
        s = &dev->subdevices[1];