Commit 50154e29 authored by Amitoj Kaur Chawla's avatar Amitoj Kaur Chawla Committed by Jacek Anaszewski

leds: lm3533: Use devm_led_classdev_register

Switch to resource-managed function devm_led_classdev_register instead
of led_classdev_register and remove unneeded led_classdev_unregister.

To be compatible with this change, remove an unnecessary label by
replacing it with direct return statement.

The Coccinelle semantic patch used to make this change is as follows:
//<smpl>
@platform@
identifier p, probefn, removefn;
@@
struct platform_driver p = {
  .probe = probefn,
  .remove = removefn,
};

@prb@
identifier platform.probefn, pdev;
expression e;
@@
probefn(struct platform_device *pdev, ...) {
  ...
  e =
- led_classdev_register
+ devm_led_classdev_register
  (...);
   ...
?- led_classdev_unregister(...);
  ...
}
@remove depends on prb@
identifier platform.removefn;
@@
removefn(...) {
...
?- led_classdev_unregister(...);
...
}
//</smpl>
Signed-off-by: default avatarAmitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
parent eae7c98a
...@@ -698,7 +698,7 @@ static int lm3533_led_probe(struct platform_device *pdev) ...@@ -698,7 +698,7 @@ static int lm3533_led_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, led); platform_set_drvdata(pdev, led);
ret = led_classdev_register(pdev->dev.parent, &led->cdev); ret = devm_led_classdev_register(pdev->dev.parent, &led->cdev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id); dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id);
return ret; return ret;
...@@ -708,18 +708,13 @@ static int lm3533_led_probe(struct platform_device *pdev) ...@@ -708,18 +708,13 @@ static int lm3533_led_probe(struct platform_device *pdev)
ret = lm3533_led_setup(led, pdata); ret = lm3533_led_setup(led, pdata);
if (ret) if (ret)
goto err_unregister; return ret;
ret = lm3533_ctrlbank_enable(&led->cb); ret = lm3533_ctrlbank_enable(&led->cb);
if (ret) if (ret)
goto err_unregister; return ret;
return 0; return 0;
err_unregister:
led_classdev_unregister(&led->cdev);
return ret;
} }
static int lm3533_led_remove(struct platform_device *pdev) static int lm3533_led_remove(struct platform_device *pdev)
...@@ -729,7 +724,6 @@ static int lm3533_led_remove(struct platform_device *pdev) ...@@ -729,7 +724,6 @@ static int lm3533_led_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s\n", __func__); dev_dbg(&pdev->dev, "%s\n", __func__);
lm3533_ctrlbank_disable(&led->cb); lm3533_ctrlbank_disable(&led->cb);
led_classdev_unregister(&led->cdev);
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