Skip to content

Commit 4a8d2be

Browse files
agxpavelmachek
authored andcommitted
leds: lm3692x: Split out lm3692x_leds_disable
Move the relevant parts out of lm3692x_remove() and call it from there. No functional change. Signed-off-by: Guido Günther <[email protected]> Acked-by: Pavel Machek <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 5e9d7b6 commit 4a8d2be

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

drivers/leds/leds-lm3692x.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,30 @@ static int lm3692x_leds_enable(struct lm3692x_led *led)
289289
return ret;
290290
}
291291

292+
static int lm3692x_leds_disable(struct lm3692x_led *led)
293+
{
294+
int ret;
295+
296+
ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
297+
if (ret) {
298+
dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
299+
ret);
300+
return ret;
301+
}
302+
303+
if (led->enable_gpio)
304+
gpiod_direction_output(led->enable_gpio, 0);
305+
306+
if (led->regulator) {
307+
ret = regulator_disable(led->regulator);
308+
if (ret)
309+
dev_err(&led->client->dev,
310+
"Failed to disable regulator: %d\n", ret);
311+
}
312+
313+
return ret;
314+
}
315+
292316
static int lm3692x_brightness_set(struct led_classdev *led_cdev,
293317
enum led_brightness brt_val)
294318
{
@@ -463,23 +487,9 @@ static int lm3692x_remove(struct i2c_client *client)
463487
struct lm3692x_led *led = i2c_get_clientdata(client);
464488
int ret;
465489

466-
ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0);
467-
if (ret) {
468-
dev_err(&led->client->dev, "Failed to disable regulator: %d\n",
469-
ret);
490+
ret = lm3692x_leds_disable(led);
491+
if (ret)
470492
return ret;
471-
}
472-
473-
if (led->enable_gpio)
474-
gpiod_direction_output(led->enable_gpio, 0);
475-
476-
if (led->regulator) {
477-
ret = regulator_disable(led->regulator);
478-
if (ret)
479-
dev_err(&led->client->dev,
480-
"Failed to disable regulator: %d\n", ret);
481-
}
482-
483493
mutex_destroy(&led->lock);
484494

485495
return 0;

0 commit comments

Comments
 (0)