diff mbox series

[v2,04/10] iio: pressure: mprls0025pa.c fix off-by-one enum

Message ID 20231224143500.10940-5-petre.rodan@subdimension.ro (mailing list archive)
State Changes Requested
Headers show
Series changes to mprls0025pa | expand

Commit Message

Petre Rodan Dec. 24, 2023, 2:34 p.m. UTC
Fix off-by-one error in transfer-function property.
The honeywell,transfer-function property takes values between 1-3 so
make sure the proper enum gets used.

Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
Signed-off-by: Andreas Klinger <ak@it-klinger.de>
---
 drivers/iio/pressure/mprls0025pa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--
2.41.0

Comments

Jonathan Cameron Dec. 26, 2023, 4:33 p.m. UTC | #1
On Sun, 24 Dec 2023 16:34:49 +0200
Petre Rodan <petre.rodan@subdimension.ro> wrote:

> Fix off-by-one error in transfer-function property.
> The honeywell,transfer-function property takes values between 1-3 so
> make sure the proper enum gets used.
> 
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
> Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Hi Petre

Same question on what Andreas has to do with this patch and need
for some other tag to explain that.

Needs a fixes tag as well.

> ---
>  drivers/iio/pressure/mprls0025pa.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c
> index 30fb2de36821..e3f0de020a40 100644
> --- a/drivers/iio/pressure/mprls0025pa.c
> +++ b/drivers/iio/pressure/mprls0025pa.c
> @@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client)
>  	struct iio_dev *indio_dev;
>  	struct device *dev = &client->dev;
>  	s64 scale, offset;
> +	u32 func;
> 
>  	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE))
>  		return dev_err_probe(dev, -EOPNOTSUPP,
> @@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client)
>  			return dev_err_probe(dev, ret,
>  				"honeywell,pmax-pascal could not be read\n");
>  		ret = device_property_read_u32(dev,
> -				"honeywell,transfer-function", &data->function);
> +				"honeywell,transfer-function", &func);
>  		if (ret)
>  			return dev_err_probe(dev, ret,
>  				"honeywell,transfer-function could not be read\n");
> +		data->function = func - 1;
>  		if (data->function > MPR_FUNCTION_C)
>  			return dev_err_probe(dev, -EINVAL,
>  				"honeywell,transfer-function %d invalid\n",
> --
> 2.41.0
>
Andy Shevchenko Dec. 27, 2023, 4:30 p.m. UTC | #2
On Sun, Dec 24, 2023 at 04:34:49PM +0200, Petre Rodan wrote:
> Fix off-by-one error in transfer-function property.
> The honeywell,transfer-function property takes values between 1-3 so
> make sure the proper enum gets used.

> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
> Signed-off-by: Andreas Klinger <ak@it-klinger.de>

Submitter's SoB always goes last, this is written in Submitting Patches document.
diff mbox series

Patch

diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c
index 30fb2de36821..e3f0de020a40 100644
--- a/drivers/iio/pressure/mprls0025pa.c
+++ b/drivers/iio/pressure/mprls0025pa.c
@@ -323,6 +323,7 @@  static int mpr_probe(struct i2c_client *client)
 	struct iio_dev *indio_dev;
 	struct device *dev = &client->dev;
 	s64 scale, offset;
+	u32 func;

 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE))
 		return dev_err_probe(dev, -EOPNOTSUPP,
@@ -362,10 +363,11 @@  static int mpr_probe(struct i2c_client *client)
 			return dev_err_probe(dev, ret,
 				"honeywell,pmax-pascal could not be read\n");
 		ret = device_property_read_u32(dev,
-				"honeywell,transfer-function", &data->function);
+				"honeywell,transfer-function", &func);
 		if (ret)
 			return dev_err_probe(dev, ret,
 				"honeywell,transfer-function could not be read\n");
+		data->function = func - 1;
 		if (data->function > MPR_FUNCTION_C)
 			return dev_err_probe(dev, -EINVAL,
 				"honeywell,transfer-function %d invalid\n",