All of lore.kernel.org
 help / color / mirror / Atom feed
From: maxime.ripard@free-electrons.com (Maxime Ripard)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register
Date: Tue, 17 Jun 2014 22:46:57 +0200	[thread overview]
Message-ID: <20140617204657.GE19730@lukather> (raw)
In-Reply-To: <1402990723-28138-7-git-send-email-boris.brezillon@free-electrons.com>

On Tue, Jun 17, 2014 at 09:38:42AM +0200, Boris BREZILLON wrote:
> Make use of the devm_regulator_set_register instead of registering each
> regulator provided by the PMIC.
> 
> This also solves a self dependency issue where one regulator of the PMIC
> is used as a supply for anoher regulator provided by the same PMIC.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
>  drivers/regulator/axp20x-regulator.c | 59 ++++++++++++++----------------------
>  1 file changed, 23 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index d42bf6d..e8f0df7 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -301,66 +301,53 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  
>  static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
> -	struct regulator_dev *rdev;
> +	struct regulator_set *rset;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> -	struct regulator_config config = { };
> -	struct regulator_init_data *init_data;
> +	struct regulator_set_config config;
>  	struct of_regulator_match *matches;
> -	int nmatches;
> -	const struct regulator_desc *regulators;
> -	int nregulators;
>  	int ret, i;
>  	u32 workmode;
>  
> +	memset(&config, 0, sizeof(config));
> +	config.dev = &pdev->dev;
> +	config.regmap = axp20x->regmap;
>  	if (axp20x->variant == AXP221_ID) {
>  		matches = axp22x_matches;
> -		nmatches = ARRAY_SIZE(axp22x_matches);
> -		regulators = axp22x_regulators;
> -		nregulators = AXP22X_REG_ID_MAX;
> +		config.descs = axp22x_regulators;
> +		config.nregulators = AXP22X_REG_ID_MAX;
>  	} else {
>  		matches = axp20x_matches;
> -		nmatches = ARRAY_SIZE(axp20x_matches);
> -		regulators = axp20x_regulators;
> -		nregulators = AXP20X_REG_ID_MAX;
> +		config.descs = axp20x_regulators;
> +		config.nregulators = AXP20X_REG_ID_MAX;
>  	}
> +	config.matches = matches;
>  
>  	/*
>  	 * Reset matches table (this table might have been modified by a
>  	 * previous AXP2xx device probe).
>  	 */
> -	for (i = 0; i < nmatches; i++) {
> +	for (i = 0; i < config.nregulators; i++) {
>  		matches[i].init_data = NULL;
>  		matches[i].of_node = NULL;
>  	}
>  
> -	ret = axp20x_regulator_parse_dt(pdev, matches, nmatches);
> +	ret = axp20x_regulator_parse_dt(pdev, matches,
> +					config.nregulators);
>  	if (ret)
>  		return ret;
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		init_data = matches[i].init_data;
> +	rset = devm_regulator_set_register(&pdev->dev, &config);
> +	if (IS_ERR(rset))
> +		return PTR_ERR(rset);
>  
> -		config.dev = &pdev->dev;
> -		config.init_data = init_data;
> -		config.regmap = axp20x->regmap;
> -		config.of_node = matches[i].of_node;
> -
> -		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
> -					       &config);
> -		if (IS_ERR(rdev)) {
> -			dev_err(&pdev->dev, "Failed to register %s\n",
> -				regulators[i].name);
> -
> -			return PTR_ERR(rdev);
> -		}
> -
> -		ret = of_property_read_u32(matches[i].of_node, "x-powers,dcdc-workmode",
> +	for (i = 0; i < rset->nregulators; i++) {
> +		ret = of_property_read_u32(config.matches[i].of_node,
> +					   "x-powers,dcdc-workmode",
>  					   &workmode);
> -		if (!ret) {
> -			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
> -				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					regulators[i].name);
> -		}
> +		if (!ret &&
> +		    axp20x_set_dcdc_workmode(rset->regulators[i], i, workmode))
> +			dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> +				config.descs[i].name);
>  	}
>  
>  	return 0;
> -- 
> 1.8.3.2
> 

