linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: clk: zynqmp: remove clock name dependency
@ 2024-01-03  7:20 Naman Trivedi Manojbhai
  2024-01-03 10:03 ` Michal Simek
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Naman Trivedi Manojbhai @ 2024-01-03  7:20 UTC (permalink / raw)
  To: mturquette, sboyd, michal.simek, abel.vesa, robh,
	krzysztof.kozlowski, angelogioacchino.delregno
  Cc: linux-clk, linux-arm-kernel, linux-kernel,
	Naman Trivedi Manojbhai

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-03-27  5:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-03  7:20 [PATCH] drivers: clk: zynqmp: remove clock name dependency Naman Trivedi Manojbhai
2024-01-03 10:03 ` Michal Simek
2024-01-03 22:28 ` kernel test robot
2024-01-04  1:00 ` Stephen Boyd
2024-01-09 11:24   ` Trivedi Manojbhai, Naman
2024-01-29 16:48     ` Trivedi Manojbhai, Naman
2024-01-22 12:05   ` Trivedi Manojbhai, Naman
2024-03-07  6:06   ` Trivedi Manojbhai, Naman
2024-03-27  5:47     ` Trivedi Manojbhai, Naman
2024-01-04  1:41 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).