Re: [PATCH v5 4/5] iio: ssp_sensors: use devm APIs for mutex and IRQ resources

From: Sanjay Chitroda

Date: Sat Apr 11 2026 - 07:41:42 EST




On 7 April 2026 6:12:57 pm IST, Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
>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.
>
>> + }
>
Hi Andy,

Thank you for your input.

I will replace pending goto and drop newly added redundant error message and send next series with change.

>...
>
>> - 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;
>> }
>