diff options
author | Amitoj Kaur Chawla <amitoj1606@gmail.com> | 2016-03-08 22:23:47 -0500 |
---|---|---|
committer | Jacek Anaszewski <j.anaszewski@samsung.com> | 2016-03-14 04:22:22 -0400 |
commit | 8d3b6a4001ceaeef1aaac39e6cb5380780b4ef9c (patch) | |
tree | 37c33eee222708f659e407006c343ef9da76440b | |
parent | f165a66e16f0aa8270ec4a26fdb07606eb7d6ae3 (diff) |
leds: wm831x-status: 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 from probe function and the remove
function, wm831x_status_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: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
-rw-r--r-- | drivers/leds/leds-wm831x-status.c | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c index 64a22263e7fc..be93b20e792a 100644 --- a/drivers/leds/leds-wm831x-status.c +++ b/drivers/leds/leds-wm831x-status.c | |||
@@ -239,7 +239,6 @@ static int wm831x_status_probe(struct platform_device *pdev) | |||
239 | GFP_KERNEL); | 239 | GFP_KERNEL); |
240 | if (!drvdata) | 240 | if (!drvdata) |
241 | return -ENOMEM; | 241 | return -ENOMEM; |
242 | platform_set_drvdata(pdev, drvdata); | ||
243 | 242 | ||
244 | drvdata->wm831x = wm831x; | 243 | drvdata->wm831x = wm831x; |
245 | drvdata->reg = res->start; | 244 | drvdata->reg = res->start; |
@@ -284,7 +283,7 @@ static int wm831x_status_probe(struct platform_device *pdev) | |||
284 | drvdata->cdev.blink_set = wm831x_status_blink_set; | 283 | drvdata->cdev.blink_set = wm831x_status_blink_set; |
285 | drvdata->cdev.groups = wm831x_status_groups; | 284 | drvdata->cdev.groups = wm831x_status_groups; |
286 | 285 | ||
287 | ret = led_classdev_register(wm831x->dev, &drvdata->cdev); | 286 | ret = devm_led_classdev_register(wm831x->dev, &drvdata->cdev); |
288 | if (ret < 0) { | 287 | if (ret < 0) { |
289 | dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); | 288 | dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); |
290 | return ret; | 289 | return ret; |
@@ -293,21 +292,11 @@ static int wm831x_status_probe(struct platform_device *pdev) | |||
293 | return 0; | 292 | return 0; |
294 | } | 293 | } |
295 | 294 | ||
296 | static int wm831x_status_remove(struct platform_device *pdev) | ||
297 | { | ||
298 | struct wm831x_status *drvdata = platform_get_drvdata(pdev); | ||
299 | |||
300 | led_classdev_unregister(&drvdata->cdev); | ||
301 | |||
302 | return 0; | ||
303 | } | ||
304 | |||
305 | static struct platform_driver wm831x_status_driver = { | 295 | static struct platform_driver wm831x_status_driver = { |
306 | .driver = { | 296 | .driver = { |
307 | .name = "wm831x-status", | 297 | .name = "wm831x-status", |
308 | }, | 298 | }, |
309 | .probe = wm831x_status_probe, | 299 | .probe = wm831x_status_probe, |
310 | .remove = wm831x_status_remove, | ||
311 | }; | 300 | }; |
312 | 301 | ||
313 | module_platform_driver(wm831x_status_driver); | 302 | module_platform_driver(wm831x_status_driver); |