It looks like you're modifying code you just introduced. You should
probably move this patch earlier on, so that you don't have to patch
your patch.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140617/10fcac8f/attachment.sig>

WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Boris BREZILLON
	<boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Liam Girdwood <lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Carlo Caione <carlo-KA+7E9HrN00dnm+yROfE0A@public.gmane.org>,
	Shuge <shuge-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org>,
	kevin-0TFLnhJekD6UEPyfVivIlAC/G2K4zDHf@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org
Subject: Re: [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register
Date: Tue, 17 Jun 2014 22:46:57 +0200	[thread overview]
Message-ID: <20140617204657.GE19730@lukather> (raw)
In-Reply-To: <1402990723-28138-7-git-send-email-boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 4107 bytes --]

On Tue, Jun 17, 2014 at 09:38:42AM +0200, Boris BREZILLON wrote:
> Make use of the devm_regulator_set_register instead of registering each
> regulator provided by the PMIC.
> 
> This also solves a self dependency issue where one regulator of the PMIC
> is used as a supply for anoher regulator provided by the same PMIC.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  drivers/regulator/axp20x-regulator.c | 59 ++++++++++++++----------------------
>  1 file changed, 23 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index d42bf6d..e8f0df7 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -301,66 +301,53 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  
>  static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
> -	struct regulator_dev *rdev;
> +	struct regulator_set *rset;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> -	struct regulator_config config = { };
> -	struct regulator_init_data *init_data;
> +	struct regulator_set_config config;
>  	struct of_regulator_match *matches;
> -	int nmatches;
> -	const struct regulator_desc *regulators;
> -	int nregulators;
>  	int ret, i;
>  	u32 workmode;
>  
> +	memset(&config, 0, sizeof(config));
> +	config.dev = &pdev->dev;
> +	config.regmap = axp20x->regmap;
>  	if (axp20x->variant == AXP221_ID) {
>  		matches = axp22x_matches;
> -		nmatches = ARRAY_SIZE(axp22x_matches);
> -		regulators = axp22x_regulators;
> -		nregulators = AXP22X_REG_ID_MAX;
> +		config.descs = axp22x_regulators;
> +		config.nregulators = AXP22X_REG_ID_MAX;
>  	} else {
>  		matches = axp20x_matches;
> -		nmatches = ARRAY_SIZE(axp20x_matches);
> -		regulators = axp20x_regulators;
> -		nregulators = AXP20X_REG_ID_MAX;
> +		config.descs = axp20x_regulators;
> +		config.nregulators = AXP20X_REG_ID_MAX;
>  	}
> +	config.matches = matches;
>  
>  	/*
>  	 * Reset matches table (this table might have been modified by a
>  	 * previous AXP2xx device probe).
>  	 */
> -	for (i = 0; i < nmatches; i++) {
> +	for (i = 0; i < config.nregulators; i++) {
>  		matches[i].init_data = NULL;
>  		matches[i].of_node = NULL;
>  	}
>  
> -	ret = axp20x_regulator_parse_dt(pdev, matches, nmatches);
> +	ret = axp20x_regulator_parse_dt(pdev, matches,
> +					config.nregulators);
>  	if (ret)
>  		return ret;
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		init_data = matches[i].init_data;
> +	rset = devm_regulator_set_register(&pdev->dev, &config);
> +	if (IS_ERR(rset))
> +		return PTR_ERR(rset);
>  
> -		config.dev = &pdev->dev;
> -		config.init_data = init_data;
> -		config.regmap = axp20x->regmap;
> -		config.of_node = matches[i].of_node;
> -
> -		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
> -					       &config);
> -		if (IS_ERR(rdev)) {
> -			dev_err(&pdev->dev, "Failed to register %s\n",
> -				regulators[i].name);
> -
> -			return PTR_ERR(rdev);
> -		}
> -
> -		ret = of_property_read_u32(matches[i].of_node, "x-powers,dcdc-workmode",
> +	for (i = 0; i < rset->nregulators; i++) {
> +		ret = of_property_read_u32(config.matches[i].of_node,
> +					   "x-powers,dcdc-workmode",
>  					   &workmode);
> -		if (!ret) {
> -			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
> -				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					regulators[i].name);
> -		}
> +		if (!ret &&
> +		    axp20x_set_dcdc_workmode(rset->regulators[i], i, workmode))
> +			dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> +				config.descs[i].name);
>  	}
>  
>  	return 0;
> -- 
> 1.8.3.2
> 

