]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: sca3000: use guard(mutex) to simplify return paths
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Thu, 5 Feb 2026 13:12:11 +0000 (05:12 -0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 3 Mar 2026 21:20:01 +0000 (21:20 +0000)
Switch sca3000_stop_all_interrupts() to use guard(mutex) to simplify the
error paths without needing a goto.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/sca3000.c

index b08136ef6dcda9273ad612445d1cc36e10661f94..ad8925b227be2683912e137769e5b25d3ba68151 100644 (file)
@@ -7,6 +7,7 @@
  * See industrialio/accels/sca3000.h for comments.
  */
 
+#include <linux/cleanup.h>
 #include <linux/interrupt.h>
 #include <linux/fs.h>
 #include <linux/device.h>
@@ -1431,17 +1432,17 @@ static void sca3000_stop_all_interrupts(struct sca3000_state *st)
 {
        int ret;
 
-       mutex_lock(&st->lock);
+       guard(mutex)(&st->lock);
+
        ret = sca3000_read_data_short(st, SCA3000_REG_INT_MASK_ADDR, 1);
        if (ret)
-               goto error_ret;
+               return;
+
        sca3000_write_reg(st, SCA3000_REG_INT_MASK_ADDR,
                          (st->rx[0] &
                           ~(SCA3000_REG_INT_MASK_RING_THREE_QUARTER |
                             SCA3000_REG_INT_MASK_RING_HALF |
                             SCA3000_REG_INT_MASK_ALL_INTS)));
-error_ret:
-       mutex_unlock(&st->lock);
 }
 
 static int sca3000_probe(struct spi_device *spi)