Skip to contentSkip to conversation

iio: accel: msa311: use devm_mutex_init()

PATCH Applied Niloy Meharchandani 3 participants 3 messages Nov 15 – Nov 22 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: accel: msa311: use devm_mutex_init()

Initialize msa311->lock via devm_mutex_init() instead of mutex_init() in msa311_probe() and propagate any initialization error. Include <linux/mutex.h> explicitly.

Since msa311 already manages all remaining resources with devm_* helpers and defines no remove() callback, using devm_mutex_init() ensures proper mutex cleanup on probe failure or device removal when CONFIG_DEBUG_MUTEXES is enabled.

No functional change intended. Compile-tested only.

---
 drivers/iio/accel/msa311.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/accel/msa311.c +4 -1
index caf9b1b6397f..0e1af4761b7d 100644
@@ -29,6 +29,7 @@
 
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
@@ -1156,7 +1157,9 @@ static int msa311_probe(struct i2c_client *i2c)
 	if (err)
 		return err;
 
-	mutex_init(&msa311->lock);
+	err = devm_mutex_init(dev, &msa311->lock);
+	if (err)
+		return err;
 
 	err = devm_regulator_get_enable(dev, "vdd");
 	if (err)
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Niloy Meharchandani

Initialize msa311->lock via devm_mutex_init() instead of mutex_init() in msa311_probe() and propagate any initialization error. Include <linux/mutex.h> explicitly.

maintainer Applied
#2 lore raw
Quoted 7 lines · On Sun, 15 Nov 2026 09:25:57 +0530 Arnav Kapoor <[email protected]> wrote:
Quoted 3 lines · Niloy Meharchandani

Initialize msa311->lock via devm_mutex_init() instead of mutex_init() in msa311_probe() and propagate any initialization error. Include <linux/mutex.h> explicitly.

Applied, but Niloy, these are low value so I'd suggest moving on to something else for next patch!

I normally only take these form new contributors or when someone is already touching the surrounding code. It isn't worth the churn to take them otherwise.

Thanks,

Jonathan