devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, Ben Dooks <ben-linux@fluff.org>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Russell King <linux@arm.linux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>
Subject: Re: [RFT v2 2/8] regulator: max77802: Remove support for board files
Date: Thu, 30 Oct 2014 08:49:56 +0100	[thread overview]
Message-ID: <1414655396.5114.10.camel@AMDC1943> (raw)
In-Reply-To: <54517B37.9010305@collabora.co.uk>

On czw, 2014-10-30 at 00:41 +0100, Javier Martinez Canillas wrote:
> Hello Krzysztof,
> 
> On 10/29/2014 04:06 PM, Krzysztof Kozlowski wrote:
> >  
> >  static int max77802_pmic_probe(struct platform_device *pdev)
> >  {
> >  	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> > -	struct max77686_platform_data *pdata = dev_get_platdata(iodev->dev);
> >  	struct max77802_regulator_prv *max77802;
> >  	int i, ret = 0, val;
> >  	struct regulator_config config = { };
> > -
> > -	/* This is allocated by the MFD driver */
> > -	if (!pdata) {
> > -		dev_err(&pdev->dev, "no platform data found for regulator\n");
> > -		return -ENODEV;
> > -	}
> > +	struct of_regulator_match *rdata;
> >  
> >  	max77802 = devm_kzalloc(&pdev->dev,
> >  				sizeof(struct max77802_regulator_prv),
> > @@ -586,24 +558,29 @@ static int max77802_pmic_probe(struct platform_device *pdev)
> >  	if (!max77802)
> >  		return -ENOMEM;
> >  
> > -	if (iodev->dev->of_node) {
> > -		ret = max77802_pmic_dt_parse_pdata(pdev, pdata);
> > -		if (ret)
> > -			return ret;
> > -	}
> > -
> >  	config.dev = iodev->dev;
> >  	config.regmap = iodev->regmap;
> >  	config.driver_data = max77802;
> >  	platform_set_drvdata(pdev, max77802);
> >  
> > +	rdata = kzalloc(sizeof(*rdata) * MAX77802_REG_MAX, GFP_KERNEL);
> > +	if (!rdata)
> > +		return -ENOMEM;
> > +
> > +	for (i = 0; i < MAX77802_REG_MAX; i++)
> > +		rdata[i].name = regulators[i].name;
> > +
> > +	ret = max77802_pmic_dt_parse(pdev, rdata);
> > +	if (ret)
> > +		goto out;
> > +
> >  	for (i = 0; i < MAX77802_REG_MAX; i++) {
> >  		struct regulator_dev *rdev;
> > -		int id = pdata->regulators[i].id;
> > +		int id = regulators[i].id;
> >  		int shift = max77802_get_opmode_shift(id);
> >  
> > -		config.init_data = pdata->regulators[i].initdata;
> > -		config.of_node = pdata->regulators[i].of_node;
> > +		config.init_data = rdata[i].init_data;
> > +		config.of_node = rdata[i].of_node;
> >  
> >  		ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val);
> >  		val = val >> shift & MAX77802_OPMODE_MASK;
> > @@ -621,13 +598,17 @@ static int max77802_pmic_probe(struct platform_device *pdev)
> >  		rdev = devm_regulator_register(&pdev->dev,
> >  					       &regulators[i], &config);
> 
> Thanks for your patch. It's indeed an improvement over the old code and I can
> test it tomorrow when I've access to my machine with a max77802 PMIC.
> 
> However, I don't think this is the change that Mark asked. AFAIU what he wanted
> is to fill the struct regulator_desc .of_match and .regulators_node fields so
> the init_data is extracted by the core on regulator registration.
> 
> Look at commits a0c7b164 ("regulator: of: Provide simplified DT parsing method")
> and 93a127b ("regulator: isl9305: Convert to new style DT parsing") to see what
> I'm talking about.

Ooo, I missed these changes. This should simplify the code even more.
I'll re-spin, so don't hurry with testing :)

Best regards,
Krzysztof

  reply	other threads:[~2014-10-30  7:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 15:06 [PATCH v2 0/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 1/8] regulator: max77686: Consistently index opmode array by rdev id Krzysztof Kozlowski
2014-10-29 15:06 ` [RFT v2 2/8] regulator: max77802: Remove support for board files Krzysztof Kozlowski
2014-10-29 23:41   ` Javier Martinez Canillas
2014-10-30  7:49     ` Krzysztof Kozlowski [this message]
2014-10-29 15:06 ` [PATCH v2 3/8] regulator: max77686: " Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 4/8] mfd: max77686/802: " Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 5/8] regulator: max77686: Initialize opmode explicitly to normal mode Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 6/8] regulator: max77686: Add GPIO control Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 7/8] mfd/regulator: dt-bindings: max77686: Document gpio property Krzysztof Kozlowski
2014-10-29 15:06 ` [PATCH v2 8/8] ARM: dts: exynos4412-trats: Switch max77686 regulators to GPIO control Krzysztof Kozlowski

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=1414655396.5114.10.camel@AMDC1943 \
    --to=k.kozlowski@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=ben-linux@fluff.org \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=javier.martinez@collabora.co.uk \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=sameo@linux.intel.com \
    /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).