From: vaibhav.hiremath@linaro.org (Vaibhav Hiremath)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] regulator: 88pm800: Update driver to use devm_regulator_register fn
Date: Thu, 16 Jul 2015 23:46:55 +0530 [thread overview]
Message-ID: <1437070618-21330-3-git-send-email-vaibhav.hiremath@linaro.org> (raw)
In-Reply-To: <1437070618-21330-1-git-send-email-vaibhav.hiremath@linaro.org>
This patch replaces standard regulator_register with
devm_regulator_register() fn, as using devm_regulator_register() fn
simplifies the driver return/exit path.
As part of this update, patch also cleanups up all unnecessary changes
which is result of this patch -
- Remove _remove() fn, as devm_ variant takes care of it.
- Remove pm800_regulators.regulators[] field, as it was only
needed during cleanup, so we no longer need this.
This also saved some amount of memory.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
---
drivers/regulator/88pm800.c | 27 ++++++---------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index 11f7ab2..3b37170 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -78,7 +78,6 @@ struct pm800_regulator_info {
};
struct pm800_regulators {
- struct regulator_dev *regulators[PM800_ID_RG_MAX];
struct pm80x_chip *chip;
struct regmap *map;
};
@@ -318,6 +317,8 @@ static int pm800_regulator_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pm800_data);
for (i = 0; i < PM800_ID_RG_MAX; i++) {
+ struct regulator_dev *regulator;
+
if (!pdata || pdata->num_regulators == 0)
init_data = pm800_regulator_matches[i].init_data;
else
@@ -331,16 +332,12 @@ static int pm800_regulator_probe(struct platform_device *pdev)
config.regmap = pm800_data->map;
config.of_node = pm800_regulator_matches[i].of_node;
- pm800_data->regulators[i] =
- regulator_register(&info->desc, &config);
- if (IS_ERR(pm800_data->regulators[i])) {
- ret = PTR_ERR(pm800_data->regulators[i]);
+ regulator = devm_regulator_register(&pdev->dev,
+ &info->desc, &config);
+ if (IS_ERR(regulator)) {
+ ret = PTR_ERR(regulator);
dev_err(&pdev->dev, "Failed to register %s\n",
info->desc.name);
-
- while (--i >= 0)
- regulator_unregister(pm800_data->regulators[i]);
-
return ret;
}
}
@@ -348,23 +345,11 @@ static int pm800_regulator_probe(struct platform_device *pdev)
return 0;
}
-static int pm800_regulator_remove(struct platform_device *pdev)
-{
- struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
- int i;
-
- for (i = 0; i < PM800_ID_RG_MAX; i++)
- regulator_unregister(pm800_data->regulators[i]);
-
- return 0;
-}
-
static struct platform_driver pm800_regulator_driver = {
.driver = {
.name = "88pm80x-regulator",
},
.probe = pm800_regulator_probe,
- .remove = pm800_regulator_remove,
};
module_platform_driver(pm800_regulator_driver);
--
1.9.1
next prev parent reply other threads:[~2015-07-16 18:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 18:16 [PATCH 0/5] regulator: 88pm800: Add 88pm860 regulator support Vaibhav Hiremath
2015-07-16 18:16 ` [PATCH 1/5] regulator: 88pm800: Fix indentation of assignments of data structures Vaibhav Hiremath
2015-07-16 18:16 ` Vaibhav Hiremath [this message]
2015-07-16 18:16 ` [PATCH 3/5] regulator: 88pm800: Use regulator_nodes/of_match in the descriptor Vaibhav Hiremath
2015-07-16 18:16 ` [PATCH 4/5] regulator: 88pm800: Add 88pm860 regulator support Vaibhav Hiremath
2015-07-16 21:34 ` Mark Brown
2015-07-17 5:42 ` Vaibhav Hiremath
2015-07-17 11:17 ` Mark Brown
2015-07-17 12:43 ` Vaibhav Hiremath
2015-07-20 7:30 ` Lee Jones
2015-07-20 12:01 ` Vaibhav Hiremath
2015-07-21 9:21 ` Lee Jones
2015-07-21 11:15 ` Vaibhav Hiremath
2015-07-21 15:13 ` Lee Jones
2015-07-21 15:19 ` Vaibhav Hiremath
2015-07-21 15:55 ` Lee Jones
2015-07-16 18:16 ` [PATCH 5/5] regulator: 88pm800: Add support for configuration of dual phase on BUCK1 Vaibhav Hiremath
2015-07-16 20:32 ` Mark Brown
2015-07-17 5:38 ` Vaibhav Hiremath
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=1437070618-21330-3-git-send-email-vaibhav.hiremath@linaro.org \
--to=vaibhav.hiremath@linaro.org \
--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 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).