[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260114-mprls_cleanup-v3-10-bc7f1c2957c2@subdimension.ro>
Date: Wed, 14 Jan 2026 18:55:39 +0200
From: Petre Rodan <petre.rodan@...dimension.ro>
To: Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Andreas Klinger <ak@...klinger.de>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Petre Rodan <petre.rodan@...dimension.ro>
Subject: [PATCH v3 10/13] iio: pressure: mprls0025pa: move memset to core
Move memset() from the bus specific code into core.
Zeroing out the buffer is performed because the sensor has noticeable
latch-up sensitivity and in some cases it clamps the MISO signal to GND
in sync with SCLK [1]. A raw conversion of zero is out of bounds since
valid values have to be between output_min and output_max (and the
smallest output_min is 2.5% of 2^24 = 419430).
The user is expected to discard out of bounds pressure values.
Given the fact that we can't follow the behaviour of all SPI controllers
when faced to this clamping of an output signal, a raw conversion of zero
is used as an early warning in case the low level SPI API reacts
unexpectedly.
Link: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1588325/am3358-spi-tx-data-corruption [1]
Signed-off-by: Petre Rodan <petre.rodan@...dimension.ro>
---
v1 -> v3 no changes
---
drivers/iio/pressure/mprls0025pa.c | 2 ++
drivers/iio/pressure/mprls0025pa_i2c.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c
index 2bcd339dc84e..a7041a503bde 100644
--- a/drivers/iio/pressure/mprls0025pa.c
+++ b/drivers/iio/pressure/mprls0025pa.c
@@ -22,6 +22,7 @@
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/property.h>
+#include <linux/string.h>
#include <linux/units.h>
#include <linux/gpio/consumer.h>
@@ -247,6 +248,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press)
}
}
+ memset(data->rx_buf, 0, sizeof(data->rx_buf));
ret = data->ops->read(data, MPR_CMD_NOP, MPR_PKT_NOP_LEN);
if (ret < 0)
return ret;
diff --git a/drivers/iio/pressure/mprls0025pa_i2c.c b/drivers/iio/pressure/mprls0025pa_i2c.c
index a0bbc6af9283..0fe8cfe0d7e7 100644
--- a/drivers/iio/pressure/mprls0025pa_i2c.c
+++ b/drivers/iio/pressure/mprls0025pa_i2c.c
@@ -25,7 +25,6 @@ static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt)
if (cnt > MPR_MEASUREMENT_RD_SIZE)
return -EOVERFLOW;
- memset(data->rx_buf, 0, MPR_MEASUREMENT_RD_SIZE);
ret = i2c_master_recv(client, data->rx_buf, cnt);
if (ret < 0)
return ret;
--
2.52.0
Powered by blists - more mailing lists