diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-07-03 07:47:54 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-23 19:52:36 -0400 |
commit | d41589658ed1607303e702805c51030d6ecfc471 (patch) | |
tree | 67d89834ae46ad8ed786e16a2285d601b9b439f3 /drivers/leds/leds-regulator.c | |
parent | 0b7da746cc5fdbdb7b52bf6faa9bb06bb0dd7869 (diff) |
leds: Use devm_kzalloc in leds-regulator.c file
devm_kzalloc() makes cleanup simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers/leds/leds-regulator.c')
-rw-r--r-- | drivers/leds/leds-regulator.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c index df7e963bddd3..25d382d60fa9 100644 --- a/drivers/leds/leds-regulator.c +++ b/drivers/leds/leds-regulator.c | |||
@@ -158,7 +158,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) | |||
158 | return PTR_ERR(vcc); | 158 | return PTR_ERR(vcc); |
159 | } | 159 | } |
160 | 160 | ||
161 | led = kzalloc(sizeof(*led), GFP_KERNEL); | 161 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); |
162 | if (led == NULL) { | 162 | if (led == NULL) { |
163 | ret = -ENOMEM; | 163 | ret = -ENOMEM; |
164 | goto err_vcc; | 164 | goto err_vcc; |
@@ -169,7 +169,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) | |||
169 | dev_err(&pdev->dev, "Invalid default brightness %d\n", | 169 | dev_err(&pdev->dev, "Invalid default brightness %d\n", |
170 | pdata->brightness); | 170 | pdata->brightness); |
171 | ret = -EINVAL; | 171 | ret = -EINVAL; |
172 | goto err_led; | 172 | goto err_vcc; |
173 | } | 173 | } |
174 | led->value = pdata->brightness; | 174 | led->value = pdata->brightness; |
175 | 175 | ||
@@ -190,7 +190,7 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) | |||
190 | ret = led_classdev_register(&pdev->dev, &led->cdev); | 190 | ret = led_classdev_register(&pdev->dev, &led->cdev); |
191 | if (ret < 0) { | 191 | if (ret < 0) { |
192 | cancel_work_sync(&led->work); | 192 | cancel_work_sync(&led->work); |
193 | goto err_led; | 193 | goto err_vcc; |
194 | } | 194 | } |
195 | 195 | ||
196 | /* to expose the default value to userspace */ | 196 | /* to expose the default value to userspace */ |
@@ -201,8 +201,6 @@ static int __devinit regulator_led_probe(struct platform_device *pdev) | |||
201 | 201 | ||
202 | return 0; | 202 | return 0; |
203 | 203 | ||
204 | err_led: | ||
205 | kfree(led); | ||
206 | err_vcc: | 204 | err_vcc: |
207 | regulator_put(vcc); | 205 | regulator_put(vcc); |
208 | return ret; | 206 | return ret; |
@@ -216,7 +214,6 @@ static int __devexit regulator_led_remove(struct platform_device *pdev) | |||
216 | cancel_work_sync(&led->work); | 214 | cancel_work_sync(&led->work); |
217 | regulator_led_disable(led); | 215 | regulator_led_disable(led); |
218 | regulator_put(led->vcc); | 216 | regulator_put(led->vcc); |
219 | kfree(led); | ||
220 | return 0; | 217 | return 0; |
221 | } | 218 | } |
222 | 219 | ||