staging: comedi: das08: Initialize AO channels
authorIan Abbott <abbotti@mev.co.uk>
Fri, 31 Aug 2012 19:41:43 +0000 (20:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Sep 2012 19:00:42 +0000 (12:00 -0700)
Initialize the AO subdevice channels to mid-range data value so they are
in a known state.  This allows us to support reading back the current
value in a later patch.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das08.c

index 13e6ac75b0e180b1b07ad981c9ebf289d03fe71b..0457b9b7ef2d618c2818b51e47cd047767335599 100644 (file)
@@ -391,6 +391,17 @@ static void das08_ao_set_data(struct comedi_device *dev,
        }
 }
 
+static void das08_ao_initialize(struct comedi_device *dev,
+                               struct comedi_subdevice *s)
+{
+       int n;
+       unsigned int data;
+
+       data = s->maxdata / 2;  /* should be about 0 volts */
+       for (n = 0; n < s->n_chan; n++)
+               das08_ao_set_data(dev, n, data);
+}
+
 static int das08_ao_winsn(struct comedi_device *dev,
                          struct comedi_subdevice *s,
                          struct comedi_insn *insn, unsigned int *data)
@@ -665,6 +676,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
                s->maxdata = (1 << thisboard->ao_nbits) - 1;
                s->range_table = &range_bipolar5;
                s->insn_write = das08_ao_winsn;
+               das08_ao_initialize(dev, s);
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }