Re: [PATCH v4 5/5] iio: imu: inv_icm42600: use guard() to release mutexes
From: Jonathan Cameron
Date: Wed Sep 10 2025 - 14:36:52 EST
On Tue, 9 Sep 2025 16:15:04 +0300
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Tue, Sep 09, 2025 at 11:53:02AM +0000, Sean Nyekjaer wrote:
> > On Tue, Sep 09, 2025 at 02:39:12PM +0100, Andy Shevchenko wrote:
> > > On Tue, Sep 09, 2025 at 09:11:11AM +0200, Sean Nyekjaer wrote:
>
> ...
>
> > > > /* exit if FIFO is already on */
> > > > if (st->fifo.on) {
> > > > - ret = 0;
> > > > - goto out_on;
> > >
> > > Probably you wanted the same comment here
> > >
> > > /* increase FIFO on counter */
> > >
> > > > + st->fifo.on++;
> > > > + return 0;
> > > > }
>
> ...
>
> > > > /* exit if there are several sensors using the FIFO */
> > > > if (st->fifo.on > 1) {
> > > > - ret = 0;
> > > > - goto out_off;
> > >
> > > In the similar way
> > >
> >
> > Considered it. But isn't it obvious whats happening?
>
> With the same equality existing ones may be killed. Some of consistency at least :-)
>
> > I will be happy to add them...
>
> > > /* decrease FIFO on counter */
> > >
> > > > + st->fifo.on--;
> > > > + return 0;
> > > > }
>
Applied with this tweak. Thanks
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
index 15391961bf96..ada968be954d 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c
@@ -300,7 +300,6 @@ static int inv_icm42600_buffer_postenable(struct iio_dev *indio_dev)
guard(mutex)(&st->lock);
- /* exit if FIFO is already on */
if (st->fifo.on) {
st->fifo.on++;
return 0;
@@ -329,7 +328,6 @@ static int inv_icm42600_buffer_postenable(struct iio_dev *indio_dev)
if (ret)
return ret;
- /* increase FIFO on counter */
st->fifo.on++;
return 0;
@@ -342,7 +340,6 @@ static int inv_icm42600_buffer_predisable(struct iio_dev *indio_dev)
guard(mutex)(&st->lock);
- /* exit if there are several sensors using the FIFO */
if (st->fifo.on > 1) {
st->fifo.on--;
return 0;
@@ -366,7 +363,6 @@ static int inv_icm42600_buffer_predisable(struct iio_dev *indio_dev)
if (ret)
return ret;
- /* decrease FIFO on counter */
st->fifo.on--;
return 0;