2016-03-07 14:51:06

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 0/7] leds: 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.

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>

Amitoj Kaur Chawla (7):
leds: 88pm860x: Use devm_led_classdev_register
leds: lp8788: Use devm_led_classdev_register
leds: wm381x-status: Use devm_led_classdev_register
leds: s3c24xx: Use devm_led_classdev_register
leds: da903x: Use devm_led_classdev_register
leds: max8997: Use devm_led_classdev_register
leds: lm3533: Use devm_led_classdev_register

drivers/leds/leds-88pm860x.c | 11 +----------
drivers/leds/leds-da903x.c | 11 +----------
drivers/leds/leds-lm3533.c | 12 +++---------
drivers/leds/leds-lp8788.c | 12 +-----------
drivers/leds/leds-max8997.c | 12 +-----------
drivers/leds/leds-s3c24xx.c | 12 +-----------
drivers/leds/leds-wm831x-status.c | 12 +-----------
7 files changed, 9 insertions(+), 73 deletions(-)

--
1.9.1


2016-03-07 14:51:11

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 2/7] leds: lp8788: 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 lp8788_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 <[email protected]>
---
drivers/leds/leds-lp8788.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/leds/leds-lp8788.c b/drivers/leds/leds-lp8788.c
index 0eee38f..ffc3f89 100644
--- a/drivers/leds/leds-lp8788.c
+++ b/drivers/leds/leds-lp8788.c
@@ -154,7 +154,7 @@ static int lp8788_led_probe(struct platform_device *pdev)
return ret;
}

- ret = led_classdev_register(dev, &led->led_dev);
+ ret = devm_led_classdev_register(dev, &led->led_dev);
if (ret) {
dev_err(dev, "led register err: %d\n", ret);
return ret;
@@ -163,18 +163,8 @@ static int lp8788_led_probe(struct platform_device *pdev)
return 0;
}

-static int lp8788_led_remove(struct platform_device *pdev)
-{
- struct lp8788_led *led = platform_get_drvdata(pdev);
-
- led_classdev_unregister(&led->led_dev);
-
- return 0;
-}
-
static struct platform_driver lp8788_led_driver = {
.probe = lp8788_led_probe,
- .remove = lp8788_led_remove,
.driver = {
.name = LP8788_DEV_KEYLED,
},
--
1.9.1

2016-03-07 14:51:25

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 3/7] leds: wm381x-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 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 <[email protected]>
---
drivers/leds/leds-wm831x-status.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/leds/leds-wm831x-status.c b/drivers/leds/leds-wm831x-status.c
index 64a2226..5722b94a 100644
--- a/drivers/leds/leds-wm831x-status.c
+++ b/drivers/leds/leds-wm831x-status.c
@@ -284,7 +284,7 @@ static int wm831x_status_probe(struct platform_device *pdev)
drvdata->cdev.blink_set = wm831x_status_blink_set;
drvdata->cdev.groups = wm831x_status_groups;

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

-static int wm831x_status_remove(struct platform_device *pdev)
-{
- struct wm831x_status *drvdata = platform_get_drvdata(pdev);
-
- led_classdev_unregister(&drvdata->cdev);
-
- return 0;
-}
-
static struct platform_driver wm831x_status_driver = {
.driver = {
.name = "wm831x-status",
},
.probe = wm831x_status_probe,
- .remove = wm831x_status_remove,
};

module_platform_driver(wm831x_status_driver);
--
1.9.1

2016-03-07 14:51:36

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 4/7] leds: s3c24xx: 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 s3c24xx_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 <[email protected]>
---
drivers/leds/leds-s3c24xx.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index 83641a7..ae3fbed 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -59,15 +59,6 @@ static void s3c24xx_led_set(struct led_classdev *led_cdev,
}
}

-static int s3c24xx_led_remove(struct platform_device *dev)
-{
- struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
-
- led_classdev_unregister(&led->cdev);
-
- return 0;
-}
-
static int s3c24xx_led_probe(struct platform_device *dev)
{
struct s3c24xx_led_platdata *pdata = dev_get_platdata(&dev->dev);
@@ -104,7 +95,7 @@ static int s3c24xx_led_probe(struct platform_device *dev)

/* register our new led device */

- ret = led_classdev_register(&dev->dev, &led->cdev);
+ ret = devm_led_classdev_register(&dev->dev, &led->cdev);
if (ret < 0)
dev_err(&dev->dev, "led_classdev_register failed\n");

@@ -113,7 +104,6 @@ static int s3c24xx_led_probe(struct platform_device *dev)

static struct platform_driver s3c24xx_led_driver = {
.probe = s3c24xx_led_probe,
- .remove = s3c24xx_led_remove,
.driver = {
.name = "s3c24xx_led",
},
--
1.9.1

2016-03-07 14:51:41

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 5/7] 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 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: Amitoj Kaur Chawla <[email protected]>
---
drivers/leds/leds-da903x.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c
index 4752a2b..3e0aab9 100644
--- a/drivers/leds/leds-da903x.c
+++ b/drivers/leds/leds-da903x.c
@@ -113,7 +113,7 @@ static int da903x_led_probe(struct platform_device *pdev)
led->flags = pdata->flags;
led->master = pdev->dev.parent;

- ret = led_classdev_register(led->master, &led->cdev);
+ ret = devm_led_classdev_register(led->master, &led->cdev);
if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", id);
return ret;
@@ -123,20 +123,11 @@ static int da903x_led_probe(struct platform_device *pdev)
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;
-}
-
static struct platform_driver da903x_led_driver = {
.driver = {
.name = "da903x-led",
},
.probe = da903x_led_probe,
- .remove = da903x_led_remove,
};

