Commit 9e65506c authored by Petre Rodan's avatar Petre Rodan Committed by Jonathan Cameron

iio: pressure: mprls0025pa fix off-by-one enum

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.

Fixes: 713337d9 ("iio: pressure: Honeywell mprls0025pa pressure sensor")
Co-developed-by: default avatarAndreas Klinger <ak@it-klinger.de>
Signed-off-by: default avatarAndreas Klinger <ak@it-klinger.de>
Signed-off-by: default avatarPetre Rodan <petre.rodan@subdimension.ro>
Link: https://lore.kernel.org/r/20231229092445.30180-5-petre.rodan@subdimension.roSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent f0884916
...@@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client) ...@@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client)
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct device *dev = &client->dev; struct device *dev = &client->dev;
s64 scale, offset; s64 scale, offset;
u32 func;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE))
return dev_err_probe(dev, -EOPNOTSUPP, return dev_err_probe(dev, -EOPNOTSUPP,
...@@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client) ...@@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client)
return dev_err_probe(dev, ret, return dev_err_probe(dev, ret,
"honeywell,pmax-pascal could not be read\n"); "honeywell,pmax-pascal could not be read\n");
ret = device_property_read_u32(dev, ret = device_property_read_u32(dev,
"honeywell,transfer-function", &data->function); "honeywell,transfer-function", &func);
if (ret) if (ret)
return dev_err_probe(dev, ret, return dev_err_probe(dev, ret,
"honeywell,transfer-function could not be read\n"); "honeywell,transfer-function could not be read\n");
data->function = func - 1;
if (data->function > MPR_FUNCTION_C) if (data->function > MPR_FUNCTION_C)
return dev_err_probe(dev, -EINVAL, return dev_err_probe(dev, -EINVAL,
"honeywell,transfer-function %d invalid\n", "honeywell,transfer-function %d invalid\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment