All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] clk: renesas: Fix SDH clock divider decoding on Gen2
@ 2019-03-18  5:20 Marek Vasut
  2019-03-18  5:20 ` [U-Boot] [PATCH 2/3] clk: renesas: Fix swapped div and mul in debug output " Marek Vasut
  2019-03-18  5:20 ` [U-Boot] [PATCH 3/3] clk: renesas: Add support for setting MMCIF clock divider " Marek Vasut
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Vasut @ 2019-03-18  5:20 UTC (permalink / raw)
  To: u-boot

The gen2_clk_get_sdh_div() function is supposed to look up the
$val value read out of the SDCKCR register in the supplied table
and return the matching divider value. The current implementation
was matching the value from SDCKCR on the divider value in the
table, which is wrong. Fix this and rework the function a bit
to make it more readable.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
---
 drivers/clk/renesas/clk-rcar-gen2.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/renesas/clk-rcar-gen2.c b/drivers/clk/renesas/clk-rcar-gen2.c
index 6dfd02f2eb..aedaab723b 100644
--- a/drivers/clk/renesas/clk-rcar-gen2.c
+++ b/drivers/clk/renesas/clk-rcar-gen2.c
@@ -44,13 +44,17 @@ static const struct clk_div_table cpg_sd01_div_table[] = {
 	{  0,  0 },
 };
 
-static u8 gen2_clk_get_sdh_div(const struct clk_div_table *table, u8 div)
+static u8 gen2_clk_get_sdh_div(const struct clk_div_table *table, u8 val)
 {
-	while ((*table++).val) {
-		if ((*table).div == div)
-			return div;
+	for (;;) {
+		if (!(*table).div)
+			return 0xff;
+
+		if ((*table).val == val)
+			return (*table).div;
+
+		table++;
 	}
-	return 0xff;
 }
 
 static int gen2_clk_enable(struct clk *clk)
-- 
2.20.1

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

end of thread, other threads:[~2019-03-18  5:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18  5:20 [U-Boot] [PATCH 1/3] clk: renesas: Fix SDH clock divider decoding on Gen2 Marek Vasut
2019-03-18  5:20 ` [U-Boot] [PATCH 2/3] clk: renesas: Fix swapped div and mul in debug output " Marek Vasut
2019-03-18  5:20 ` [U-Boot] [PATCH 3/3] clk: renesas: Add support for setting MMCIF clock divider " Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.