It looks like you're modifying code you just introduced. You should
probably move this patch earlier on, so that you don't have to patch
your patch.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Boris BREZILLON <boris.brezillon@free-electrons.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Carlo Caione <carlo@caione.org>,
	Shuge <shuge@allwinnertech.com>,
	kevin@allwinnertech.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org, dev@linux-sunxi.org
Subject: Re: [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register
Date: Tue, 17 Jun 2014 22:46:57 +0200	[thread overview]
Message-ID: <20140617204657.GE19730@lukather> (raw)
In-Reply-To: <1402990723-28138-7-git-send-email-boris.brezillon@free-electrons.com>

[-- Attachment #1: Type: text/plain, Size: 4076 bytes --]

On Tue, Jun 17, 2014 at 09:38:42AM +0200, Boris BREZILLON wrote:
> Make use of the devm_regulator_set_register instead of registering each
> regulator provided by the PMIC.
> 
> This also solves a self dependency issue where one regulator of the PMIC
> is used as a supply for anoher regulator provided by the same PMIC.
> 
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
>  drivers/regulator/axp20x-regulator.c | 59 ++++++++++++++----------------------
>  1 file changed, 23 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
> index d42bf6d..e8f0df7 100644
> --- a/drivers/regulator/axp20x-regulator.c
> +++ b/drivers/regulator/axp20x-regulator.c
> @@ -301,66 +301,53 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
>  
>  static int axp20x_regulator_probe(struct platform_device *pdev)
>  {
> -	struct regulator_dev *rdev;
> +	struct regulator_set *rset;
>  	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> -	struct regulator_config config = { };
> -	struct regulator_init_data *init_data;
> +	struct regulator_set_config config;
>  	struct of_regulator_match *matches;
> -	int nmatches;
> -	const struct regulator_desc *regulators;
> -	int nregulators;
>  	int ret, i;
>  	u32 workmode;
>  
> +	memset(&config, 0, sizeof(config));
> +	config.dev = &pdev->dev;
> +	config.regmap = axp20x->regmap;
>  	if (axp20x->variant == AXP221_ID) {
>  		matches = axp22x_matches;
> -		nmatches = ARRAY_SIZE(axp22x_matches);
> -		regulators = axp22x_regulators;
> -		nregulators = AXP22X_REG_ID_MAX;
> +		config.descs = axp22x_regulators;
> +		config.nregulators = AXP22X_REG_ID_MAX;
>  	} else {
>  		matches = axp20x_matches;
> -		nmatches = ARRAY_SIZE(axp20x_matches);
> -		regulators = axp20x_regulators;
> -		nregulators = AXP20X_REG_ID_MAX;
> +		config.descs = axp20x_regulators;
> +		config.nregulators = AXP20X_REG_ID_MAX;
>  	}
> +	config.matches = matches;
>  
>  	/*
>  	 * Reset matches table (this table might have been modified by a
>  	 * previous AXP2xx device probe).
>  	 */
> -	for (i = 0; i < nmatches; i++) {
> +	for (i = 0; i < config.nregulators; i++) {
>  		matches[i].init_data = NULL;
>  		matches[i].of_node = NULL;
>  	}
>  
> -	ret = axp20x_regulator_parse_dt(pdev, matches, nmatches);
> +	ret = axp20x_regulator_parse_dt(pdev, matches,
> +					config.nregulators);
>  	if (ret)
>  		return ret;
>  
> -	for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
> -		init_data = matches[i].init_data;
> +	rset = devm_regulator_set_register(&pdev->dev, &config);
> +	if (IS_ERR(rset))
> +		return PTR_ERR(rset);
>  
> -		config.dev = &pdev->dev;
> -		config.init_data = init_data;
> -		config.regmap = axp20x->regmap;
> -		config.of_node = matches[i].of_node;
> -
> -		rdev = devm_regulator_register(&pdev->dev, &regulators[i],
> -					       &config);
> -		if (IS_ERR(rdev)) {
> -			dev_err(&pdev->dev, "Failed to register %s\n",
> -				regulators[i].name);
> -
> -			return PTR_ERR(rdev);
> -		}
> -
> -		ret = of_property_read_u32(matches[i].of_node, "x-powers,dcdc-workmode",
> +	for (i = 0; i < rset->nregulators; i++) {
> +		ret = of_property_read_u32(config.matches[i].of_node,
> +					   "x-powers,dcdc-workmode",
>  					   &workmode);
> -		if (!ret) {
> -			if (axp20x_set_dcdc_workmode(rdev, i, workmode))
> -				dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> -					regulators[i].name);
> -		}
> +		if (!ret &&
> +		    axp20x_set_dcdc_workmode(rset->regulators[i], i, workmode))
> +			dev_err(&pdev->dev, "Failed to set workmode on %s\n",
> +				config.descs[i].name);
>  	}
>  
>  	return 0;
> -- 
> 1.8.3.2
> 

It looks like you're modifying code you just introduced. You should
probably move this patch earlier on, so that you don't have to patch
your patch.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-06-17 20:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17  7:38 [PATCH v4 0/7] mfd: axp20x: add AXP221 PMIC support Boris BREZILLON
2014-06-17  7:38 ` Boris BREZILLON
2014-06-17  7:38 ` Boris BREZILLON
2014-06-17  7:38 ` [PATCH v4 1/7] " Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-18  8:36   ` Lee Jones
2014-06-18  8:36     ` Lee Jones
2014-06-18  8:36     ` Lee Jones
2014-06-18  8:46     ` Boris BREZILLON
2014-06-18  8:46       ` Boris BREZILLON
2014-06-18  8:46       ` Boris BREZILLON
2014-06-18  9:28       ` Lee Jones
2014-06-18  9:28         ` Lee Jones
2014-06-18  9:28         ` Lee Jones
2014-06-17  7:38 ` [PATCH v4 2/7] regulator: axp20x: prepare support for multiple AXP chip families Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38 ` [PATCH v4 3/7] regulator: axp20x: add support for AXP221 regulators Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38 ` [PATCH v4 4/7] regulator: axp20x: reset probe data before each probe Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17 20:44   ` Maxime Ripard
2014-06-17 20:44     ` Maxime Ripard
2014-06-17 20:44     ` Maxime Ripard
2014-06-18  7:11     ` Boris BREZILLON
2014-06-18  7:11       ` Boris BREZILLON
2014-06-18  8:32       ` [linux-sunxi] " Hans de Goede
2014-06-18  8:32         ` Hans de Goede
2014-06-18  8:32         ` Hans de Goede
2014-06-18 12:44       ` Maxime Ripard
2014-06-18 12:44         ` Maxime Ripard
2014-06-18 12:44         ` Maxime Ripard
2014-06-17  7:38 ` [PATCH v4 5/7] regulator: add support for regulator set registration Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38 ` [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON
2014-06-17 20:46   ` Maxime Ripard [this message]
2014-06-17 20:46     ` Maxime Ripard
2014-06-17 20:46     ` Maxime Ripard
2014-06-18  7:12     ` Boris BREZILLON
2014-06-18  7:12       ` Boris BREZILLON
2014-06-17  7:38 ` [PATCH v4 7/7] mfd: AXP20x: add "x-powers, axp221" compatible string to DT bindings doc Boris BREZILLON
2014-06-17  7:38   ` [PATCH v4 7/7] mfd: AXP20x: add "x-powers,axp221" " Boris BREZILLON
2014-06-17  7:38   ` Boris BREZILLON

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140617204657.GE19730@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.