leds: 88pm860x: Use devm_led_classdev_register
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Wed, 9 Mar 2016 03:23:29 +0000 (08:53 +0530)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Mon, 14 Mar 2016 08:22:22 +0000 (09:22 +0100)
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, pm860x_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: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-88pm860x.c

index 1ad4d03..77a104d 100644 (file)
@@ -195,7 +195,6 @@ static int pm860x_led_probe(struct platform_device *pdev)
                sprintf(data->name, "led1-blue");
                break;
        }
-       platform_set_drvdata(pdev, data);
        data->chip = chip;
        data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion;
        data->port = pdev->id;
@@ -208,7 +207,7 @@ static int pm860x_led_probe(struct platform_device *pdev)
        data->cdev.brightness_set_blocking = pm860x_led_set;
        mutex_init(&data->lock);
 
-       ret = led_classdev_register(chip->dev, &data->cdev);
+       ret = devm_led_classdev_register(chip->dev, &data->cdev);
        if (ret < 0) {
                dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
                return ret;
@@ -217,21 +216,12 @@ static int pm860x_led_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int pm860x_led_remove(struct platform_device *pdev)
-{
-       struct pm860x_led *data = platform_get_drvdata(pdev);
-
-       led_classdev_unregister(&data->cdev);
-
-       return 0;
-}
 
 static struct platform_driver pm860x_led_driver = {
        .driver = {
                .name   = "88pm860x-led",
        },
        .probe  = pm860x_led_probe,
-       .remove = pm860x_led_remove,
 };
 
 module_platform_driver(pm860x_led_driver);