diff options
author | Bryan Wu <bryan.wu@canonical.com> | 2012-07-03 01:07:53 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:37 -0400 |
commit | bad1c898e8b70c644c6542f79802326cc7b11c77 (patch) | |
tree | fd0bf324a68ca1739f27c332a6a49aeef7fb683f /drivers/leds/leds-da903x.c | |
parent | 9813d74fa55fba7a974d66d452d1d699ee15073b (diff) |
leds: convert DA9030/DA9034 LED driver to devm_kzalloc() and cleanup error exit path
Cc: Eric Miao <eric.miao@canonical.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-da903x.c')
-rw-r--r-- | drivers/leds/leds-da903x.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/leds/leds-da903x.c b/drivers/leds/leds-da903x.c index d9cd73ebd6c4..cc77c9d92615 100644 --- a/drivers/leds/leds-da903x.c +++ b/drivers/leds/leds-da903x.c | |||
@@ -108,7 +108,7 @@ static int __devinit da903x_led_probe(struct platform_device *pdev) | |||
108 | return -EINVAL; | 108 | return -EINVAL; |
109 | } | 109 | } |
110 | 110 | ||
111 | led = kzalloc(sizeof(struct da903x_led), GFP_KERNEL); | 111 | led = devm_kzalloc(&pdev->dev, sizeof(struct da903x_led), GFP_KERNEL); |
112 | if (led == NULL) { | 112 | if (led == NULL) { |
113 | dev_err(&pdev->dev, "failed to alloc memory for LED%d\n", id); | 113 | dev_err(&pdev->dev, "failed to alloc memory for LED%d\n", id); |
114 | return -ENOMEM; | 114 | return -ENOMEM; |
@@ -129,15 +129,11 @@ static int __devinit da903x_led_probe(struct platform_device *pdev) | |||
129 | ret = led_classdev_register(led->master, &led->cdev); | 129 | ret = led_classdev_register(led->master, &led->cdev); |
130 | if (ret) { | 130 | if (ret) { |
131 | dev_err(&pdev->dev, "failed to register LED %d\n", id); | 131 | dev_err(&pdev->dev, "failed to register LED %d\n", id); |
132 | goto err; | 132 | return ret; |
133 | } | 133 | } |
134 | 134 | ||
135 | platform_set_drvdata(pdev, led); | 135 | platform_set_drvdata(pdev, led); |
136 | return 0; | 136 | return 0; |
137 | |||
138 | err: | ||
139 | kfree(led); | ||
140 | return ret; | ||
141 | } | 137 | } |
142 | 138 | ||
143 | static int __devexit da903x_led_remove(struct platform_device *pdev) | 139 | static int __devexit da903x_led_remove(struct platform_device *pdev) |
@@ -145,7 +141,6 @@ static int __devexit da903x_led_remove(struct platform_device *pdev) | |||
145 | struct da903x_led *led = platform_get_drvdata(pdev); | 141 | struct da903x_led *led = platform_get_drvdata(pdev); |
146 | 142 | ||
147 | led_classdev_unregister(&led->cdev); | 143 | led_classdev_unregister(&led->cdev); |
148 | kfree(led); | ||
149 | return 0; | 144 | return 0; |
150 | } | 145 | } |
151 | 146 | ||