Skip to content

Commit 85e4614

Browse files
libschmudie-sojic23
authored andcommitted
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. Fixes: 22d199a ("iio: potentiometer: add driver for Microchip MCP413X/414X/415X/416X/423X/424X/425X/426X") Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li># Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent d23d763 commit 85e4614

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/potentiometer/mcp4131.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int mcp4131_write_raw(struct iio_dev *indio_dev,
221221

222222
mutex_lock(&data->lock);
223223

224-
data->buf[0] = address << MCP4131_WIPER_SHIFT;
224+
data->buf[0] = address;
225225
data->buf[0] |= MCP4131_WRITE | (val >> 8);
226226
data->buf[1] = val & 0xFF; /* 8 bits here */
227227

0 commit comments

Comments
 (0)