mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RESEND [PATCH v1] iio: potentiometer: mcp4131: fix double application of wiper shift
@ 2026-02-02 20:15 Lukas Schmid
  2026-02-02 20:29 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Schmid @ 2026-02-02 20:15 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
  Cc: Lukas Schmid, linux-iio, linux-kernel

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 <lukas.schmid@netcube.li>
---
 drivers/iio/potentiometer/mcp4131.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c
index ad082827aad5..56c9111ef5e8 100644
--- a/drivers/iio/potentiometer/mcp4131.c
+++ b/drivers/iio/potentiometer/mcp4131.c
@@ -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 */
 
-- 
2.47.3



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-02 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-02 20:15 RESEND [PATCH v1] iio: potentiometer: mcp4131: fix double application of wiper shift Lukas Schmid
2026-02-02 20:29 ` Jonathan Cameron
2026-02-02 20:34   ` Jonathan Cameron
2026-02-02 20:59     ` Lukas Schmid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®