* Re: [PATCH] staging: iio: frequency: ad9832: use devm_mutex_init()
[not found] <CAFonu5gDrT6znf3VUDjyg9=mTtB2nqXj9MFVO6cUZF3X4F-UeA@mail.gmail.com>
@ 2026-10-31 8:51 ` Andy Shevchenko
0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2026-10-31 8:51 UTC (permalink / raw)
To: Nithishvelan M
Cc: Jonathan Cameron, Greg Kroah-Hartman, Nuno Sa, Michael Hennerich,
David Lechner, Andy Shevchenko, linux-iio, linux-staging,
linux-kernel, linux
On Sat, Oct 31, 2026 at 01:02:58PM +0530, Nithishvelan M wrote:
> Replace mutex_init() with devm_mutex_init() in ad9832_probe() and
> check its return value. The driver already uses devm_* helpers for
> its other resources and has no remove() callback, so this ensures
> the mutex is destroyed automatically on teardown when mutex
> debugging is enabled.
>
> No functional change intended. Compile-tested only.
>
> Signed-off-by: Nithishvelan M <mnithishvelan@gmail.com>
> From d6899b1d88d9c9b224dd78b94b67caaad05098bf Mon Sep 17 00:00:00 2001
> From: Nithishvelan M <mnithishvelan@gmail.com>
> Date: Sat, 31 Oct 2026 12:03:37 +0530
> Subject: [PATCH] staging: iio: frequency: ad9832: use devm_mutex_init()
No, we don't accept attachments. But `b4` might, I dunno.
> Replace mutex_init() with devm_mutex_init() in ad9832_probe() and
> check its return value. The driver already uses devm_* helpers for
> its other resources and has no remove() callback, so this ensures
> the mutex is destroyed automatically on teardown when mutex
> debugging is enabled.
>
> No functional change intended. Compile-tested only.
>
> Signed-off-by: Nithishvelan M <mnithishvelan@gmail.com>
> ---
> drivers/staging/iio/frequency/ad9832.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index 35f823f24f..a90ee89803 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -325,7 +325,9 @@ static int ad9832_probe(struct spi_device *spi)
> return PTR_ERR(st->mclk);
>
> st->spi = spi;
> - mutex_init(&st->lock);
+ Blank line.
> + ret = devm_mutex_init(&spi->dev, &st->lock);
> + if (ret)
> + return ret;
>
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->info = &ad9832_info;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] only message in thread