From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Support Opensource <support.opensource@diasemi.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Subject: [PATCH 17/17] regulator: max77650: Use container_of and constify static data
Date: Mon, 09 Sep 2024 15:51:28 +0200 [thread overview]
Message-ID: <20240909-regulator-const-v1-17-8934704a5787@linaro.org> (raw)
In-Reply-To: <20240909-regulator-const-v1-0-8934704a5787@linaro.org>
Switch from rdev_get_drvdata() to container_of(), so the static
'struct max77650_regulator_desc' holding 'struct regulator_desc' can
be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
[RFT]: Not tested, only built.
---
drivers/regulator/max77650-regulator.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/regulator/max77650-regulator.c b/drivers/regulator/max77650-regulator.c
index 94abfbb2bc1e..7368f54f046d 100644
--- a/drivers/regulator/max77650-regulator.c
+++ b/drivers/regulator/max77650-regulator.c
@@ -43,8 +43,6 @@ struct max77650_regulator_desc {
unsigned int regB;
};
-static struct max77650_regulator_desc max77651_SBB1_desc;
-
static const unsigned int max77651_sbb1_volt_range_sel[] = {
0x0, 0x1, 0x2, 0x3
};
@@ -66,11 +64,11 @@ static const unsigned int max77650_current_limit_table[] = {
static int max77650_regulator_is_enabled(struct regulator_dev *rdev)
{
- struct max77650_regulator_desc *rdesc;
+ const struct max77650_regulator_desc *rdesc;
struct regmap *map;
int val, rv, en;
- rdesc = rdev_get_drvdata(rdev);
+ rdesc = container_of(rdev->desc, struct max77650_regulator_desc, desc);
map = rdev_get_regmap(rdev);
rv = regmap_read(map, rdesc->regB, &val);
@@ -84,10 +82,10 @@ static int max77650_regulator_is_enabled(struct regulator_dev *rdev)
static int max77650_regulator_enable(struct regulator_dev *rdev)
{
- struct max77650_regulator_desc *rdesc;
+ const struct max77650_regulator_desc *rdesc;
struct regmap *map;
- rdesc = rdev_get_drvdata(rdev);
+ rdesc = container_of(rdev->desc, struct max77650_regulator_desc, desc);
map = rdev_get_regmap(rdev);
return regmap_update_bits(map, rdesc->regB,
@@ -97,10 +95,10 @@ static int max77650_regulator_enable(struct regulator_dev *rdev)
static int max77650_regulator_disable(struct regulator_dev *rdev)
{
- struct max77650_regulator_desc *rdesc;
+ const struct max77650_regulator_desc *rdesc;
struct regmap *map;
- rdesc = rdev_get_drvdata(rdev);
+ rdesc = container_of(rdev->desc, struct max77650_regulator_desc, desc);
map = rdev_get_regmap(rdev);
return regmap_update_bits(map, rdesc->regB,
@@ -145,7 +143,7 @@ static const struct regulator_ops max77651_SBB1_regulator_ops = {
.set_active_discharge = regulator_set_active_discharge_regmap,
};
-static struct max77650_regulator_desc max77650_LDO_desc = {
+static const struct max77650_regulator_desc max77650_LDO_desc = {
.desc = {
.name = "ldo",
.of_match = of_match_ptr("ldo"),
@@ -171,7 +169,7 @@ static struct max77650_regulator_desc max77650_LDO_desc = {
.regB = MAX77650_REG_CNFG_LDO_B,
};
-static struct max77650_regulator_desc max77650_SBB0_desc = {
+static const struct max77650_regulator_desc max77650_SBB0_desc = {
.desc = {
.name = "sbb0",
.of_match = of_match_ptr("sbb0"),
@@ -201,7 +199,7 @@ static struct max77650_regulator_desc max77650_SBB0_desc = {
.regB = MAX77650_REG_CNFG_SBB0_B,
};
-static struct max77650_regulator_desc max77650_SBB1_desc = {
+static const struct max77650_regulator_desc max77650_SBB1_desc = {
.desc = {
.name = "sbb1",
.of_match = of_match_ptr("sbb1"),
@@ -231,7 +229,7 @@ static struct max77650_regulator_desc max77650_SBB1_desc = {
.regB = MAX77650_REG_CNFG_SBB1_B,
};
-static struct max77650_regulator_desc max77651_SBB1_desc = {
+static const struct max77650_regulator_desc max77651_SBB1_desc = {
.desc = {
.name = "sbb1",
.of_match = of_match_ptr("sbb1"),
@@ -264,7 +262,7 @@ static struct max77650_regulator_desc max77651_SBB1_desc = {
.regB = MAX77650_REG_CNFG_SBB1_B,
};
-static struct max77650_regulator_desc max77650_SBB2_desc = {
+static const struct max77650_regulator_desc max77650_SBB2_desc = {
.desc = {
.name = "sbb2",
.of_match = of_match_ptr("sbb2"),
@@ -294,7 +292,7 @@ static struct max77650_regulator_desc max77650_SBB2_desc = {
.regB = MAX77650_REG_CNFG_SBB2_B,
};
-static struct max77650_regulator_desc max77651_SBB2_desc = {
+static const struct max77650_regulator_desc max77651_SBB2_desc = {
.desc = {
.name = "sbb2",
.of_match = of_match_ptr("sbb2"),
@@ -326,8 +324,8 @@ static struct max77650_regulator_desc max77651_SBB2_desc = {
static int max77650_regulator_probe(struct platform_device *pdev)
{
- struct max77650_regulator_desc **rdescs;
- struct max77650_regulator_desc *rdesc;
+ const struct max77650_regulator_desc **rdescs;
+ const struct max77650_regulator_desc *rdesc;
struct regulator_config config = { };
struct device *dev, *parent;
struct regulator_dev *rdev;
@@ -376,7 +374,6 @@ static int max77650_regulator_probe(struct platform_device *pdev)
for (i = 0; i < MAX77650_REGULATOR_NUM_REGULATORS; i++) {
rdesc = rdescs[i];
- config.driver_data = rdesc;
rdev = devm_regulator_register(dev, &rdesc->desc, &config);
if (IS_ERR(rdev))
--
2.43.0
next prev parent reply other threads:[~2024-09-09 13:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 13:51 [PATCH 00/17] regulator: Few constifications of " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 01/17] regulator: da9052: Constify " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 02/17] regulator: da9055: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 03/17] regulator: da9063: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 04/17] regulator: da9121: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 05/17] regulator: da9211: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 06/17] regulator: hi6421: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 07/17] regulator: hi6421v600: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 08/17] regulator: tps65023: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 09/17] regulator: max77826: Drop unused 'rdesc' in 'struct max77826_regulator_info' Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 10/17] regulator: max77826: Constify static data Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 11/17] regulator: mtk-dvfsrc: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 12/17] regulator: pcap: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 13/17] regulator: pfuze100: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 14/17] regulator: qcom-refgen: " Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 15/17] regulator: hi6421v530: Drop unused 'eco_microamp' Krzysztof Kozlowski
2024-09-09 13:51 ` [PATCH 16/17] regulator: hi6421v530: Use container_of and constify static data Krzysztof Kozlowski
2024-09-09 13:51 ` Krzysztof Kozlowski [this message]
2024-09-11 11:16 ` [PATCH 00/17] regulator: Few constifications of " Mark Brown
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=20240909-regulator-const-v1-17-8934704a5787@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=support.opensource@diasemi.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
all inboxes | Powered by JetHome®