Linux-Clk Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH -next] clk: tegra: Use match_string() helper to simplify the code
@ 2019-11-09  3:42 YueHaibing
  2019-11-13 23:04 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: YueHaibing @ 2019-11-09  3:42 UTC (permalink / raw)
  To: pdeschrijver, pgaikwad, mturquette, sboyd, thierry.reding, jonathanh
  Cc: linux-clk, linux-tegra, linux-kernel, YueHaibing

match_string() returns the array index of a matching string.
Use it instead of the open-coded implementation.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/clk/tegra/clk-emc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/tegra/clk-emc.c b/drivers/clk/tegra/clk-emc.c
index ea39caf..745f9fa 100644
--- a/drivers/clk/tegra/clk-emc.c
+++ b/drivers/clk/tegra/clk-emc.c
@@ -403,20 +403,16 @@ static int load_one_timing_from_dt(struct tegra_clk_emc *tegra,
 	}
 
 	timing->parent_index = 0xff;
-	for (i = 0; i < ARRAY_SIZE(emc_parent_clk_names); i++) {
-		if (!strcmp(emc_parent_clk_names[i],
-			    __clk_get_name(timing->parent))) {
-			timing->parent_index = i;
-			break;
-		}
-	}
-	if (timing->parent_index == 0xff) {
+	i = match_string(emc_parent_clk_names, ARRAY_SIZE(emc_parent_clk_names),
+			 __clk_get_name(timing->parent));
+	if (i < 0) {
 		pr_err("timing %pOF: %s is not a valid parent\n",
 		       node, __clk_get_name(timing->parent));
 		clk_put(timing->parent);
 		return -EINVAL;
 	}
 
+	timing->parent_index = i;
 	return 0;
 }
 
-- 
2.7.4



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

* Re: [PATCH -next] clk: tegra: Use match_string() helper to simplify the code
  2019-11-09  3:42 [PATCH -next] clk: tegra: Use match_string() helper to simplify the code YueHaibing
@ 2019-11-13 23:04 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2019-11-13 23:04 UTC (permalink / raw)
  To: YueHaibing, jonathanh, mturquette, pdeschrijver, pgaikwad,
	thierry.reding
  Cc: linux-clk, linux-tegra, linux-kernel, YueHaibing

Quoting YueHaibing (2019-11-08 19:42:26)
> match_string() returns the array index of a matching string.
> Use it instead of the open-coded implementation.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---

Applied to clk-next


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09  3:42 [PATCH -next] clk: tegra: Use match_string() helper to simplify the code YueHaibing
2019-11-13 23:04 ` Stephen Boyd

Linux-Clk Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-clk/0 linux-clk/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-clk linux-clk/ https://lore.kernel.org/linux-clk \
		linux-clk@vger.kernel.org
	public-inbox-index linux-clk

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-clk


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git