Linux-Clk Archive mirror
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: Naman Trivedi Manojbhai <naman.trivedimanojbhai@amd.com>,
	mturquette@baylibre.com, sboyd@kernel.org, abel.vesa@linaro.org,
	robh@kernel.org, krzysztof.kozlowski@linaro.org,
	angelogioacchino.delregno@collabora.com
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: clk: zynqmp: remove clock name dependency
Date: Wed, 3 Jan 2024 11:03:07 +0100	[thread overview]
Message-ID: <19ad5595-93fd-4344-8c90-d5903eb6e279@amd.com> (raw)
In-Reply-To: <20240103072017.1646007-1-naman.trivedimanojbhai@amd.com>



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

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

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

Thanks,
Michal

  reply	other threads:[~2024-01-03 10:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03  7:20 [PATCH] drivers: clk: zynqmp: remove clock name dependency Naman Trivedi Manojbhai
2024-01-03 10:03 ` Michal Simek [this message]
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-04-11  4:17       ` Stephen Boyd
2024-01-04  1:41 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19ad5595-93fd-4344-8c90-d5903eb6e279@amd.com \
    --to=michal.simek@amd.com \
    --cc=abel.vesa@linaro.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=naman.trivedimanojbhai@amd.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).