diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-08-09 22:08:32 -0400 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-09-11 06:32:40 -0400 |
commit | 490dcee9b433302da4ec5325c3e69a0be1201473 (patch) | |
tree | 5ecf391c3ab2df5eeae02735c05925b5e66d380c /drivers | |
parent | ee539a9309ecaf6b6eee59f1c9e1c4fd716624a0 (diff) |
leds: wm8350: Convert to devm_regulator_get()
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/leds/leds-wm8350.c | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c index 918d4baff1c7..f5d9ac3ff161 100644 --- a/drivers/leds/leds-wm8350.c +++ b/drivers/leds/leds-wm8350.c | |||
@@ -201,7 +201,7 @@ static int wm8350_led_probe(struct platform_device *pdev) | |||
201 | struct regulator *isink, *dcdc; | 201 | struct regulator *isink, *dcdc; |
202 | struct wm8350_led *led; | 202 | struct wm8350_led *led; |
203 | struct wm8350_led_platform_data *pdata = pdev->dev.platform_data; | 203 | struct wm8350_led_platform_data *pdata = pdev->dev.platform_data; |
204 | int ret, i; | 204 | int i; |
205 | 205 | ||
206 | if (pdata == NULL) { | 206 | if (pdata == NULL) { |
207 | dev_err(&pdev->dev, "no platform data\n"); | 207 | dev_err(&pdev->dev, "no platform data\n"); |
@@ -214,24 +214,21 @@ static int wm8350_led_probe(struct platform_device *pdev) | |||
214 | return -EINVAL; | 214 | return -EINVAL; |
215 | } | 215 | } |
216 | 216 | ||
217 | isink = regulator_get(&pdev->dev, "led_isink"); | 217 | isink = devm_regulator_get(&pdev->dev, "led_isink"); |
218 | if (IS_ERR(isink)) { | 218 | if (IS_ERR(isink)) { |
219 | printk(KERN_ERR "%s: can't get ISINK\n", __func__); | 219 | printk(KERN_ERR "%s: can't get ISINK\n", __func__); |
220 | return PTR_ERR(isink); | 220 | return PTR_ERR(isink); |
221 | } | 221 | } |
222 | 222 | ||
223 | dcdc = regulator_get(&pdev->dev, "led_vcc"); | 223 | dcdc = devm_regulator_get(&pdev->dev, "led_vcc"); |
224 | if (IS_ERR(dcdc)) { | 224 | if (IS_ERR(dcdc)) { |
225 | printk(KERN_ERR "%s: can't get DCDC\n", __func__); | 225 | printk(KERN_ERR "%s: can't get DCDC\n", __func__); |
226 | ret = PTR_ERR(dcdc); | 226 | return PTR_ERR(dcdc); |
227 | goto err_isink; | ||
228 | } | 227 | } |
229 | 228 | ||
230 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); | 229 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); |
231 | if (led == NULL) { | 230 | if (led == NULL) |
232 | ret = -ENOMEM; | 231 | return -ENOMEM; |
233 | goto err_dcdc; | ||
234 | } | ||
235 | 232 | ||
236 | led->cdev.brightness_set = wm8350_led_set; | 233 | led->cdev.brightness_set = wm8350_led_set; |
237 | led->cdev.default_trigger = pdata->default_trigger; | 234 | led->cdev.default_trigger = pdata->default_trigger; |
@@ -257,17 +254,7 @@ static int wm8350_led_probe(struct platform_device *pdev) | |||
257 | led->value = LED_OFF; | 254 | led->value = LED_OFF; |
258 | platform_set_drvdata(pdev, led); | 255 | platform_set_drvdata(pdev, led); |
259 | 256 | ||
260 | ret = led_classdev_register(&pdev->dev, &led->cdev); | 257 | return led_classdev_register(&pdev->dev, &led->cdev); |
261 | if (ret < 0) | ||
262 | goto err_dcdc; | ||
263 | |||
264 | return 0; | ||
265 | |||
266 | err_dcdc: | ||
267 | regulator_put(dcdc); | ||
268 | err_isink: | ||
269 | regulator_put(isink); | ||
270 | return ret; | ||
271 | } | 258 | } |
272 | 259 | ||
273 | static int wm8350_led_remove(struct platform_device *pdev) | 260 | static int wm8350_led_remove(struct platform_device *pdev) |
@@ -277,8 +264,6 @@ static int wm8350_led_remove(struct platform_device *pdev) | |||
277 | led_classdev_unregister(&led->cdev); | 264 | led_classdev_unregister(&led->cdev); |
278 | flush_work_sync(&led->work); | 265 | flush_work_sync(&led->work); |
279 | wm8350_led_disable(led); | 266 | wm8350_led_disable(led); |
280 | regulator_put(led->dcdc); | ||
281 | regulator_put(led->isink); | ||
282 | return 0; | 267 | return 0; |
283 | } | 268 | } |
284 | 269 | ||