iio: adc: mcp3911: use correct id bits
Subsystems (2)
Marcus Folkesson
maintainerPATCH 1/1 iio: adc: mcp3911: use correct id bits
The device ID should be shifted 6 bits to left according to datasheet.
Fixes 3a89b289df5d ("iio: adc: add support for mcp3911")
Signed-off-by Marcus Folkesson <[email protected]>
--- drivers/iio/adc/mcp3911.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/mcp3911.c +2 -2
@@ -57,8 +57,8 @@/* Internal voltage reference in mV */ #define MCP3911_INT_VREF_MV 1200 -#define MCP3911_REG_READ (reg, id) ((((reg) << 1) | ((id) << 5) | (1 << 0)) & 0xff) -#define MCP3911_REG_WRITE (reg, id) ((((reg) << 1) | ((id) << 5) | (0 << 0)) & 0xff) +#define MCP3911_REG_READ (reg, id) ((((reg) << 1) | ((id) << 6) | (1 << 0)) & 0xff) +#define MCP3911_REG_WRITE (reg, id) ((((reg) << 1) | ((id) << 6) | (0 << 0)) & 0xff)#define MCP3911_NUM_CHANNELS 2#define MCP3911_NUM_SCALES 6
Signature · 1 line
2.37.1
Quoted 4 lines · On Mon, 10 Oct 2022 21:46:41 +0200 Marcus Folkesson…
The device ID should be shifted 6 bits to left according to datasheet.
Fixes 3a89b289df5d ("iio: adc: add support for mcp3911")Signed-off-by Marcus Folkesson <[email protected]>
Applied to the the fixes-togreg branch of iio.git.
Thanks,
Jonathan
Quoted 19 lines
--- drivers/iio/adc/mcp3911.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/mcp3911.c +2
-2@@ -57,8 +57,8 @@/* Internal voltage reference in mV */ #define MCP3911_INT_VREF_MV 1200 -#define MCP3911_REG_READ (reg, id) ((((reg) << 1) | ((id) << 5) | (1 << 0)) & 0xff) -#define MCP3911_REG_WRITE (reg, id) ((((reg) << 1) | ((id) << 5) | (0 << 0)) & 0xff) +#define MCP3911_REG_READ (reg, id) ((((reg) << 1) | ((id) << 6) | (1 << 0)) & 0xff) +#define MCP3911_REG_WRITE (reg, id) ((((reg) << 1) | ((id) << 6) | (0 << 0)) & 0xff)#define MCP3911_NUM_CHANNELS 2#define MCP3911_NUM_SCALES 6