mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: patches@opensource.cirrus.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/5] regulator: arizona: always parse device tree properties
Date: Mon, 30 Nov 2026 21:58:36 -0800	[thread overview]
Message-ID: <20261130-arizona-regulator-v1-2-727bc83b897c@gmail.com> (raw)
In-Reply-To: <20261130-arizona-regulator-v1-0-727bc83b897c@gmail.com>

Always invoke Device Tree parsing for Arizona LDO1 and MICVDD
regulators even when parent platform data is present, allowing DT
properties to configure regulators without requiring platform data to be
absent.

Short-circuit early inside the OF parsing helpers when the parent
device has no OF node so non-DT platforms skip OF lookups while still
registering the regulators with default init_data, and CONFIG_OF=n
builds fold the helpers away cleanly without an explicit CONFIG_OF guard
at the call sites.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/regulator/arizona-ldo1.c    | 18 ++++++++----------
 drivers/regulator/arizona-micsupp.c | 19 +++++++++----------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index f8e1d9eb82c7..73abdf344a95 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -191,10 +191,14 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
 				     bool *external_dcvdd)
 {
 	struct arizona_ldo1 *ldo1 = config->driver_data;
-	struct device_node *np = config->dev->of_node;
+	struct device_node *np;
 	struct device_node *init_node, *dcvdd_node;
 	struct regulator_init_data *init_data;
 
+	np = dev_of_node(config->dev);
+	if (!np)
+		return 0;
+
 	init_node = of_get_child_by_name(np, "ldo1");
 	dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0);
 
@@ -241,15 +245,9 @@ static int arizona_ldo1_common_init(struct platform_device *pdev,
 	config.driver_data = ldo1;
 	config.regmap = ldo1->regmap;
 
-	if (IS_ENABLED(CONFIG_OF)) {
-		if (!dev_get_platdata(parent_dev)) {
-			ret = arizona_ldo1_of_get_pdata(pdata,
-							&config, desc,
-							external_dcvdd);
-			if (ret < 0)
-				return ret;
-		}
-	}
+	ret = arizona_ldo1_of_get_pdata(pdata, &config, desc, external_dcvdd);
+	if (ret < 0)
+		return ret;
 
 	/* We assume that high output = regulator off
 	 * Don't use devm, since we need to get against the parent device
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 09a3cdd8aaea..c8ff49e44427 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -227,10 +227,14 @@ static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
 					const struct regulator_desc *desc)
 {
 	struct arizona_micsupp *micsupp = config->driver_data;
-	struct device_node *np;
+	struct device_node *parent_np, *np;
 	struct regulator_init_data *init_data;
 
-	np = of_get_child_by_name(config->dev->of_node, "micvdd");
+	parent_np = dev_of_node(config->dev);
+	if (!parent_np)
+		return 0;
+
+	np = of_get_child_by_name(parent_np, "micvdd");
 
 	if (np) {
 		config->of_node = np;
@@ -269,14 +273,9 @@ static int arizona_micsupp_common_init(struct platform_device *pdev,
 	config.driver_data = micsupp;
 	config.regmap = micsupp->regmap;
 
-	if (IS_ENABLED(CONFIG_OF)) {
-		if (!dev_get_platdata(micsupp->dev)) {
-			ret = arizona_micsupp_of_get_pdata(pdata, &config,
-							   desc);
-			if (ret < 0)
-				return ret;
-		}
-	}
+	ret = arizona_micsupp_of_get_pdata(pdata, &config, desc);
+	if (ret < 0)
+		return ret;
 
 	if (pdata->init_data)
 		config.init_data = pdata->init_data;

-- 
2.56.1.911.g883d8bcb20-goog


  parent reply	other threads:[~2026-12-01  5:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  5:58 [PATCH 0/5] regulator: arizona: clean up Device Tree and platform data handling Dmitry Torokhov
2026-12-01  5:58 ` [PATCH 1/5] regulator: arizona-ldo1: fix OF node leak on enable GPIO error Dmitry Torokhov
2026-12-01  5:58 ` Dmitry Torokhov [this message]
2026-12-01  5:58 ` [PATCH 3/5] regulator: arizona: stop using platform data for init_data Dmitry Torokhov
2026-12-01  5:58 ` [PATCH 4/5] regulator: arizona: simplify Device Tree property parsing Dmitry Torokhov
2026-12-01  5:58 ` [PATCH 5/5] regulator: arizona-ldo1: clean up coding style Dmitry Torokhov

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=20261130-arizona-regulator-v1-2-727bc83b897c@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.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®