lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 19 Aug 2020 15:04:48 +0100
From:   Cristian Marussi <cristian.marussi@....com>
To:     linux-kernel@...r.kernel.org
Cc:     broonie@...nel.org, cristian.marussi@....com
Subject: [PATCH] regulator: core: add of_match_full_name boolean flag

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@....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

Powered by blists - more mailing lists