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

gpio: pca9570: use lock guards

Shrink the code by a couple lines and improve lock management by using
lock guards from cleanup.h.

Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20260113111156.188051-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
4aa57300 053578d3

+4 -5
+4 -5
drivers/gpio/gpio-pca9570.c
··· 10 10 */ 11 11 12 12 #include <linux/bits.h> 13 + #include <linux/cleanup.h> 13 14 #include <linux/device/devres.h> 14 15 #include <linux/errno.h> 15 16 #include <linux/gpio/driver.h> ··· 99 98 u8 buffer; 100 99 int ret; 101 100 102 - mutex_lock(&gpio->lock); 101 + guard(mutex)(&gpio->lock); 103 102 104 103 buffer = gpio->out; 105 104 if (value) ··· 109 108 110 109 ret = pca9570_write(gpio, buffer); 111 110 if (ret) 112 - goto out; 111 + return ret; 113 112 114 113 gpio->out = buffer; 115 114 116 - out: 117 - mutex_unlock(&gpio->lock); 118 - return ret; 115 + return 0; 119 116 } 120 117 121 118 static int pca9570_probe(struct i2c_client *client)