Skip to content

Commit

Permalink
leds: regulator: Convert to devm_regulator_get_exclusive
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
  • Loading branch information
Axel Lin authored and Bryan Wu committed Nov 14, 2014
1 parent 206c5f6 commit 29ce9fe
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions drivers/leds/leds-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,21 @@ static int regulator_led_probe(struct platform_device *pdev)
return -ENODEV;
}

vcc = regulator_get_exclusive(&pdev->dev, "vled");
vcc = devm_regulator_get_exclusive(&pdev->dev, "vled");
if (IS_ERR(vcc)) {
dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name);
return PTR_ERR(vcc);
}

led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (led == NULL) {
ret = -ENOMEM;
goto err_vcc;
}
if (led == NULL)
return -ENOMEM;

led->cdev.max_brightness = led_regulator_get_max_brightness(vcc);
if (pdata->brightness > led->cdev.max_brightness) {
dev_err(&pdev->dev, "Invalid default brightness %d\n",
pdata->brightness);
ret = -EINVAL;
goto err_vcc;
return -EINVAL;
}
led->value = pdata->brightness;

Expand All @@ -191,7 +188,7 @@ static int regulator_led_probe(struct platform_device *pdev)
ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0) {
cancel_work_sync(&led->work);
goto err_vcc;
return ret;
}

/* to expose the default value to userspace */
Expand All @@ -201,10 +198,6 @@ static int regulator_led_probe(struct platform_device *pdev)
regulator_led_set_value(led);

return 0;

err_vcc:
regulator_put(vcc);
return ret;
}

static int regulator_led_remove(struct platform_device *pdev)
Expand All @@ -214,7 +207,6 @@ static int regulator_led_remove(struct platform_device *pdev)
led_classdev_unregister(&led->cdev);
cancel_work_sync(&led->work);
regulator_led_disable(led);
regulator_put(led->vcc);
return 0;
}

Expand Down

0 comments on commit 29ce9fe

Please sign in to comment.