linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Porter <mporter@linaro.org>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@kernel.org>,
	Tim Kryger <tim.kryger@linaro.org>,
	Markus Mayer <markus.mayer@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] regulator: bcm590xx: Use array to save desc and *info
Date: Thu, 20 Mar 2014 11:42:57 -0400	[thread overview]
Message-ID: <20140320154257.GL25092@beef> (raw)
In-Reply-To: <1394762428.8460.5.camel@phoenix>

On Fri, Mar 14, 2014 at 10:00:28AM +0800, Axel Lin wrote:
> BCM590XX_NUM_REGS is known in compile time.
> Use array to save desc and *info makes the code simpler.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Well, ok. It was coded for dynamic allocation because I'm starting to
work on BCM59054 support, which is similar but different. The actual
regulators are different but, due to luck, the total number is the
same between 59056 and 59054...so this can still work for the moment.
However, another 590xx part does have a different number of regulators
so I'm not sure this is worth doing when we know we'll go back to
dynamic allocation in the future.

-Matt

> ---
>  drivers/regulator/bcm590xx-regulator.c | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c
> index ab08ca7..fe21855 100644
> --- a/drivers/regulator/bcm590xx-regulator.c
> +++ b/drivers/regulator/bcm590xx-regulator.c
> @@ -151,9 +151,9 @@ static struct bcm590xx_info bcm590xx_regs[] = {
>  };
>  
>  struct bcm590xx_reg {
> -	struct regulator_desc *desc;
> +	struct regulator_desc desc[BCM590XX_NUM_REGS];
>  	struct bcm590xx *mfd;
> -	struct bcm590xx_info **info;
> +	struct bcm590xx_info *info[BCM590XX_NUM_REGS];
>  };
>  
>  static int bcm590xx_get_vsel_register(int id)
> @@ -319,20 +319,6 @@ static int bcm590xx_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, pmu);
>  
> -	pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
> -			sizeof(struct regulator_desc), GFP_KERNEL);
> -	if (!pmu->desc) {
> -		dev_err(&pdev->dev, "Memory alloc fails for desc\n");
> -		return -ENOMEM;
> -	}
> -
> -	pmu->info = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
> -			sizeof(struct bcm590xx_info *), GFP_KERNEL);
> -	if (!pmu->info) {
> -		dev_err(&pdev->dev, "Memory alloc fails for info\n");
> -		return -ENOMEM;
> -	}
> -
>  	info = bcm590xx_regs;
>  
>  	for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) {
> -- 
> 1.8.1.2
> 
> 
> 

  reply	other threads:[~2014-03-20 15:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-14  1:57 [PATCH 1/3] regulator: bcm590xx: Make the modalias matches the driver name Axel Lin
2014-03-14  1:59 ` [PATCH 2/3] regulator: bcm590xx: Remove **rdev from struct bcm590xx_reg Axel Lin
2014-03-20 15:21   ` Matt Porter
2014-03-21 18:10   ` Mark Brown
2014-03-14  2:00 ` [PATCH 3/3] regulator: bcm590xx: Use array to save desc and *info Axel Lin
2014-03-20 15:42   ` Matt Porter [this message]
2014-03-21  0:58     ` Axel Lin
2014-03-21 18:09 ` [PATCH 1/3] regulator: bcm590xx: Make the modalias matches the driver name Mark Brown

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=20140320154257.GL25092@beef \
    --to=mporter@linaro.org \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.mayer@linaro.org \
    --cc=tim.kryger@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).