diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-10-25 08:47:41 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-01-08 18:37:29 -0500 |
commit | 42ab84fb0a3db786567158bf0006a35131714eb5 (patch) | |
tree | 7087360e9b6cdd0af0e9d1c5032f4e93d187b51d | |
parent | d48cbb74357b42b86ac8edc3bc34bcb3d65a12d9 (diff) |
mfd: Convert wm8994 to devm_kzalloc()
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | drivers/mfd/wm8994-core.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 61894fced8ea..ff373dcda2c7 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c | |||
@@ -402,9 +402,9 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) | |||
402 | goto err_regmap; | 402 | goto err_regmap; |
403 | } | 403 | } |
404 | 404 | ||
405 | wm8994->supplies = kzalloc(sizeof(struct regulator_bulk_data) * | 405 | wm8994->supplies = devm_kzalloc(wm8994->dev, |
406 | wm8994->num_supplies, | 406 | sizeof(struct regulator_bulk_data) * |
407 | GFP_KERNEL); | 407 | wm8994->num_supplies, GFP_KERNEL); |
408 | if (!wm8994->supplies) { | 408 | if (!wm8994->supplies) { |
409 | ret = -ENOMEM; | 409 | ret = -ENOMEM; |
410 | goto err_regmap; | 410 | goto err_regmap; |
@@ -432,7 +432,7 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) | |||
432 | wm8994->supplies); | 432 | wm8994->supplies); |
433 | if (ret != 0) { | 433 | if (ret != 0) { |
434 | dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); | 434 | dev_err(wm8994->dev, "Failed to get supplies: %d\n", ret); |
435 | goto err_supplies; | 435 | goto err_regmap; |
436 | } | 436 | } |
437 | 437 | ||
438 | ret = regulator_bulk_enable(wm8994->num_supplies, | 438 | ret = regulator_bulk_enable(wm8994->num_supplies, |
@@ -560,12 +560,9 @@ err_enable: | |||
560 | wm8994->supplies); | 560 | wm8994->supplies); |
561 | err_get: | 561 | err_get: |
562 | regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); | 562 | regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); |
563 | err_supplies: | ||
564 | kfree(wm8994->supplies); | ||
565 | err_regmap: | 563 | err_regmap: |
566 | regmap_exit(wm8994->regmap); | 564 | regmap_exit(wm8994->regmap); |
567 | mfd_remove_devices(wm8994->dev); | 565 | mfd_remove_devices(wm8994->dev); |
568 | kfree(wm8994); | ||
569 | return ret; | 566 | return ret; |
570 | } | 567 | } |
571 | 568 | ||
@@ -577,9 +574,7 @@ static void wm8994_device_exit(struct wm8994 *wm8994) | |||
577 | regulator_bulk_disable(wm8994->num_supplies, | 574 | regulator_bulk_disable(wm8994->num_supplies, |
578 | wm8994->supplies); | 575 | wm8994->supplies); |
579 | regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); | 576 | regulator_bulk_free(wm8994->num_supplies, wm8994->supplies); |
580 | kfree(wm8994->supplies); | ||
581 | regmap_exit(wm8994->regmap); | 577 | regmap_exit(wm8994->regmap); |
582 | kfree(wm8994); | ||
583 | } | 578 | } |
584 | 579 | ||
585 | static int wm8994_i2c_probe(struct i2c_client *i2c, | 580 | static int wm8994_i2c_probe(struct i2c_client *i2c, |
@@ -588,7 +583,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c, | |||
588 | struct wm8994 *wm8994; | 583 | struct wm8994 *wm8994; |
589 | int ret; | 584 | int ret; |
590 | 585 | ||
591 | wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); | 586 | wm8994 = devm_kzalloc(&i2c->dev, sizeof(struct wm8994), GFP_KERNEL); |
592 | if (wm8994 == NULL) | 587 | if (wm8994 == NULL) |
593 | return -ENOMEM; | 588 | return -ENOMEM; |
594 | 589 | ||
@@ -602,7 +597,6 @@ static int wm8994_i2c_probe(struct i2c_client *i2c, | |||
602 | ret = PTR_ERR(wm8994->regmap); | 597 | ret = PTR_ERR(wm8994->regmap); |
603 | dev_err(wm8994->dev, "Failed to allocate register map: %d\n", | 598 | dev_err(wm8994->dev, "Failed to allocate register map: %d\n", |
604 | ret); | 599 | ret); |
605 | kfree(wm8994); | ||
606 | return ret; | 600 | return ret; |
607 | } | 601 | } |
608 | 602 | ||