module_platform_driver(da903x_led_driver);
--
1.9.1

2016-03-07 14:51:54

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 7/7] leds: lm3533: 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.

To be compatible with this change, remove an unnecessary label by
replacing it with direct return statement.

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 <[email protected]>
---
drivers/leds/leds-lm3533.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
index 196dcb5..5b529dc 100644
--- a/drivers/leds/leds-lm3533.c
+++ b/drivers/leds/leds-lm3533.c
@@ -698,7 +698,7 @@ static int lm3533_led_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, led);

- ret = led_classdev_register(pdev->dev.parent, &led->cdev);
+ ret = devm_led_classdev_register(pdev->dev.parent, &led->cdev);
if (ret) {
dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id);
return ret;
@@ -708,18 +708,13 @@ static int lm3533_led_probe(struct platform_device *pdev)

ret = lm3533_led_setup(led, pdata);
if (ret)
- goto err_unregister;
+ return ret;

ret = lm3533_ctrlbank_enable(&led->cb);
if (ret)
- goto err_unregister;
+ return ret;

return 0;
-
-err_unregister:
- led_classdev_unregister(&led->cdev);
-
- return ret;
}

static int lm3533_led_remove(struct platform_device *pdev)
@@ -729,7 +724,6 @@ static int lm3533_led_remove(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s\n", __func__);

lm3533_ctrlbank_disable(&led->cb);
- led_classdev_unregister(&led->cdev);

return 0;
}
--
1.9.1

2016-03-07 14:52:20

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 6/7] leds: max8997: 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 max8997_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 <[email protected]>
---
drivers/leds/leds-max8997.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c
index 01b45906..2387e35 100644
--- a/drivers/leds/leds-max8997.c
+++ b/drivers/leds/leds-max8997.c
@@ -283,28 +283,18 @@ static int max8997_led_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, led);

- ret = led_classdev_register(&pdev->dev, &led->cdev);
+ ret = devm_led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0)
return ret;

return 0;
}

-static int max8997_led_remove(struct platform_device *pdev)
-{
- struct max8997_led *led = platform_get_drvdata(pdev);
-
- led_classdev_unregister(&led->cdev);
-
- return 0;
-}
-
static struct platform_driver max8997_led_driver = {
.driver = {
.name = "max8997-led",
},
.probe = max8997_led_probe,
- .remove = max8997_led_remove,
};

module_platform_driver(max8997_led_driver);
--
1.9.1

2016-03-07 14:52:45

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: [PATCH 1/7] 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 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 <[email protected]>
---
drivers/leds/leds-88pm860x.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
index 1ad4d03..16cfb3d 100644
--- a/drivers/leds/leds-88pm860x.c
+++ b/drivers/leds/leds-88pm860x.c
@@ -208,7 +208,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 +217,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);
--
1.9.1

2016-03-08 08:26:27

by Jacek Anaszewski

[permalink] [raw]
Subject: Re: [PATCH 0/7] leds: Use devm_led_classdev_register

Hi Amitoj,

Thanks for the patches.

Applied only the 7/7 one. In the remaining ones, please remove
also all occurrences of platform_set_drvdata() in the probe()
and pdev_to_gpio() definition from leds-s3c24xx.cm as they will
be no longer required.

Best regards,
Jacek Anaszewski

On 03/07/2016 03:50 PM, Amitoj Kaur Chawla wrote:
> Switch to resource-managed function devm_led_classdev_register instead
> of led_classdev_register and remove unneeded led_classdev_unregister.
>
> 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>
>
> Amitoj Kaur Chawla (7):
> leds: 88pm860x: Use devm_led_classdev_register
> leds: lp8788: Use devm_led_classdev_register
> leds: wm381x-status: Use devm_led_classdev_register
> leds: s3c24xx: Use devm_led_classdev_register
> leds: da903x: Use devm_led_classdev_register
> leds: max8997: Use devm_led_classdev_register
> leds: lm3533: Use devm_led_classdev_register
>
> drivers/leds/leds-88pm860x.c | 11 +----------
> drivers/leds/leds-da903x.c | 11 +----------
> drivers/leds/leds-lm3533.c | 12 +++---------
> drivers/leds/leds-lp8788.c | 12 +-----------
> drivers/leds/leds-max8997.c | 12 +-----------
> drivers/leds/leds-s3c24xx.c | 12 +-----------
> drivers/leds/leds-wm831x-status.c | 12 +-----------
> 7 files changed, 9 insertions(+), 73 deletions(-)
>



2016-03-08 12:42:41

by Amitoj Kaur Chawla

[permalink] [raw]
Subject: Re: [PATCH 0/7] leds: Use devm_led_classdev_register

On Tue, Mar 8, 2016 at 1:56 PM, Jacek Anaszewski
<[email protected]> wrote:
> Hi Amitoj,
>
> Thanks for the patches.
>
> Applied only the 7/7 one. In the remaining ones, please remove
> also all occurrences of platform_set_drvdata() in the probe()
> and pdev_to_gpio() definition from leds-s3c24xx.cm as they will
> be no longer required.

Okay, thanks for the feedback. Will do.

Amitoj