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

leds: da903x: 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.

Also, remove platform_set_drvdata in probe function and the remove
function, da903x_led_remove as it is now has nothing to do.

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 48a7032b
...@@ -113,21 +113,12 @@ static int da903x_led_probe(struct platform_device *pdev) ...@@ -113,21 +113,12 @@ static int da903x_led_probe(struct platform_device *pdev)
led->flags = pdata->flags; led->flags = pdata->flags;
led->master = pdev->dev.parent; led->master = pdev->dev.parent;
ret = led_classdev_register(led->master, &led->cdev); ret = devm_led_classdev_register(led->master, &led->cdev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", id); dev_err(&pdev->dev, "failed to register LED %d\n", id);
return ret; return ret;
} }
platform_set_drvdata(pdev, led);
return 0;
}
static int da903x_led_remove(struct platform_device *pdev)
{
struct da903x_led *led = platform_get_drvdata(pdev);
led_classdev_unregister(&led->cdev);
return 0; return 0;
} }
...@@ -136,7 +127,6 @@ static struct platform_driver da903x_led_driver = { ...@@ -136,7 +127,6 @@ static struct platform_driver da903x_led_driver = {
.name = "da903x-led", .name = "da903x-led",
}, },
.probe = da903x_led_probe, .probe = da903x_led_probe,
.remove = da903x_led_remove,
}; };
module_platform_driver(da903x_led_driver); module_platform_driver(da903x_led_driver);
......
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