diff options
author | Amitoj Kaur Chawla <amitoj1606@gmail.com> | 2016-03-08 22:23:29 -0500 |
---|---|---|
committer | Jacek Anaszewski <j.anaszewski@samsung.com> | 2016-03-14 04:22:22 -0400 |
commit | 375446df95eee10c21ecc7fcb2295bd1ae1db8f7 (patch) | |
tree | 1097757fb07d610abc9d85a29a9ef9a3f665872c | |
parent | e0442d7def8f9dccde0d825a01d8a6951aa6e95d (diff) |
leds: 88pm860x: 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, 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>
-rw-r--r-- | drivers/leds/leds-88pm860x.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 1ad4d03a0a3c..77a104d2b124 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c | |||
@@ -195,7 +195,6 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
195 | sprintf(data->name, "led1-blue"); | 195 | sprintf(data->name, "led1-blue"); |
196 | break; | 196 | break; |
197 | } | 197 | } |
198 | platform_set_drvdata(pdev, data); | ||
199 | data->chip = chip; | 198 | data->chip = chip; |
200 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; | 199 | data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; |
201 | data->port = pdev->id; | 200 | data->port = pdev->id; |
@@ -208,7 +207,7 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
208 | data->cdev.brightness_set_blocking = pm860x_led_set; | 207 | data->cdev.brightness_set_blocking = pm860x_led_set; |
209 | mutex_init(&data->lock); | 208 | mutex_init(&data->lock); |
210 | 209 | ||
211 | ret = led_classdev_register(chip->dev, &data->cdev); | 210 | ret = devm_led_classdev_register(chip->dev, &data->cdev); |
212 | if (ret < 0) { | 211 | if (ret < 0) { |
213 | dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); | 212 | dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); |
214 | return ret; | 213 | return ret; |
@@ -217,21 +216,12 @@ static int pm860x_led_probe(struct platform_device *pdev) | |||
217 | return 0; | 216 | return 0; |
218 | } | 217 | } |
219 | 218 | ||
220 | static int pm860x_led_remove(struct platform_device *pdev) | ||
221 | { | ||
222 | struct pm860x_led *data = platform_get_drvdata(pdev); | ||
223 | |||
224 | led_classdev_unregister(&data->cdev); | ||
225 | |||
226 | return 0; | ||
227 | } | ||
228 | 219 | ||
229 | static struct platform_driver pm860x_led_driver = { | 220 | static struct platform_driver pm860x_led_driver = { |
230 | .driver = { | 221 | .driver = { |
231 | .name = "88pm860x-led", | 222 | .name = "88pm860x-led", |
232 | }, | 223 | }, |
233 | .probe = pm860x_led_probe, | 224 | .probe = pm860x_led_probe, |
234 | .remove = pm860x_led_remove, | ||
235 | }; | 225 | }; |
236 | 226 | ||
237 | module_platform_driver(pm860x_led_driver); | 227 | module_platform_driver(pm860x_led_driver); |