From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>,
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,
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 14:00:44 +0100 [thread overview]
Message-ID: <5314519.ORHTDE3qkF@amdc1032> (raw)
In-Reply-To: <1385109972-28059-5-git-send-email-k.kozlowski@samsung.com>
Hi,
On Friday, November 22, 2013 09:46:11 AM Krzysztof Kozlowski wrote:
[...]
> +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);
> + if (ret)
> + return ret;
> + }
> +
> + size = sizeof(struct regulator_dev *) * ARRAY_SIZE(supported_regulators);
> + regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
> + if (!regulators) {
> + dev_err(&pdev->dev, "Cannot allocate memory for regulators\n");
> + return -ENOMEM;
> + }
> +
> + config.dev = &pdev->dev;
> + config.regmap = max14577->regmap;
> +
> + 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;
> +
> + regulators[i] = devm_regulator_register(&pdev->dev,
> + &supported_regulators[i], &config);
> + if (IS_ERR(regulators[i])) {
> + int ret = PTR_ERR(regulators[i]);
This can be cleaned up further. The code just needs a single "struct
regulator_dev *regulator" (which can be declared inside "for" loop)
instead of an array.
> + dev_err(&pdev->dev,
> + "Regulator init failed for ID %d with error: %d\n",
> + i, ret);
> + return ret;
> + }
> + }
> +
> + return 0;
> +}
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2013-11-22 13:00 UTC|newest]
Thread overview: 19+ 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 ` [PATCH v3 1/5] mfd: max14577: Add max14577 MFD driver core Krzysztof Kozlowski
2013-11-22 9:31 ` Lee Jones
2013-11-22 9:58 ` Krzysztof Kozlowski
2013-11-22 10:07 ` Lee Jones
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 10:35 ` Mark Brown
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:54 ` Alexander Shiyan
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 9:16 ` Lee Jones
2013-11-22 9:23 ` Krzysztof Kozlowski
2013-11-22 10:15 ` Lee Jones
2013-11-22 15:55 ` Krzysztof Kozlowski
2013-11-22 13:00 ` Bartlomiej Zolnierkiewicz [this message]
2013-11-22 8:46 ` [PATCH v3 5/5] mfd: max14577: Add device tree bindings document 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=5314519.ORHTDE3qkF@amdc1032 \
--to=b.zolnierkie@samsung.com \
--cc=anton@enomsg.org \
--cc=broonie@kernel.org \
--cc=cw00.choi@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=k.kozlowski@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-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=myungjoo.ham@samsung.com \
--cc=pawel.moll@arm.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=sameo@linux.intel.com \
--cc=swarren@wwwdotorg.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).