Commit a5a3e431 authored by Peter Meerwald's avatar Peter Meerwald Committed by Jonathan Cameron

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: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Acked-by: default avatarAngelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent ec7f68e0
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment