[PATCH 06/14] iio: pressure: mprls0025pa: memset rx_buf before reading new data

From: Petre Rodan

Date: Thu Dec 18 2025 - 06:10:30 EST


Zero out input buffer before reading the new conversion.
Perform this operation in core instead of in the bus specific code.

Signed-off-by: Petre Rodan <petre.rodan@xxxxxxxxxxxxxxx>
---
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 00b1ff1e50a8..7cc8dd0d8476 100644
--- a/drivers/iio/pressure/mprls0025pa.c
+++ b/drivers/iio/pressure/mprls0025pa.c
@@ -16,6 +16,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>
@@ -239,6 +240,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.51.2