]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
staging: comedi: rti800: tidy up ai two's complement support
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 9 Apr 2013 01:20:41 +0000 (18:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Apr 2013 23:29:24 +0000 (16:29 -0700)
The analog input on this board can return data as either two's
complement or straight binary data. The format is selected by a
jumper of the board and enabled by the user as option[4] when
attaching to the board.

Replace the adc_coding enum with a simple bool to indicate that
the data is returned in two's complement form.

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

index 917543a3effe8af9e63704b705b4838b2f8d2220..d788c19e7fb1c79ada911696f0c4eadea863ead6 100644 (file)
@@ -152,9 +152,7 @@ static const struct rti800_board rti800_boardtypes[] = {
 };
 
 struct rti800_private {
-       enum {
-               adc_2comp, adc_straight
-       } adc_coding;
+       bool adc_2comp;
        bool dac_2comp[2];
        const struct comedi_lrange *ao_range_type_list[2];
        unsigned int ao_readback[2];
@@ -221,7 +219,7 @@ static int rti800_ai_insn_read(struct comedi_device *dev,
                data[i] = inb(dev->iobase + RTI800_ADCLO);
                data[i] |= (0xf & inb(dev->iobase + RTI800_ADCHI)) << 8;
 
-               if (devpriv->adc_coding == adc_2comp)
+               if (devpriv->adc_2comp)
                        data[i] ^= 0x800;
        }
 
@@ -338,7 +336,7 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return -ENOMEM;
        dev->private = devpriv;
 
-       devpriv->adc_coding = it->options[4];
+       devpriv->adc_2comp = (it->options[4] == 0);
        devpriv->dac_2comp[0] = (it->options[6] == 0);
        devpriv->dac_2comp[1] = (it->options[8] == 0);
        /* invalid, forces the MUXGAIN register to be set when first used */