mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: iio: frequency: ad9834: use devm_mutex_init()
@ 2026-11-14  6:20 Niloy Meharchandani
  2026-11-14  7:27 ` Arnav Kapoor
  0 siblings, 1 reply; 2+ messages in thread
From: Niloy Meharchandani @ 2026-11-14  6:20 UTC (permalink / raw)
  To: Jonathan Cameron, Greg Kroah-Hartman
  Cc: Nuno Sá,
	Michael Hennerich, David Lechner, Andy Shevchenko, linux,
	linux-iio, linux-staging, linux-kernel, Niloy Meharchandani

Initialize st->lock via devm_mutex_init() instead of mutex_init() in
ad9834_probe() and propagate any initialization error. Since ad9834
already manages its 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/staging/iio/frequency/ad9834.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 3d97502d5909..9cb1fcbcb1ba 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -412,7 +412,11 @@ static int ad9834_probe(struct spi_device *spi)
 	if (!indio_dev)
 		return -ENOMEM;
 	st = iio_priv(indio_dev);
-	mutex_init(&st->lock);
+
+	ret = devm_mutex_init(&spi->dev, &st->lock);
+	if (ret)
+		return ret;
+
 	st->mclk = devm_clk_get_enabled(&spi->dev, NULL);
 	if (IS_ERR(st->mclk))
 		return dev_err_probe(&spi->dev, PTR_ERR(st->mclk),
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-14  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14  6:20 [PATCH] staging: iio: frequency: ad9834: use devm_mutex_init() Niloy Meharchandani
2026-11-14  7:27 ` 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®