mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org
Cc: broonie@kernel.org, cristian.marussi@arm.com
Subject: [PATCH] regulator: core: add of_match_full_name boolean flag
Date: Wed, 19 Aug 2020 15:04:48 +0100	[thread overview]
Message-ID: <20200819140448.51373-1-cristian.marussi@arm.com> (raw)

When an .of_match non-null string is defined in struct regulator_desc, the
regulator core searches for regulators trying to match, at first, such
string against the 'regulator-compatible' property and then falls back to
use the name of the node itself.

Property 'regulator-compatible' is now deprecated (even if still widely
used in the code base), and the node-name fallback works fine only as long
as the nodes are named in an unique way; if it makes sense to use a common
name and identifying them using an index through a 'reg' property the
standard advices to use a naming in the form <common-name>@<unit>.

In this case the above matching mechanism based on the simple (common) name
will fail and the only viable alternative would be to properly define the
deprecrated 'regulator-compatible' property equal to the full name
<common-name>@<unit>.

In order to address this case without using such deprecated property,
define a new boolean flag .of_match_full_name in struct regulator_desc to
force the core to match against the node full-name instead.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 drivers/regulator/of_regulator.c | 3 ++-
 include/linux/regulator/driver.h | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 06c0b15fe4c0..f60cb0093b40 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -414,7 +414,8 @@ device_node *regulator_of_get_init_node(struct device *dev,
 	for_each_available_child_of_node(search, child) {
 		name = of_get_property(child, "regulator-compatible", NULL);
 		if (!name)
-			name = child->name;
+			name = !desc->of_match_full_name ?
+				child->name : child->full_name;
 
 		if (!strcmp(desc->of_match, name)) {
 			of_node_put(search);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 8539f34ae42b..5d9b011fcef6 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -223,6 +223,8 @@ enum regulator_type {
  * @name: Identifying name for the regulator.
  * @supply_name: Identifying the regulator supply
  * @of_match: Name used to identify regulator in DT.
+ * @of_match_full_name: A flag to indicate that the of_match string, if
+ *			present, should be matched against the node full_name.
  * @regulators_node: Name of node containing regulator definitions in DT.
  * @of_parse_cb: Optional callback called only if of_match is present.
  *               Will be called for each regulator parsed from DT, during
@@ -314,6 +316,7 @@ struct regulator_desc {
 	const char *name;
 	const char *supply_name;
 	const char *of_match;
+	bool of_match_full_name;
 	const char *regulators_node;
 	int (*of_parse_cb)(struct device_node *,
 			    const struct regulator_desc *,
-- 
2.17.1


             reply	other threads:[~2020-08-19 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 14:04 Cristian Marussi [this message]
2020-08-19 18:22 ` Mark Brown
2020-08-20 16:38   ` Cristian Marussi
2020-08-20 17:11     ` 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=20200819140448.51373-1-cristian.marussi@arm.com \
    --to=cristian.marussi@arm.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®