提交 29ce9feb 编写于 作者: A Axel Lin 提交者: Bryan Wu

leds: regulator: Convert to devm_regulator_get_exclusive

Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NBryan Wu <cooloney@gmail.com>
上级 206c5f60
...@@ -153,24 +153,21 @@ static int regulator_led_probe(struct platform_device *pdev) ...@@ -153,24 +153,21 @@ static int regulator_led_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
vcc = regulator_get_exclusive(&pdev->dev, "vled"); vcc = devm_regulator_get_exclusive(&pdev->dev, "vled");
if (IS_ERR(vcc)) { if (IS_ERR(vcc)) {
dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name);
return PTR_ERR(vcc); return PTR_ERR(vcc);
} }
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (led == NULL) { if (led == NULL)
ret = -ENOMEM; return -ENOMEM;
goto err_vcc;
}
led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); led->cdev.max_brightness = led_regulator_get_max_brightness(vcc);
if (pdata->brightness > led->cdev.max_brightness) { if (pdata->brightness > led->cdev.max_brightness) {
dev_err(&pdev->dev, "Invalid default brightness %d\n", dev_err(&pdev->dev, "Invalid default brightness %d\n",
pdata->brightness); pdata->brightness);
ret = -EINVAL; return -EINVAL;
goto err_vcc;
} }
led->value = pdata->brightness; led->value = pdata->brightness;
...@@ -191,7 +188,7 @@ static int regulator_led_probe(struct platform_device *pdev) ...@@ -191,7 +188,7 @@ static int regulator_led_probe(struct platform_device *pdev)
ret = led_classdev_register(&pdev->dev, &led->cdev); ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0) { if (ret < 0) {
cancel_work_sync(&led->work); cancel_work_sync(&led->work);
goto err_vcc; return ret;
} }
/* to expose the default value to userspace */ /* to expose the default value to userspace */
...@@ -201,10 +198,6 @@ static int regulator_led_probe(struct platform_device *pdev) ...@@ -201,10 +198,6 @@ static int regulator_led_probe(struct platform_device *pdev)
regulator_led_set_value(led); regulator_led_set_value(led);
return 0; return 0;
err_vcc:
regulator_put(vcc);
return ret;
} }
static int regulator_led_remove(struct platform_device *pdev) static int regulator_led_remove(struct platform_device *pdev)
...@@ -214,7 +207,6 @@ static int regulator_led_remove(struct platform_device *pdev) ...@@ -214,7 +207,6 @@ static int regulator_led_remove(struct platform_device *pdev)
led_classdev_unregister(&led->cdev); led_classdev_unregister(&led->cdev);
cancel_work_sync(&led->work); cancel_work_sync(&led->work);
regulator_led_disable(led); regulator_led_disable(led);
regulator_put(led->vcc);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册