iio: adc: xilinx: Fix VREFN sign
authorThomas Betker <thomas.betker@rohde-schwarz.com>
Wed, 15 Apr 2015 19:11:50 +0000 (21:11 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 19 Apr 2015 12:49:54 +0000 (13:49 +0100)
The VREFN channel is bipolar, not unipolar. Small negative values do
occur (e.g., -1mV), and unsigned conversion maps them incorrectly to
large positive values (about +1V), so fix this.

Signed-off-by: Thomas Betker <thomas.betker@rohde-schwarz.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/xilinx-xadc-core.c

index 6fa629b3c168a7e6125d15c82590bc36b6969ce1..ce93bd8e3f68b82fec81b31f8f1885b908ef0b45 100644 (file)
@@ -997,7 +997,7 @@ static const struct iio_event_spec xadc_voltage_events[] = {
        .num_event_specs = (_alarm) ? ARRAY_SIZE(xadc_voltage_events) : 0, \
        .scan_index = (_scan_index), \
        .scan_type = { \
-               .sign = 'u', \
+               .sign = ((_addr) == XADC_REG_VREFN) ? 's' : 'u', \
                .realbits = 12, \
                .storagebits = 16, \
                .shift = 4, \