diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2013-11-02 19:44:00 +0000 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-11-05 22:45:25 +0000 |
commit | a5a3e43111e145aaaec4c60c927a8155b875890a (patch) | |
tree | 66379d7354a1a357360970df6f00cca39c1e12a6 /drivers/iio | |
parent | ec7f68e07bf10198717b7824c78201b46bbf1956 (diff) | |
download | linux-a5a3e43111e145aaaec4c60c927a8155b875890a.tar.bz2 |
iio: Fix sign extension table in mcp3422 driver
the index argument to sign_extend32() gives the bit position (from 0)
to the sign bit
so e.g. if the measurement has 16-bit resolution, we need to pass 15;
a measurement of 0x8000 should be reported as -32768, not 32768
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/mcp3422.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 12948325431c..c8c1baaec6c1 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -88,10 +88,10 @@ static const int mcp3422_sample_rates[4] = { /* sample rates to sign extension table */ static const int mcp3422_sign_extend[4] = { - [MCP3422_SRATE_240] = 12, - [MCP3422_SRATE_60] = 14, - [MCP3422_SRATE_15] = 16, - [MCP3422_SRATE_3] = 18 }; + [MCP3422_SRATE_240] = 11, + [MCP3422_SRATE_60] = 13, + [MCP3422_SRATE_15] = 15, + [MCP3422_SRATE_3] = 17 }; /* Client data (each client gets its own) */ struct mcp3422 { |