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

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 <agx@sigxcpu.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Pavel Machek <pavel@ucw.cz>

authored by

Guido Günther and committed by
Pavel
4a8d2bee 5e9d7b6f

+26 -16
+26 -16
drivers/leds/leds-lm3692x.c
··· 289 289 return ret; 290 290 } 291 291 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 + 292 316 static int lm3692x_brightness_set(struct led_classdev *led_cdev, 293 317 enum led_brightness brt_val) 294 318 { ··· 487 463 struct lm3692x_led *led = i2c_get_clientdata(client); 488 464 int ret; 489 465 490 - ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0); 491 - if (ret) { 492 - dev_err(&led->client->dev, "Failed to disable regulator: %d\n", 493 - ret); 466 + ret = lm3692x_leds_disable(led); 467 + if (ret) 494 468 return ret; 495 - } 496 - 497 - if (led->enable_gpio) 498 - gpiod_direction_output(led->enable_gpio, 0); 499 - 500 - if (led->regulator) { 501 - ret = regulator_disable(led->regulator); 502 - if (ret) 503 - dev_err(&led->client->dev, 504 - "Failed to disable regulator: %d\n", ret); 505 - } 506 - 507 469 mutex_destroy(&led->lock); 508 470 509 471 return 0;