Skip to content

Commit 4aa5730

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
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>
1 parent 053578d commit 4aa5730

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/gpio/gpio-pca9570.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <linux/bits.h>
13+
#include <linux/cleanup.h>
1314
#include <linux/device/devres.h>
1415
#include <linux/errno.h>
1516
#include <linux/gpio/driver.h>
@@ -98,7 +99,7 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
9899
u8 buffer;
99100
int ret;
100101

101-
mutex_lock(&gpio->lock);
102+
guard(mutex)(&gpio->lock);
102103

103104
buffer = gpio->out;
104105
if (value)
@@ -108,13 +109,11 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
108109

109110
ret = pca9570_write(gpio, buffer);
110111
if (ret)
111-
goto out;
112+
return ret;
112113

113114
gpio->out = buffer;
114115

115-
out:
116-
mutex_unlock(&gpio->lock);
117-
return ret;
116+
return 0;
118117
}
119118

120119
static int pca9570_probe(struct i2c_client *client)

0 commit comments

Comments
 (0)