Re: [PATCH] iio: imu: kmx61: Use guard(mutex)() family over manual locking
From: Jonathan Cameron
Date: Mon May 04 2026 - 12:47:28 EST
> ...
>
> > - mutex_lock(&data->lock);
> > + guard(mutex)(&data->lock);
> > iio_for_each_active_channel(indio_dev, bit) {
> > ret = kmx61_read_measurement(data, base, bit);
> > if (ret < 0) {
> > - mutex_unlock(&data->lock);
> > - goto err;
> > + iio_trigger_notify_done(indio_dev->trig);
> > + return IRQ_HANDLED;
>
> Hmm... Is the HANDLED a right choice?
Ah. Long running discussion point on what right thing to do if you
are sure it's your interrupt but your handling failed - in a fashion
that doesn't prevent the interrupt clearing. Not obvious :(
>
> > }
> > buffer[i++] = ret;
> > }
> > - mutex_unlock(&data->lock);
> >
> > iio_push_to_buffers(indio_dev, buffer);
> > -err:
> > iio_trigger_notify_done(indio_dev->trig);
> >
> > return IRQ_HANDLED;
>
> If the answer is yes, I'm wondering if we may deduplicate that...
Would require a helper function to avoid gotos + guard() in the same
function or some ugly code flow. Might not be worth it.
Jonathan
p.s. I deleted some more stuff from Andy so look at his reply.