From: k.kozlowski@samsung.com (Krzysztof Kozlowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/5] regulator: max14577: Add regulator driver for Maxim 14577
Date: Fri, 22 Nov 2013 16:55:48 +0100 [thread overview]
Message-ID: <1385135748.27216.1.camel@AMDC1943> (raw)
In-Reply-To: <20131122101551.GJ23067@lee--X1>
On Fri, 2013-11-22 at 10:15 +0000, Lee Jones wrote:
> > +#ifdef CONFIG_OF
> > +static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
> > + struct max14577_platform_data *pdata)
> > +{
> > + struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
> > + struct device_node *np;
> > + struct max14577_regulator_platform_data *reg_pdata;
> > + struct of_regulator_match rmatch;
> > + int i, ret;
> > +
> > + np = of_get_child_by_name(max14577->dev->of_node, "regulators");
> > + if (!np)
> > + return -EINVAL;
>
> No need to do this. If instead you use a compatible string and set
> it's MFD cell's .of_compatible property, the MFD core will set
> pdev->dev.of_node for you.
>
> > + reg_pdata = devm_kzalloc(&pdev->dev, sizeof(*reg_pdata) *
> > + ARRAY_SIZE(supported_regulators), GFP_KERNEL);
> > + if (!reg_pdata)
> > + return -ENOMEM;
> > +
> > + for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
> > + rmatch.name = supported_regulators[i].name;
> > + ret = of_regulator_match(&pdev->dev, np, &rmatch, 1);
> > + if (ret != 1)
> > + continue;
> > + dev_dbg(&pdev->dev, "Found regulator %d/%s\n",
> > + supported_regulators[i].id,
> > + supported_regulators[i].name);
> > + reg_pdata[i].id = supported_regulators[i].id;
> > + reg_pdata[i].initdata = rmatch.init_data;
> > + reg_pdata[i].of_node = rmatch.of_node;
> > + }
> > +
> > + pdata->regulators = reg_pdata;
> > +
> > + return 0;
> > +}
> > +#else
> > +static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
> > + struct max14577_platform_data *pdata)
> > +{
> > + return 0;
> > +}
> > +#endif
>
> No need for this either. Just check for the device's of_node.
>
> > +static int max14577_regulator_probe(struct platform_device *pdev)
> > +{
> > + struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
> > + struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev);
> > + int i, size;
> > + struct regulator_config config = {};
> > + struct regulator_dev **regulators;
> > +
> > + if (!pdata) {
> > + /* Parent must provide pdata */
> > + dev_err(&pdev->dev, "No MFD driver platform data found.\n");
> > + return -ENODEV;
> > + }
> > +
> > + if (max14577->dev->of_node) {
> > + int ret = max14577_regulator_dt_parse_pdata(pdev, pdata);
>
> This will overwrite pdata which is wrong.
>
> pdata should always take precedence over DT.
>
> <snip>
>
> > + for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
> > + /*
> > + * Index of supported_regulators[] is also the id and must
> > + * match index of pdata->regulators[].
> > + */
> > + config.init_data = pdata->regulators[i].initdata;
> > + config.of_node = pdata->regulators[i].of_node;
>
> I still thing this is superfluous. Why don't you run though the nodes
> here instead of doing it in MFD and passing this stuff through?
I have rewritten the regulator init code (and DT parsing). I think it
reflects your comments. Please look at version 4 of patches.
Best regards,
Krzysztof
WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Samuel Ortiz <sameo@linux.intel.com>,
Anton Vorontsov <anton@enomsg.org>,
David Woodhouse <dwmw2@infradead.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Rob Herring <rob.herring@calxeda.com>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
Pawel Moll <pawel.moll@arm.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Rob Landley <rob@landley.net>,
linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH v3 4/5] regulator: max14577: Add regulator driver for Maxim 14577
Date: Fri, 22 Nov 2013 16:55:48 +0100 [thread overview]
Message-ID: <1385135748.27216.1.camel@AMDC1943> (raw)
In-Reply-To: <20131122101551.GJ23067@lee--X1>
On Fri, 2013-11-22 at 10:15 +0000, Lee Jones wrote:
> > +#ifdef CONFIG_OF
> > +static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
> > + struct max14577_platform_data *pdata)
> > +{
> > + struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
> > + struct device_node *np;
> > + struct max14577_regulator_platform_data *reg_pdata;
> > + struct of_regulator_match rmatch;
> > + int i, ret;
> > +
> > + np = of_get_child_by_name(max14577->dev->of_node, "regulators");
> > + if (!np)
> > + return -EINVAL;
>
> No need to do this. If instead you use a compatible string and set
> it's MFD cell's .of_compatible property, the MFD core will set
> pdev->dev.of_node for you.
>
> > + reg_pdata = devm_kzalloc(&pdev->dev, sizeof(*reg_pdata) *
> > + ARRAY_SIZE(supported_regulators), GFP_KERNEL);
> > + if (!reg_pdata)
> > + return -ENOMEM;
> > +
> > + for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
> > + rmatch.name = supported_regulators[i].name;
> > + ret = of_regulator_match(&pdev->dev, np, &rmatch, 1);
> > + if (ret != 1)
> > + continue;
> > + dev_dbg(&pdev->dev, "Found regulator %d/%s\n",
> > + supported_regulators[i].id,
> > + supported_regulators[i].name);
> > + reg_pdata[i].id = supported_regulators[i].id;
> > + reg_pdata[i].initdata = rmatch.init_data;
> > + reg_pdata[i].of_node = rmatch.of_node;
> > + }
> > +
> > + pdata->regulators = reg_pdata;
> > +
> > + return 0;
> > +}
> > +#else
> > +static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev,
> > + struct max14577_platform_data *pdata)
> > +{
> > + return 0;
> > +}
> > +#endif
>
> No need for this either. Just check for the device's of_node.
>
> > +static int max14577_regulator_probe(struct platform_device *pdev)
> > +{
> > + struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent);
> > + struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev);
> > + int i, size;
> > + struct regulator_config config = {};
> > + struct regulator_dev **regulators;
> > +
> > + if (!pdata) {
> > + /* Parent must provide pdata */
> > + dev_err(&pdev->dev, "No MFD driver platform data found.\n");
> > + return -ENODEV;
> > + }
> > +
> > + if (max14577->dev->of_node) {
> > + int ret = max14577_regulator_dt_parse_pdata(pdev, pdata);
>
> This will overwrite pdata which is wrong.
>
> pdata should always take precedence over DT.
>
> <snip>
>
> > + for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) {
> > + /*
> > + * Index of supported_regulators[] is also the id and must
> > + * match index of pdata->regulators[].
> > + */
> > + config.init_data = pdata->regulators[i].initdata;
> > + config.of_node = pdata->regulators[i].of_node;
>
> I still thing this is superfluous. Why don't you run though the nodes
> here instead of doing it in MFD and passing this stuff through?
I have rewritten the regulator init code (and DT parsing). I think it
reflects your comments. Please look at version 4 of patches.
Best regards,
Krzysztof
next prev parent reply other threads:[~2013-11-22 15:55 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 8:46 [PATCH v3 0/5] mfd: max14577: Add max14577 MFD drivers Krzysztof Kozlowski
2013-11-22 8:46 ` Krzysztof Kozlowski
2013-11-22 8:46 ` [PATCH v3 1/5] mfd: max14577: Add max14577 MFD driver core Krzysztof Kozlowski
2013-11-22 8:46 ` Krzysztof Kozlowski
2013-11-22 9:31 ` Lee Jones
2013-11-22 9:31 ` Lee Jones
2013-11-22 9:58 ` Krzysztof Kozlowski
2013-11-22 9:58 ` Krzysztof Kozlowski
2013-11-22 10:07 ` Lee Jones
2013-11-22 10:07 ` Lee Jones
2013-11-22 10:36 ` Mark Brown
2013-11-22 10:36 ` Mark Brown
2013-11-22 8:46 ` [PATCH v3 2/5] extcon: max14577: Add extcon-max14577 driver to support MUIC device Krzysztof Kozlowski
2013-11-22 8:46 ` Krzysztof Kozlowski
2013-11-22 10:35 ` Mark Brown
2013-11-22 10:35 ` Mark Brown
2013-11-22 11:34 ` Krzysztof Kozlowski
2013-11-22 11:34 ` Krzysztof Kozlowski
2013-11-22 8:46 ` [PATCH v3 3/5] charger: max14577: Add charger support for Maxim 14577 Krzysztof Kozlowski
2013-11-22 8:46 ` Krzysztof Kozlowski
2013-11-22 8:54 ` Alexander Shiyan
2013-11-22 8:54 ` Alexander Shiyan
2013-11-22 9:57 ` Krzysztof Kozlowski
2013-11-22 9:57 ` Krzysztof Kozlowski
2013-11-22 8:46 ` [PATCH v3 4/5] regulator: max14577: Add regulator driver " Krzysztof Kozlowski
2013-11-22 8:46 ` Krzysztof Kozlowski
2013-11-22 9:16 ` Lee Jones
2013-11-22 9:16 ` Lee Jones
2013-11-22 9:23 ` Krzysztof Kozlowski
2013-11-22 9:23 ` Krzysztof Kozlowski
2013-11-22 10:15 ` Lee Jones
2013-11-22 10:15 ` Lee Jones
2013-11-22 15:55 ` Krzysztof Kozlowski [this message]
2013-11-22 15:55 ` Krzysztof Kozlowski
2013-11-22 13:00 ` Bartlomiej Zolnierkiewicz
2013-11-22 13:00 ` Bartlomiej Zolnierkiewicz
2013-11-22 8:46 ` [PATCH v3 5/5] mfd: max14577: Add device tree bindings document Krzysztof Kozlowski
2013-11-22 8:46 ` 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=1385135748.27216.1.camel@AMDC1943 \
--to=k.kozlowski@samsung.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.