Skip to content

Commit 8d3b6a4

Browse files
musicakcjanaszewski
authored andcommitted
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>
1 parent f165a66 commit 8d3b6a4

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

drivers/leds/leds-wm831x-status.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ static int wm831x_status_probe(struct platform_device *pdev)
239239
GFP_KERNEL);
240240
if (!drvdata)
241241
return -ENOMEM;
242-
platform_set_drvdata(pdev, drvdata);
243242

244243
drvdata->wm831x = wm831x;
245244
drvdata->reg = res->start;
@@ -284,7 +283,7 @@ static int wm831x_status_probe(struct platform_device *pdev)
284283
drvdata->cdev.blink_set = wm831x_status_blink_set;
285284
drvdata->cdev.groups = wm831x_status_groups;
286285

287-
ret = led_classdev_register(wm831x->dev, &drvdata->cdev);
286+
ret = devm_led_classdev_register(wm831x->dev, &drvdata->cdev);
288287
if (ret < 0) {
289288
dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
290289
return ret;
@@ -293,21 +292,11 @@ static int wm831x_status_probe(struct platform_device *pdev)
293292
return 0;
294293
}
295294

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-
305295
static struct platform_driver wm831x_status_driver = {
306296
.driver = {
307297
.name = "wm831x-status",
308298
},
309299
.probe = wm831x_status_probe,
310-
.remove = wm831x_status_remove,
311300
};
312301

313302
module_platform_driver(wm831x_status_driver);

0 commit comments

Comments
 (0)