Skip to content

Commit

Permalink
leds: lp55xx: Convert LED class registration to devm_*
Browse files Browse the repository at this point in the history
Convert the LED class registration calls to the LED devm_*
registration calls.

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
  • Loading branch information
Dan Murphy authored and Pavel Machek committed Jul 22, 2020
1 parent a89d385 commit c732eaf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 40 deletions.
9 changes: 3 additions & 6 deletions drivers/leds/leds-lp5521.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,19 +541,17 @@ static int lp5521_probe(struct i2c_client *client,

ret = lp55xx_register_leds(led, chip);
if (ret)
goto err_register_leds;
goto err_out;

ret = lp55xx_register_sysfs(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs;
goto err_out;
}

return 0;

err_register_sysfs:
lp55xx_unregister_leds(led, chip);
err_register_leds:
err_out:
lp55xx_deinit_device(chip);
err_init:
return ret;
Expand All @@ -566,7 +564,6 @@ static int lp5521_remove(struct i2c_client *client)

lp5521_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);

return 0;
Expand Down
9 changes: 3 additions & 6 deletions drivers/leds/leds-lp5523.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,19 +909,17 @@ static int lp5523_probe(struct i2c_client *client,

ret = lp55xx_register_leds(led, chip);
if (ret)
goto err_register_leds;
goto err_out;

ret = lp55xx_register_sysfs(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs;
goto err_out;
}

return 0;

err_register_sysfs:
lp55xx_unregister_leds(led, chip);
err_register_leds:
err_out:
lp55xx_deinit_device(chip);
err_init:
return ret;
Expand All @@ -934,7 +932,6 @@ static int lp5523_remove(struct i2c_client *client)

lp5523_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);

return 0;
Expand Down
9 changes: 3 additions & 6 deletions drivers/leds/leds-lp5562.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,19 +554,17 @@ static int lp5562_probe(struct i2c_client *client,

ret = lp55xx_register_leds(led, chip);
if (ret)
goto err_register_leds;
goto err_out;

ret = lp55xx_register_sysfs(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs;
goto err_out;
}

return 0;

err_register_sysfs:
lp55xx_unregister_leds(led, chip);
err_register_leds:
err_out:
lp55xx_deinit_device(chip);
err_init:
return ret;
Expand All @@ -580,7 +578,6 @@ static int lp5562_remove(struct i2c_client *client)
lp5562_stop_engine(chip);

lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);

return 0;
Expand Down
15 changes: 1 addition & 14 deletions drivers/leds/leds-lp55xx-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
led->cdev.name = name;
}

ret = led_classdev_register(dev, &led->cdev);
ret = devm_led_classdev_register(dev, &led->cdev);
if (ret) {
dev_err(dev, "led register err: %d\n", ret);
return ret;
Expand Down Expand Up @@ -480,23 +480,10 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
return 0;

err_init_led:
lp55xx_unregister_leds(led, chip);
return ret;
}
EXPORT_SYMBOL_GPL(lp55xx_register_leds);

void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
{
int i;
struct lp55xx_led *each;

for (i = 0; i < chip->num_leds; i++) {
each = led + i;
led_classdev_unregister(&each->cdev);
}
}
EXPORT_SYMBOL_GPL(lp55xx_unregister_leds);

int lp55xx_register_sysfs(struct lp55xx_chip *chip)
{
struct device *dev = &chip->cl->dev;
Expand Down
2 changes: 0 additions & 2 deletions drivers/leds/leds-lp55xx-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ extern void lp55xx_deinit_device(struct lp55xx_chip *chip);
/* common LED class device functions */
extern int lp55xx_register_leds(struct lp55xx_led *led,
struct lp55xx_chip *chip);
extern void lp55xx_unregister_leds(struct lp55xx_led *led,
struct lp55xx_chip *chip);

/* common device attributes functions */
extern int lp55xx_register_sysfs(struct lp55xx_chip *chip);
Expand Down
9 changes: 3 additions & 6 deletions drivers/leds/leds-lp8501.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,19 +344,17 @@ static int lp8501_probe(struct i2c_client *client,

ret = lp55xx_register_leds(led, chip);
if (ret)
goto err_register_leds;
goto err_out;

ret = lp55xx_register_sysfs(chip);
if (ret) {
dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs;
goto err_out;
}

return 0;

err_register_sysfs:
lp55xx_unregister_leds(led, chip);
err_register_leds:
err_out:
lp55xx_deinit_device(chip);
err_init:
return ret;
Expand All @@ -369,7 +367,6 @@ static int lp8501_remove(struct i2c_client *client)

lp8501_stop_engine(chip);
lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip);

return 0;
Expand Down

0 comments on commit c732eaf

Please sign in to comment.