summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2017-08-08 16:42:38 +0300
committerJoel Stanley <joel@jms.id.au>2017-11-28 07:37:43 +0300
commita9376f34e0a6f615228982531a180f9e03dfeddf (patch)
treeac17fdb5847fef2b6b088fa3e37bae6b1e13c149
parent4a8dbcd714cffc43050d69fe426ff6ffbd919628 (diff)
downloadlinux-a9376f34e0a6f615228982531a180f9e03dfeddf.tar.xz
leds: pca955x: use devm_led_classdev_register
This lets us remove the loop doing the cleanup in case of failure and also the remove handler of the i2c_driver. Signed-off-by: Cédric Le Goater <clg@kaod.org> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> (cherry picked from commit 91940bb4ca7b7f1b5426cc14bdbd0c7f8347683f) Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--drivers/leds/leds-pca955x.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 2d34009d00e6..5a5d3765cfd3 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -410,10 +410,10 @@ static int pca955x_probe(struct i2c_client *client,
pca955x_led->led_cdev.name = pca955x_led->name;
pca955x_led->led_cdev.brightness_set_blocking = pca955x_led_set;
- err = led_classdev_register(&client->dev,
- &pca955x_led->led_cdev);
- if (err < 0)
- goto exit;
+ err = devm_led_classdev_register(&client->dev,
+ &pca955x_led->led_cdev);
+ if (err)
+ return err;
}
/* Turn off LEDs */
@@ -431,23 +431,6 @@ static int pca955x_probe(struct i2c_client *client,
pca955x_write_psc(client, 1, 0);
return 0;
-
-exit:
- while (i--)
- led_classdev_unregister(&pca955x->leds[i].led_cdev);
-
- return err;
-}
-
-static int pca955x_remove(struct i2c_client *client)
-{
- struct pca955x *pca955x = i2c_get_clientdata(client);
- int i;
-
- for (i = 0; i < pca955x->chipdef->bits; i++)
- led_classdev_unregister(&pca955x->leds[i].led_cdev);
-
- return 0;
}
static struct i2c_driver pca955x_driver = {
@@ -457,7 +440,6 @@ static struct i2c_driver pca955x_driver = {
.of_match_table = of_match_ptr(of_pca955x_match),
},
.probe = pca955x_probe,
- .remove = pca955x_remove,
.id_table = pca955x_id,
};