Skip to content

Commit e05ef04

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
gpio: pca9570: Use devm_mutex_init() for mutex initialization
Use devm_mutex_init() since it brings some benefits when CONFIG_DEBUG_MUTEXES is enabled. 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-2-andriy.shevchenko@linux.intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 568ea51 commit e05ef04

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/gpio/gpio-pca9570.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ static int pca9570_set(struct gpio_chip *chip, unsigned int offset, int value)
115115

116116
static int pca9570_probe(struct i2c_client *client)
117117
{
118+
struct device *dev = &client->dev;
118119
struct pca9570 *gpio;
120+
int ret;
119121

120122
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
121123
if (!gpio)
@@ -132,7 +134,9 @@ static int pca9570_probe(struct i2c_client *client)
132134
gpio->chip.ngpio = gpio->chip_data->ngpio;
133135
gpio->chip.can_sleep = true;
134136

135-
mutex_init(&gpio->lock);
137+
ret = devm_mutex_init(dev, &gpio->lock);
138+
if (ret)
139+
return ret;
136140

137141
/* Read the current output level */
138142
pca9570_read(gpio, &gpio->out);

0 commit comments

Comments
 (0)