[PATCH] drivers: clk: zynqmp: remove clock name dependency
Naman Trivedi Manojbhai
naman.trivedimanojbhai at amd.com
Tue Jan 2 23:20:17 PST 2024
Currently, from zynqmp_get_parent_list() function the clock driver
references the clock by name instead of its reference from device tree.
This causes problem when the clock name in the device tree is changed.
Remove hard dependency of clock name and update the logic to use clock
reference from device tree instead of clock name.
Signed-off-by: Naman Trivedi Manojbhai <naman.trivedimanojbhai at amd.com>
---
drivers/clk/zynqmp/clkc.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c
index a91d98e238c2..87915de083d9 100644
--- a/drivers/clk/zynqmp/clkc.c
+++ b/drivers/clk/zynqmp/clkc.c
@@ -549,18 +549,46 @@ static int zynqmp_get_parent_list(struct device_node *np, u32 clk_id,
u32 total_parents = clock[clk_id].num_parents;
struct clock_topology *clk_nodes;
struct clock_parent *parents;
+ struct clk *clk_parent;
+ char *clk_name;
clk_nodes = clock[clk_id].node;
parents = clock[clk_id].parent;
for (i = 0; i < total_parents; i++) {
if (!parents[i].flag) {
+ ret = of_property_match_string(np, "clock-names",
+ parents[i].name);
+ if (ret >= 0) {
+ clk_parent = of_clk_get(np, ret);
+ if (clk_parent) {
+ clk_name = __clk_get_name(clk_parent);
+ if (clk_name)
+ strcpy(parents[i].name, clk_name);
+ else
+ return 1;
+ } else {
+ return 1;
+ }
+ }
parent_list[i] = parents[i].name;
} else if (parents[i].flag == PARENT_CLK_EXTERNAL) {
ret = of_property_match_string(np, "clock-names",
parents[i].name);
- if (ret < 0)
+ if (ret < 0) {
strcpy(parents[i].name, "dummy_name");
+ } else {
+ clk_parent = of_clk_get(np, ret);
+ if (clk_parent) {
+ clk_name = __clk_get_name(clk_parent);
+ if (clk_name)
+ strcpy(parents[i].name, clk_name);
+ else
+ return 1;
+ } else {
+ return 1;
+ }
+ }
parent_list[i] = parents[i].name;
} else {
strcat(parents[i].name,
--
2.25.1
More information about the linux-arm-kernel
mailing list