aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorPetre Rodan <petre.rodan@subdimension.ro>2023-12-29 11:24:34 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-01-23 22:06:53 +0000
commitb586b40e1952a343ae68142d16512f39596ca71b (patch)
treef337ba72ed6298a69eb10051a8fb1b9e04148d97 /drivers/iio
parent0a0fb0e63e5178905e9fdba8195686b4e2de26c4 (diff)
downloadlinux-b586b40e1952a343ae68142d16512f39596ca71b.tar.gz
iio: pressure: mprls0025pa remove defaults
This driver supports 32*3 combinations of fixed ranges and transfer functions, plus custom ranges. So statistically a user has more than 99% chance that the provided default configuration will generate invalid pressure readings if the bindings are not initialized and the driver is instantiated via sysfs. The current patch removes this loophole making sure the driver loads only if the firmware properties are present. Co-developed-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro> Link: https://lore.kernel.org/r/20231229092445.30180-7-petre.rodan@subdimension.ro Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/pressure/mprls0025pa.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/drivers/iio/pressure/mprls0025pa.c b/drivers/iio/pressure/mprls0025pa.c
index 233cc1dc38ad5..e0a2a60c62452 100644
--- a/drivers/iio/pressure/mprls0025pa.c
+++ b/drivers/iio/pressure/mprls0025pa.c
@@ -353,34 +353,26 @@ static int mpr_probe(struct i2c_client *client)
return dev_err_probe(dev, ret,
"can't get and enable vdd supply\n");
- if (dev_fwnode(dev)) {
- ret = device_property_read_u32(dev, "honeywell,pmin-pascal",
- &data->pmin);
- if (ret)
- return dev_err_probe(dev, ret,
- "honeywell,pmin-pascal could not be read\n");
- ret = device_property_read_u32(dev, "honeywell,pmax-pascal",
- &data->pmax);
- if (ret)
- return dev_err_probe(dev, ret,
- "honeywell,pmax-pascal could not be read\n");
- ret = device_property_read_u32(dev,
- "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",
- data->function);
- } else {
- /* when loaded as i2c device we need to use default values */
- dev_notice(dev, "firmware node not found; using defaults\n");
- data->pmin = 0;
- data->pmax = 172369; /* 25 psi */
- data->function = MPR_FUNCTION_A;
- }
+ ret = device_property_read_u32(dev, "honeywell,pmin-pascal",
+ &data->pmin);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "honeywell,pmin-pascal could not be read\n");
+ ret = device_property_read_u32(dev, "honeywell,pmax-pascal",
+ &data->pmax);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "honeywell,pmax-pascal could not be read\n");
+ ret = device_property_read_u32(dev,
+ "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",
+ data->function);
data->outmin = mpr_func_spec[data->function].output_min;
data->outmax = mpr_func_spec[data->function].output_max;