Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: accel: adxl372: convert to guard(mutex)

Replace manual mutex_lock/mutex_unlock pair with guard(mutex) in
adxl372_write_threshold_value(). This ensures the mutex is released
on all return paths and allows returning directly without a goto label.

Signed-off-by: Rajveer Chaudhari <rajveer.chaudhari.linux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Rajveer Chaudhari and committed by
Jonathan Cameron
594ca8ce c4e73728

+6 -9
+6 -9
drivers/iio/accel/adxl372.c
··· 7 7 8 8 #include <linux/bitfield.h> 9 9 #include <linux/bitops.h> 10 + #include <linux/cleanup.h> 10 11 #include <linux/interrupt.h> 11 12 #include <linux/irq.h> 12 13 #include <linux/module.h> ··· 337 336 struct adxl372_state *st = iio_priv(indio_dev); 338 337 int ret; 339 338 340 - mutex_lock(&st->threshold_m); 339 + guard(mutex)(&st->threshold_m); 340 + 341 341 ret = regmap_write(st->regmap, addr, ADXL372_THRESH_VAL_H_SEL(threshold)); 342 342 if (ret < 0) 343 - goto unlock; 343 + return ret; 344 344 345 - ret = regmap_update_bits(st->regmap, addr + 1, GENMASK(7, 5), 346 - ADXL372_THRESH_VAL_L_SEL(threshold) << 5); 347 - 348 - unlock: 349 - mutex_unlock(&st->threshold_m); 350 - 351 - return ret; 345 + return regmap_update_bits(st->regmap, addr + 1, GENMASK(7, 5), 346 + ADXL372_THRESH_VAL_L_SEL(threshold) << 5); 352 347 } 353 348 354 349 static int adxl372_read_axis(struct adxl372_state *st, u8 addr)