diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-10-24 10:45:58 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2014-11-14 17:29:34 -0500 |
commit | 29ce9feb65d377ea24cb0d3aabc63b090e56c152 (patch) | |
tree | 3a3b92c67bd6cede57e9ea3c3e6efc29b122bfb0 /drivers/leds | |
parent | 206c5f60a3d902bc4b56dab2de3e88de5eb06108 (diff) |
leds: regulator: Convert to devm_regulator_get_exclusive
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-regulator.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c index 358430db6e66..a6354f1ce7b2 100644 --- a/drivers/leds/leds-regulator.c +++ b/drivers/leds/leds-regulator.c | |||
@@ -153,24 +153,21 @@ static int regulator_led_probe(struct platform_device *pdev) | |||
153 | return -ENODEV; | 153 | return -ENODEV; |
154 | } | 154 | } |
155 | 155 | ||
156 | vcc = regulator_get_exclusive(&pdev->dev, "vled"); | 156 | vcc = devm_regulator_get_exclusive(&pdev->dev, "vled"); |
157 | if (IS_ERR(vcc)) { | 157 | if (IS_ERR(vcc)) { |
158 | dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); | 158 | dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); |
159 | return PTR_ERR(vcc); | 159 | return PTR_ERR(vcc); |
160 | } | 160 | } |
161 | 161 | ||
162 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); | 162 | led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); |
163 | if (led == NULL) { | 163 | if (led == NULL) |
164 | ret = -ENOMEM; | 164 | return -ENOMEM; |
165 | goto err_vcc; | ||
166 | } | ||
167 | 165 | ||
168 | led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); | 166 | led->cdev.max_brightness = led_regulator_get_max_brightness(vcc); |
169 | if (pdata->brightness > led->cdev.max_brightness) { | 167 | if (pdata->brightness > led->cdev.max_brightness) { |
170 | dev_err(&pdev->dev, "Invalid default brightness %d\n", | 168 | dev_err(&pdev->dev, "Invalid default brightness %d\n", |
171 | pdata->brightness); | 169 | pdata->brightness); |
172 | ret = -EINVAL; | 170 | return -EINVAL; |
173 | goto err_vcc; | ||
174 | } | 171 | } |
175 | led->value = pdata->brightness; | 172 | led->value = pdata->brightness; |
176 | 173 | ||
@@ -191,7 +188,7 @@ static int regulator_led_probe(struct platform_device *pdev) | |||
191 | ret = led_classdev_register(&pdev->dev, &led->cdev); | 188 | ret = led_classdev_register(&pdev->dev, &led->cdev); |
192 | if (ret < 0) { | 189 | if (ret < 0) { |
193 | cancel_work_sync(&led->work); | 190 | cancel_work_sync(&led->work); |
194 | goto err_vcc; | 191 | return ret; |
195 | } | 192 | } |
196 | 193 | ||
197 | /* to expose the default value to userspace */ | 194 | /* to expose the default value to userspace */ |
@@ -201,10 +198,6 @@ static int regulator_led_probe(struct platform_device *pdev) | |||
201 | regulator_led_set_value(led); | 198 | regulator_led_set_value(led); |
202 | 199 | ||
203 | return 0; | 200 | return 0; |
204 | |||
205 | err_vcc: | ||
206 | regulator_put(vcc); | ||
207 | return ret; | ||
208 | } | 201 | } |
209 | 202 | ||
210 | static int regulator_led_remove(struct platform_device *pdev) | 203 | static int regulator_led_remove(struct platform_device *pdev) |
@@ -214,7 +207,6 @@ static int regulator_led_remove(struct platform_device *pdev) | |||
214 | led_classdev_unregister(&led->cdev); | 207 | led_classdev_unregister(&led->cdev); |
215 | cancel_work_sync(&led->work); | 208 | cancel_work_sync(&led->work); |
216 | regulator_led_disable(led); | 209 | regulator_led_disable(led); |
217 | regulator_put(led->vcc); | ||
218 | return 0; | 210 | return 0; |
219 | } | 211 | } |
220 | 212 | ||