* [PATCH] iio: accel: msa311: use devm_mutex_init()
@ 2026-11-15 2:01 Niloy Meharchandani
2026-11-15 3:55 ` Arnav Kapoor
0 siblings, 1 reply; 2+ messages in thread
From: Niloy Meharchandani @ 2026-11-15 2:01 UTC (permalink / raw)
To: Jonathan Cameron
Cc: David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, 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.
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.
Signed-off-by: Niloy Meharchandani <niloymeharchandani@gmail.com>
---
drivers/iio/accel/msa311.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c
index caf9b1b6397f..0e1af4761b7d 100644
--- a/drivers/iio/accel/msa311.c
+++ b/drivers/iio/accel/msa311.c
@@ -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)
--
2.53.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-15 3:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 2:01 [PATCH] iio: accel: msa311: use devm_mutex_init() Niloy Meharchandani
2026-11-15 3:55 ` Arnav Kapoor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®