summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 12:56:23 +0400
committerBryan Wu <cooloney@gmail.com>2013-02-07 03:59:26 +0400
commit1904f83d568dba794be9de1311bafb5a4424812a (patch)
tree31517e43b89b28e0deed39780fa8994d15be752a /drivers/leds/leds-lp5521.c
parentf652480802b636f86e194f9680347676b655d856 (diff)
downloadlinux-1904f83d568dba794be9de1311bafb5a4424812a.tar.xz
leds-lp55xx: clean up deinit leds in lp5521/5523
To make LED unregistration code simple, new function, _unregister_leds() is added in each driver. This patch is a preceding step for lp55xx common driver architecture. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index f4cd0fe67fef..ec1ffe6316c1 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -837,12 +837,22 @@ static int lp5521_register_leds(struct lp5521_chip *chip)
return 0;
}
+static void lp5521_unregister_leds(struct lp5521_chip *chip)
+{
+ int i;
+
+ for (i = 0; i < chip->num_leds; i++) {
+ led_classdev_unregister(&chip->leds[i].cdev);
+ cancel_work_sync(&chip->leds[i].brightness_work);
+ }
+}
+
static int lp5521_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct lp5521_chip *chip;
struct lp5521_platform_data *pdata;
- int ret, i;
+ int ret;
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
@@ -885,10 +895,7 @@ static int lp5521_probe(struct i2c_client *client,
}
return ret;
fail2:
- for (i = 0; i < chip->num_leds; i++) {
- led_classdev_unregister(&chip->leds[i].cdev);
- cancel_work_sync(&chip->leds[i].brightness_work);
- }
+ lp5521_unregister_leds(chip);
fail1:
lp5521_deinit_device(chip);
return ret;
@@ -897,15 +904,11 @@ fail1:
static int lp5521_remove(struct i2c_client *client)
{
struct lp5521_chip *chip = i2c_get_clientdata(client);
- int i;
lp5521_run_led_pattern(PATTERN_OFF, chip);
lp5521_unregister_sysfs(client);
- for (i = 0; i < chip->num_leds; i++) {
- led_classdev_unregister(&chip->leds[i].cdev);
- cancel_work_sync(&chip->leds[i].brightness_work);
- }
+ lp5521_unregister_leds(chip);
lp5521_deinit_device(chip);
return 0;