mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Niloy Meharchandani <niloymeharchandani@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Niloy Meharchandani" <niloymeharchandani@gmail.com>
Subject: [PATCH] iio: accel: msa311: use devm_mutex_init()
Date: Sat, 14 Nov 2026 18:01:29 -0800	[thread overview]
Message-ID: <20261115020129.10259-1-niloymeharchandani@gmail.com> (raw)

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


             reply	other threads:[~2026-11-15  2:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15  2:01 Niloy Meharchandani [this message]
2026-11-15  3:55 ` Arnav Kapoor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261115020129.10259-1-niloymeharchandani@gmail.com \
    --to=niloymeharchandani@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®