lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Sep 2013 17:13:42 +0900
From:	Jingoo Han <jg1.han@...sung.com>
To:	'Axel Lin' <axel.lin@...ics.com>
Cc:	'Mark Brown' <broonie@...nel.org>,
	'Liam Girdwood' <lgirdwood@...il.com>,
	linux-kernel@...r.kernel.org, 'Jingoo Han' <jg1.han@...sung.com>,
	'Sachin Kamat' <sachin.kamat@...aro.org>
Subject: Re: [PATCH V3 12/14] regulator: tps6524x: use devm_regulator_register()

On Thursday, September 26, 2013 5:06 PM, Axel Lin wrote:
> 2013/9/26 Jingoo Han <jg1.han@...sung.com>:
> > Use devm_regulator_register() to make cleanup paths simpler.
> >
> > Signed-off-by: Jingoo Han <jg1.han@...sung.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.
> 

CC'ed Sachin Kamat,

Hi Axel,

I really appreciate your comment.

Then, you mean the following.
If I am wrong, please let me know. :-)
Thank you.

static int pmic_probe(struct spi_device *spi)
{
	......

		hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i],
                                                      &config);
		if (IS_ERR(hw->rdev[i]))
			return PTR_ERR(hw->rdev[i]);
	}

        return 0;
}

static struct spi_driver pmic_driver = {
        .probe          = pmic_probe,
        .driver         = {
                .name   = "tps6524x",
                .owner  = THIS_MODULE,
        },
};

Best regards,
Jingoo Han

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