From: boris.brezillon@free-electrons•com (Boris BREZILLON)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register
Date: Wed, 18 Jun 2014 09:12:54 +0200 [thread overview]
Message-ID: <53A13BF6.5010305@free-electrons.com> (raw)
In-Reply-To: <20140617204657.GE19730@lukather>
On 17/06/2014 22:46, Maxime Ripard wrote:
> 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, ®ulators[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.
Okay, I'll switch patch 5 and 6.
> Maxime
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
next prev parent reply other threads:[~2014-06-18 7:12 UTC|newest]
Thread overview: 17+ 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 ` [PATCH v4 1/7] " Boris BREZILLON
2014-06-18 8:36 ` Lee Jones
2014-06-18 8:46 ` Boris BREZILLON
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 ` [PATCH v4 3/7] regulator: axp20x: add support for AXP221 regulators Boris BREZILLON
2014-06-17 7:38 ` [PATCH v4 4/7] regulator: axp20x: reset probe data before each probe Boris BREZILLON
2014-06-17 20:44 ` Maxime Ripard
2014-06-18 7:11 ` Boris BREZILLON
2014-06-18 8:32 ` [linux-sunxi] " Hans de Goede
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 ` [PATCH v4 6/7] regulator: axp20x: make use of devm_regulator_set_register Boris BREZILLON
2014-06-17 20:46 ` Maxime Ripard
2014-06-18 7:12 ` Boris BREZILLON [this message]
2014-06-17 7:38 ` [PATCH v4 7/7] mfd: AXP20x: add "x-powers, axp221" compatible string to DT bindings doc 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=53A13BF6.5010305@free-electrons.com \
--to=boris.brezillon@free-electrons$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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