iio: chemical: scd30: Use devm_mutex_init() over non-devm mutex_init()
Subsystems (2)
PATCH v3 1/1 iio: chemical: scd30: Use devm_mutex_init() over non-devm mutex_init()
The current code uses mutex_init() instead of devm_mutex_init(), which is incorrect as the rest of the file uses the devm automatic resource management API. Fix this so that the mutex is set up in the same way as the rest of the device data structure.
---
v3:
- Return ret instead of -ENOMEM.
drivers/iio/chemical/scd30_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/chemical/scd30_core.c +4 -1
@@ -714,7 +714,10 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv, state->pressure_comp =SCD30_PRESSURE_COMP_DEFAULT ; state->meas_interval =SCD30_MEAS_INTERVAL_DEFAULT ; state->command = command; -mutex_init (&state->lock); + ret =devm_mutex_init (dev, &state->lock); +if (ret) +return ret; +init_completion (&state->meas_ready);dev_set_drvdata (dev, indio_dev);
Signature · 1 line
2.54.0
Quoted 4 lines · Maxwell Doose
The current code uses
mutex_init()instead ofdevm_mutex_init(), which is incorrect as the rest of the file uses the devm automatic resource management API. Fix this so that the mutex is set up in the same way as the rest of the device data structure.
...
drivers/iio/chemical/scd30_core.c int scd30_probe(struct device *dev, int irq, const char *name, void *priv, · line 716
Quoted 2 lines
drivers/iio/chemical/scd30_core.c +0
-0state->meas_interval =SCD30_MEAS_INTERVAL_DEFAULT ; state->command = command;
+ blank line here.
Quoted 4 lines
drivers/iio/chemical/scd30_core.c +3
-1-mutex_init (&state->lock); + ret =devm_mutex_init (dev, &state->lock); +if (ret) +return ret;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerQuoted 6 lines · On Sat, 6 Jun 2026 08:58:20 +0300 Andy Shevchenko…
Quoted 4 lines · Maxwell Doose
The current code uses
mutex_init()instead ofdevm_mutex_init(), which is incorrect as the rest of the file uses the devm automatic resource management API. Fix this so that the mutex is set up in the same way as the rest of the device data structure.
Quoted 9 lines
Reviewed-by Andy Shevchenko <[email protected]>...
drivers/iio/chemical/scd30_core.c int scd30_probe(struct device *dev, int irq, const char *name, void *priv, · line 716
Quoted 2 lines
drivers/iio/chemical/scd30_core.c +0
-0state->meas_interval =SCD30_MEAS_INTERVAL_DEFAULT ; state->command = command;+ blank line here.
Tweaked and applied.
Quoted 5 lines
Quoted 4 lines
drivers/iio/chemical/scd30_core.c +3
-1-mutex_init (&state->lock); + ret =devm_mutex_init (dev, &state->lock); +if (ret) +return ret;