aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-17 21:35:35 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-18 05:26:24 -0400
commita81edbdeb68bbecb3ee2888da7a83662ae69c9f3 (patch)
tree36a3a20c56ff482713f87b6e2cf13fdeb601c14f
parent5abe0c4005dea3a67051eb1942916f9d0f6a1796 (diff)
regulator: virtual: Convert to use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/virtual.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index ee0b161c998f..f74a68f2f16f 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -291,18 +291,19 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
291 struct virtual_consumer_data *drvdata; 291 struct virtual_consumer_data *drvdata;
292 int ret; 292 int ret;
293 293
294 drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL); 294 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct virtual_consumer_data),
295 GFP_KERNEL);
295 if (drvdata == NULL) 296 if (drvdata == NULL)
296 return -ENOMEM; 297 return -ENOMEM;
297 298
298 mutex_init(&drvdata->lock); 299 mutex_init(&drvdata->lock);
299 300
300 drvdata->regulator = regulator_get(&pdev->dev, reg_id); 301 drvdata->regulator = devm_regulator_get(&pdev->dev, reg_id);
301 if (IS_ERR(drvdata->regulator)) { 302 if (IS_ERR(drvdata->regulator)) {
302 ret = PTR_ERR(drvdata->regulator); 303 ret = PTR_ERR(drvdata->regulator);
303 dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n", 304 dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n",
304 reg_id, ret); 305 reg_id, ret);
305 goto err; 306 return ret;
306 } 307 }
307 308
308 ret = sysfs_create_group(&pdev->dev.kobj, 309 ret = sysfs_create_group(&pdev->dev.kobj,
@@ -310,7 +311,7 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
310 if (ret != 0) { 311 if (ret != 0) {
311 dev_err(&pdev->dev, 312 dev_err(&pdev->dev,
312 "Failed to create attribute group: %d\n", ret); 313 "Failed to create attribute group: %d\n", ret);
313 goto err_regulator; 314 return ret;
314 } 315 }
315 316
316 drvdata->mode = regulator_get_mode(drvdata->regulator); 317 drvdata->mode = regulator_get_mode(drvdata->regulator);
@@ -318,12 +319,6 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev)
318 platform_set_drvdata(pdev, drvdata); 319 platform_set_drvdata(pdev, drvdata);
319 320
320 return 0; 321 return 0;
321
322err_regulator:
323 regulator_put(drvdata->regulator);
324err:
325 kfree(drvdata);
326 return ret;
327} 322}
328 323
329static int __devexit regulator_virtual_remove(struct platform_device *pdev) 324static int __devexit regulator_virtual_remove(struct platform_device *pdev)
@@ -334,9 +329,6 @@ static int __devexit regulator_virtual_remove(struct platform_device *pdev)
334 329
335 if (drvdata->enabled) 330 if (drvdata->enabled)
336 regulator_disable(drvdata->regulator); 331 regulator_disable(drvdata->regulator);
337 regulator_put(drvdata->regulator);
338
339 kfree(drvdata);
340 332
341 platform_set_drvdata(pdev, NULL); 333 platform_set_drvdata(pdev, NULL);
342 334