[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260114-mprls_cleanup-v3-12-bc7f1c2957c2@subdimension.ro>
Date: Wed, 14 Jan 2026 18:55:41 +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 12/13] iio: pressure: mprls0025pa: change measurement
sequence
Implement a measurement sequence that does not involve a one byte read of
the status byte before reading the conversion.
The sensor's conversions should be read either once the EoC interrupt
has triggered or 5ms after the 0xaa command. See Options 1 and 2
respectively in Tables 16 (page 15) and 18 (page 18) of the datasheet.
Note that Honeywell's example code also covered in the datasheet follows
Option 2 for both i2c and SPI.
The datasheet does not specify any of the retry parameters that are
currently implemented in the driver. A simple 5+ms sleep as specified in
Option 2 is enough for a valid measurement sequence.
The change also gets rid of the code duplication tied to the verification
of the status byte.
This change only affects users that do not define the EoC interrupt in
the device tree.
Datasheet: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf?download=false
Signed-off-by: Petre Rodan <petre.rodan@...dimension.ro>
---
v1 -> v2 rewrote commit message
v2 -> v3 rewrote commit message
---
drivers/iio/pressure/mprls0025pa.c | 32 +++-----------------------------
1 file changed, 3 insertions(+), 29 deletions(-)
diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c
index 31ec2bae84b1..b1122ace6bac 100644
--- a/drivers/iio/pressure/mprls0025pa.c
+++ b/drivers/iio/pressure/mprls0025pa.c
@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/property.h>
#include <linux/string.h>
+#include <linux/time.h>
#include <linux/units.h>
#include <linux/gpio/consumer.h>
@@ -41,10 +42,6 @@
/* bits in status byte */
#define MPR_ST_POWER BIT(6) /* device is powered */
#define MPR_ST_BUSY BIT(5) /* device is busy */
-#define MPR_ST_MEMORY BIT(2) /* integrity test passed */
-#define MPR_ST_MATH BIT(0) /* internal math saturation */
-
-#define MPR_ST_ERR_FLAG (MPR_ST_BUSY | MPR_ST_MEMORY | MPR_ST_MATH)
/*
* support _RAW sysfs interface:
@@ -206,8 +203,7 @@ static void mpr_reset(struct mpr_data *data)
static int mpr_read_pressure(struct mpr_data *data, s32 *press)
{
struct device *dev = data->dev;
- int ret, i;
- int nloops = 10;
+ int ret;
reinit_completion(&data->completion);
@@ -224,29 +220,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press)
return -ETIMEDOUT;
}
} else {
- /* wait until status indicates data is ready */
- for (i = 0; i < nloops; i++) {
- /*
- * datasheet only says to wait at least 5 ms for the
- * data but leave the maximum response time open
- * --> let's try it nloops (10) times which seems to be
- * quite long
- */
- usleep_range(5000, 10000);
- ret = data->ops->read(data, MPR_CMD_NOP, 1);
- if (ret < 0) {
- dev_err(dev,
- "error while reading, status: %d\n",
- ret);
- return ret;
- }
- if (!(data->rx_buf[0] & MPR_ST_ERR_FLAG))
- break;
- }
- if (i == nloops) {
- dev_err(dev, "timeout while reading\n");
- return -ETIMEDOUT;
- }
+ fsleep(5 * USEC_PER_MSEC);
}
memset(data->rx_buf, 0, sizeof(data->rx_buf));
--
2.52.0
Powered by blists - more mailing lists