lkml.org 
[lkml]   [2013]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH V3 12/14] regulator: tps6524x: use devm_regulator_register()
From
2013/9/26 Jingoo Han <jg1.han@samsung.com>:
> Use devm_regulator_register() to make cleanup paths simpler.
>
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
> drivers/regulator/tps6524x-regulator.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c
> index 8b9ee39..8fe67fb 100644
> --- a/drivers/regulator/tps6524x-regulator.c
> +++ b/drivers/regulator/tps6524x-regulator.c
> @@ -584,10 +584,8 @@ static int pmic_remove(struct spi_device *spi)
>
> if (!hw)
> return 0;
> - for (i = 0; i < N_REGULATORS; i++) {
> - regulator_unregister(hw->rdev[i]);
> + for (i = 0; i < N_REGULATORS; i++)
> hw->rdev[i] = NULL;
> - }
> return 0;
> }
>
> @@ -631,7 +629,8 @@ static int pmic_probe(struct spi_device *spi)
> config.init_data = init_data;
> config.driver_data = hw;
>
> - hw->rdev[i] = regulator_register(&hw->desc[i], &config);
> + hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i],
> + &config);
> if (IS_ERR(hw->rdev[i])) {
> ret = PTR_ERR(hw->rdev[i]);
> hw->rdev[i] = NULL;

I think you can simply return PTR_ERR(hw->rdev[i]) if devm_regulator_register()
fails.
You are using devm_regulator_register now, so don't need to call
pmic_remove() in probe() error path.
Then pmic_remove() and .remove = pmic_remove() can be removed as well.

Regards,
Axel


\
 
 \ /
  Last update: 2013-09-26 10:21    [W:0.147 / U:1.468 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site