iio: potentiometer: mcp4131: fix double application of wiper shift
PATCH 1/1 iio: potentiometer: mcp4131: fix double application of wiper shift
The MCP4131 wiper address is shifted twice when preparing the SPI command in mcp4131_write_raw().
The address is already shifted when assigned to the local variable "address", but is then shifted again when written to data->buf[0]. This results in an incorrect command being sent to the device and breaks wiper writes to the second channel.
Remove the second shift and use the pre-shifted address directly when composing the SPI transfer.
Signed-off-by Lukas Schmid <[email protected]>
--- drivers/iio/potentiometer/mcp4131.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/potentiometer/mcp4131.c +1 -1
@@ -221,7 +221,7 @@ static int mcp4131_write_raw(struct iio_dev *indio_dev,mutex_lock (&data->lock); - data->buf[0 ] = address <<MCP4131_WIPER_SHIFT ; + data->buf[0 ] = address; data->buf[0 ] |=MCP4131_WRITE | (val >>8 ); data->buf[1 ] = val &0xFF ;/* 8 bits here */
Signature · 1 line
2.47.3