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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <19ad5595-93fd-4344-8c90-d5903eb6e279@amd.com>
Date: Wed, 3 Jan 2024 11:03:07 +0100
From: Michal Simek <michal.simek@....com>
To: Naman Trivedi Manojbhai <naman.trivedimanojbhai@....com>,
 mturquette@...libre.com, sboyd@...nel.org, 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
Subject: Re: [PATCH] drivers: clk: zynqmp: remove clock name dependency



On 1/3/24 08:20, Naman Trivedi Manojbhai wrote:
> 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,

Not sure if this is the best way how to do it but it works as expected.

Tested-by: Michal Simek <michal.simek@....com>

Thanks,
Michal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