Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: core: add of_match_full_name boolean flag

During regulators registration, if .of_match and .regulators_node are
defined as non-null strings in struct regulator_desc the core searches the
DT subtree rooted at .regulators_node trying to match, at first, .of_match
against the 'regulator-compatible' property and, then, falling back to use
the name of the node itself to determine a good match.

Property 'regulator-compatible', though, is now deprecated and falling back
to match against the node name, works fine only as long as the involved
nodes are named in an unique way across the searched subtree; if that's not
the case, like when using <common-name>@<unit> style naming for properties
indexed via 'reg' property (as advised by the standard), the above matching
mechanism based on the simple common name will lead to multiple matches and
the only viable alternative would be to properly define the now deprecated
'regulator-compatible' as the node full name, i.e. <common-name>@<unit>.

In order to address this case without using such deprecated binding, 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 of the plain name.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20201119191051.46363-4-cristian.marussi@arm.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Cristian Marussi and committed by
Mark Brown
e7095c35 ce10f6ca

+9 -2
+6 -2
drivers/regulator/of_regulator.c
··· 413 413 414 414 for_each_available_child_of_node(search, child) { 415 415 name = of_get_property(child, "regulator-compatible", NULL); 416 - if (!name) 417 - name = child->name; 416 + if (!name) { 417 + if (!desc->of_match_full_name) 418 + name = child->name; 419 + else 420 + name = child->full_name; 421 + } 418 422 419 423 if (!strcmp(desc->of_match, name)) { 420 424 of_node_put(search);
+3
include/linux/regulator/driver.h
··· 223 223 * @name: Identifying name for the regulator. 224 224 * @supply_name: Identifying the regulator supply 225 225 * @of_match: Name used to identify regulator in DT. 226 + * @of_match_full_name: A flag to indicate that the of_match string, if 227 + * present, should be matched against the node full_name. 226 228 * @regulators_node: Name of node containing regulator definitions in DT. 227 229 * @of_parse_cb: Optional callback called only if of_match is present. 228 230 * Will be called for each regulator parsed from DT, during ··· 316 314 const char *name; 317 315 const char *supply_name; 318 316 const char *of_match; 317 + bool of_match_full_name; 319 318 const char *regulators_node; 320 319 int (*of_parse_cb)(struct device_node *, 321 320 const struct regulator_desc *,