Commit c732eaf0 authored by Dan Murphy's avatar Dan Murphy Committed by Pavel Machek

leds: lp55xx: Convert LED class registration to devm_*

Convert the LED class registration calls to the LED devm_*
registration calls.
Acked-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarDan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent a89d385d
...@@ -541,19 +541,17 @@ static int lp5521_probe(struct i2c_client *client, ...@@ -541,19 +541,17 @@ static int lp5521_probe(struct i2c_client *client,
ret = lp55xx_register_leds(led, chip); ret = lp55xx_register_leds(led, chip);
if (ret) if (ret)
goto err_register_leds; goto err_out;
ret = lp55xx_register_sysfs(chip); ret = lp55xx_register_sysfs(chip);
if (ret) { if (ret) {
dev_err(&client->dev, "registering sysfs failed\n"); dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs; goto err_out;
} }
return 0; return 0;
err_register_sysfs: err_out:
lp55xx_unregister_leds(led, chip);
err_register_leds:
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
...@@ -566,7 +564,6 @@ static int lp5521_remove(struct i2c_client *client) ...@@ -566,7 +564,6 @@ static int lp5521_remove(struct i2c_client *client)
lp5521_stop_all_engines(chip); lp5521_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip); lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
return 0; return 0;
......
...@@ -909,19 +909,17 @@ static int lp5523_probe(struct i2c_client *client, ...@@ -909,19 +909,17 @@ static int lp5523_probe(struct i2c_client *client,
ret = lp55xx_register_leds(led, chip); ret = lp55xx_register_leds(led, chip);
if (ret) if (ret)
goto err_register_leds; goto err_out;
ret = lp55xx_register_sysfs(chip); ret = lp55xx_register_sysfs(chip);
if (ret) { if (ret) {
dev_err(&client->dev, "registering sysfs failed\n"); dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs; goto err_out;
} }
return 0; return 0;
err_register_sysfs: err_out:
lp55xx_unregister_leds(led, chip);
err_register_leds:
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
...@@ -934,7 +932,6 @@ static int lp5523_remove(struct i2c_client *client) ...@@ -934,7 +932,6 @@ static int lp5523_remove(struct i2c_client *client)
lp5523_stop_all_engines(chip); lp5523_stop_all_engines(chip);
lp55xx_unregister_sysfs(chip); lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
return 0; return 0;
......
...@@ -554,19 +554,17 @@ static int lp5562_probe(struct i2c_client *client, ...@@ -554,19 +554,17 @@ static int lp5562_probe(struct i2c_client *client,
ret = lp55xx_register_leds(led, chip); ret = lp55xx_register_leds(led, chip);
if (ret) if (ret)
goto err_register_leds; goto err_out;
ret = lp55xx_register_sysfs(chip); ret = lp55xx_register_sysfs(chip);
if (ret) { if (ret) {
dev_err(&client->dev, "registering sysfs failed\n"); dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs; goto err_out;
} }
return 0; return 0;
err_register_sysfs: err_out:
lp55xx_unregister_leds(led, chip);
err_register_leds:
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
...@@ -580,7 +578,6 @@ static int lp5562_remove(struct i2c_client *client) ...@@ -580,7 +578,6 @@ static int lp5562_remove(struct i2c_client *client)
lp5562_stop_engine(chip); lp5562_stop_engine(chip);
lp55xx_unregister_sysfs(chip); lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
return 0; return 0;
......
...@@ -179,7 +179,7 @@ static int lp55xx_init_led(struct lp55xx_led *led, ...@@ -179,7 +179,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
led->cdev.name = name; led->cdev.name = name;
} }
ret = led_classdev_register(dev, &led->cdev); ret = devm_led_classdev_register(dev, &led->cdev);
if (ret) { if (ret) {
dev_err(dev, "led register err: %d\n", ret); dev_err(dev, "led register err: %d\n", ret);
return ret; return ret;
...@@ -480,23 +480,10 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip) ...@@ -480,23 +480,10 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
return 0; return 0;
err_init_led: err_init_led:
lp55xx_unregister_leds(led, chip);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(lp55xx_register_leds); 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) int lp55xx_register_sysfs(struct lp55xx_chip *chip)
{ {
struct device *dev = &chip->cl->dev; struct device *dev = &chip->cl->dev;
......
...@@ -189,8 +189,6 @@ extern void lp55xx_deinit_device(struct lp55xx_chip *chip); ...@@ -189,8 +189,6 @@ extern void lp55xx_deinit_device(struct lp55xx_chip *chip);
/* common LED class device functions */ /* common LED class device functions */
extern int lp55xx_register_leds(struct lp55xx_led *led, extern int lp55xx_register_leds(struct lp55xx_led *led,
struct lp55xx_chip *chip); struct lp55xx_chip *chip);
extern void lp55xx_unregister_leds(struct lp55xx_led *led,
struct lp55xx_chip *chip);
/* common device attributes functions */ /* common device attributes functions */
extern int lp55xx_register_sysfs(struct lp55xx_chip *chip); extern int lp55xx_register_sysfs(struct lp55xx_chip *chip);
......
...@@ -344,19 +344,17 @@ static int lp8501_probe(struct i2c_client *client, ...@@ -344,19 +344,17 @@ static int lp8501_probe(struct i2c_client *client,
ret = lp55xx_register_leds(led, chip); ret = lp55xx_register_leds(led, chip);
if (ret) if (ret)
goto err_register_leds; goto err_out;
ret = lp55xx_register_sysfs(chip); ret = lp55xx_register_sysfs(chip);
if (ret) { if (ret) {
dev_err(&client->dev, "registering sysfs failed\n"); dev_err(&client->dev, "registering sysfs failed\n");
goto err_register_sysfs; goto err_out;
} }
return 0; return 0;
err_register_sysfs: err_out:
lp55xx_unregister_leds(led, chip);
err_register_leds:
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
err_init: err_init:
return ret; return ret;
...@@ -369,7 +367,6 @@ static int lp8501_remove(struct i2c_client *client) ...@@ -369,7 +367,6 @@ static int lp8501_remove(struct i2c_client *client)
lp8501_stop_engine(chip); lp8501_stop_engine(chip);
lp55xx_unregister_sysfs(chip); lp55xx_unregister_sysfs(chip);
lp55xx_unregister_leds(led, chip);
lp55xx_deinit_device(chip); lp55xx_deinit_device(chip);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment