Re: [PATCH v5 4/5] iio: ssp_sensors: use devm APIs for mutex and IRQ resources
From: Andy Shevchenko
Date: Tue Apr 07 2026 - 08:45:14 EST
On Mon, Apr 06, 2026 at 01:38:51PM +0530, Sanjay Chitroda wrote:
> Convert mutex initialization and IRQ registration to use devm-managed
> helpers, tying their lifetime to the device.
>
> This removes the need for explicit cleanup in the error and remove
> paths, as the resources are automatically released on probe failure
> or device unbind.
...
> - mutex_init(&data->comm_lock);
> + ret = devm_mutex_init(&spi->dev, &data->comm_lock);
> + if (ret < 0) {
> + dev_err(&spi->dev, "Failed to init comm_lock mutex\n");
The message is not needed here.
> + goto err_setup_spi;
This is half-baked solution. When devm is in use there is shouldn't be goto.
after it.
> + }
...
> - ret = request_threaded_irq(data->spi->irq, NULL,
> - ssp_irq_thread_fn,
> - IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> - "SSP_Int", data);
> + ret = devm_request_threaded_irq(&spi->dev, data->spi->irq, NULL,
> + ssp_irq_thread_fn,
> + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + "SSP_Int", data);
> if (ret < 0) {
> dev_err(&spi->dev, "Irq request fail\n");
Now you should also remove this dup message. devm APIs in IRQ core print
a message for you.
> - goto err_setup_irq;
> + goto err_setup_spi;
> }
--
With Best Regards,
Andy Shevchenko