Re: [PATCH v3 1/3] iio: ssp_sensors: ssp_spi: use guard() to release mutexes

From: Sanjay Chitroda

Date: Wed Mar 25 2026 - 23:17:48 EST




On 16 March 2026 8:02:09 pm IST, Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
>On Sun, Mar 15, 2026 at 06:25:07PM +0530, Sanjay Chitroda wrote:
>
>> Replace explicit mutex_lock() and mutex_unlock() with the guard() macro
>> for cleaner and safer mutex handling.
>
>TBH I don't see much benefit in this form. What I am thinking of is to refactor
>to have the guard and timeout_cnt++ in the top level, and
>
>static void ...(flag)
>{
> if (flag)
> return;
>
> guard(mutex)(&data->pending_lock);
> list_add_tail(&msg->list, &data->pending_list);
>}
>
>helper for three (*yes, 3) repetitive code snippets.
>

Thank you Andy for the review.

I understand your point about refactoring if pattern is repeated to simply things.

Also, while revisiting the changes, I noticed that unintended mistake where list_del() was replaced with list_add_tail() in couple of place during guard() conversion. I'll fix that in v4 along with suggestions and input from you and Jonathan.

I’ll send an updated version shortly.