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]
Message-ID: <20240103072017.1646007-1-naman.trivedimanojbhai@amd.com>
Date: Tue, 2 Jan 2024 23:20:17 -0800
From: Naman Trivedi Manojbhai <naman.trivedimanojbhai@....com>
To: <mturquette@...libre.com>, <sboyd@...nel.org>, <michal.simek@....com>,
	<abel.vesa@...aro.org>, <robh@...nel.org>, <krzysztof.kozlowski@...aro.org>,
	<angelogioacchino.delregno@...labora.com>
CC: <linux-clk@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>,
	<linux-kernel@...r.kernel.org>, Naman Trivedi Manojbhai
	<naman.trivedimanojbhai@....com>
Subject: [PATCH] drivers: clk: zynqmp: remove clock name dependency

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