aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-10-25 07:45:40 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-12 11:09:29 -0500
commit2fa33494676636f3455daddda33b7c3d5d932f2f (patch)
treecfaa3b5a4b54b51107db61c497a9cce76920e0b8
parentcf763c2e606e9e427ed854c470911e816be1101e (diff)
mfd: Convert wm8994 to devm_kzalloc()
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/mfd/wm8994-core.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index 74d4746086c6..a6846b04e156 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -401,9 +401,9 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
401 goto err_regmap; 401 goto err_regmap;
402 } 402 }
403 403
404 wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * 404 wm8994->supplies = devm_kzalloc(wm8994->dev,
405 wm8994->num_supplies, 405 sizeof(struct regulator_bulk_data) *
406 GFP_KERNEL); 406 wm8994->num_supplies, GFP_KERNEL);
407 if (!wm8994->supplies) { 407 if (!wm8994->supplies) {
408 ret = -ENOMEM; 408 ret = -ENOMEM;
409 goto err_regmap; 409 goto err_regmap;
@@ -431,7 +431,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
431 wm8994->supplies); 431 wm8994->supplies);
432 if (ret != 0) { 432 if (ret != 0) {
433 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); 433 dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret);
434 goto err_supplies; 434 goto err_regmap;
435 } 435 }
436 436
437 ret = regulator_bulk_enable(wm8994->num_supplies, 437 ret = regulator_bulk_enable(wm8994->num_supplies,
@@ -559,12 +559,9 @@ err_enable:
559 wm8994->supplies); 559 wm8994->supplies);
560err_get: 560err_get:
561 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 561 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
562err_supplies:
563 kfree(wm8994->supplies);
564err_regmap: 562err_regmap:
565 regmap_exit(wm8994->regmap); 563 regmap_exit(wm8994->regmap);
566 mfd_remove_devices(wm8994->dev); 564 mfd_remove_devices(wm8994->dev);
567 kfree(wm8994);
568 return ret; 565 return ret;
569} 566}
570 567
@@ -576,9 +573,7 @@ static void wm8994_device_exit(struct wm8994 *wm8994)
576 regulator_bulk_disable(wm8994->num_supplies, 573 regulator_bulk_disable(wm8994->num_supplies,
577 wm8994->supplies); 574 wm8994->supplies);
578 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); 575 regulator_bulk_free(wm8994->num_supplies, wm8994->supplies);
579 kfree(wm8994->supplies);
580 regmap_exit(wm8994->regmap); 576 regmap_exit(wm8994->regmap);
581 kfree(wm8994);
582} 577}
583 578
584static const struct of_device_id wm8994_of_match[] = { 579static const struct of_device_id wm8994_of_match[] = {
@@ -595,7 +590,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
595 struct wm8994 *wm8994; 590 struct wm8994 *wm8994;
596 int ret; 591 int ret;
597 592
598 wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); 593 wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL);
599 if (wm8994 == NULL) 594 if (wm8994 == NULL)
600 return -ENOMEM; 595 return -ENOMEM;
601 596
@@ -609,7 +604,6 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
609 ret = PTR_ERR(wm8994->regmap); 604 ret = PTR_ERR(wm8994->regmap);
610 dev_err(wm8994->dev, "Failed to allocate register map: %d\n", 605 dev_err(wm8994->dev, "Failed to allocate register map: %d\n",
611 ret); 606 ret);
612 kfree(wm8994);
613 return ret; 607 return ret;
614 } 608 }
615 609