Skip to content

Commit f597628

Browse files
robherringbebarino
authored andcommitted
clk: ti: Simplify ti_find_clock_provider()
Remove using for_each_of_allnodes_from() which is not safe to use without holding the DT spinlock. In reality that probably doesn't matter here. This is the only user in the whole tree, so it can be made private once removed here. The "from" argument is always NULL, so it can be dropped as well. There's a slight change in behavior in matching the "clock-output-names" value as the prior code would match if the node name matched the beginning of the value and the comparision was case insensitive. Now it must be an exact match. Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20250312163330.865573-2-robh@kernel.org Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fd12737 commit f597628

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

drivers/clk/ti/clk.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,10 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops)
118118
* Eventually we could standardize to using '_' for clk-*.c files to follow the
119119
* TRM naming.
120120
*/
121-
static struct device_node *ti_find_clock_provider(struct device_node *from,
122-
const char *name)
121+
static struct device_node *ti_find_clock_provider(const char *name)
123122
{
124123
char *tmp __free(kfree) = NULL;
125124
struct device_node *np;
126-
bool found = false;
127-
const char *n;
128125
char *p;
129126

130127
tmp = kstrdup_and_replace(name, '-', '_', GFP_KERNEL);
@@ -137,25 +134,13 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
137134
*p = '\0';
138135

139136
/* Node named "clock" with "clock-output-names" */
140-
for_each_of_allnodes_from(from, np) {
141-
if (of_property_read_string_index(np, "clock-output-names",
142-
0, &n))
143-
continue;
144-
145-
if (!strncmp(n, tmp, strlen(tmp))) {
146-
of_node_get(np);
147-
found = true;
148-
break;
149-
}
150-
}
151-
152-
if (found) {
153-
of_node_put(from);
154-
return np;
137+
for_each_node_with_property(np, "clock-output-names") {
138+
if (of_property_match_string(np, "clock-output-names", tmp) == 0)
139+
return np;
155140
}
156141

157142
/* Fall back to using old node name base provider name */
158-
return of_find_node_by_name(from, tmp);
143+
return of_find_node_by_name(NULL, tmp);
159144
}
160145

161146
/**
@@ -208,7 +193,7 @@ void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
208193
if (num_args && clkctrl_nodes_missing)
209194
continue;
210195

211-
node = ti_find_clock_provider(NULL, buf);
196+
node = ti_find_clock_provider(buf);
212197
if (num_args && compat_mode) {
213198
parent = node;
214199
child = of_get_child_by_name(parent, "clock");

0 commit comments

Comments
 (0)