linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Question about checking rate_spi in pwrap_init_reg_clock
@ 2015-04-21  1:58 Axel Lin
  2015-04-21 10:31 ` Sascha Hauer
  0 siblings, 1 reply; 7+ messages in thread
From: Axel Lin @ 2015-04-21  1:58 UTC (permalink / raw)
  To: linux-arm-kernel

hi,
The implementation in pwrap_init_reg_clock seems has off-by-one bug.
If rate_spi is 26000000, current code set ck_mhz to 18 rather than 26.

I guess it needs below fix, but I'm not 100% sure as I don't have the datasheet.
Can someone confirm if this is a bug or not?


diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
index db5be1e..e910e19 100644
--- a/drivers/soc/mediatek/mtk-pmic-wrap.c
+++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
@@ -568,9 +568,9 @@ static int pwrap_init_reg_clock(struct pmic_wrapper *wrp)
 
 	rate_spi = clk_get_rate(wrp->clk_spi);
 
-	if (rate_spi > 26000000)
+	if (rate_spi >= 26000000)
 		ck_mhz = 26;
-	else if (rate_spi > 18000000)
+	else if (rate_spi >= 18000000)
 		ck_mhz = 18;
 	else
 		ck_mhz = 0;

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

end of thread, other threads:[~2015-05-08  9:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21  1:58 Question about checking rate_spi in pwrap_init_reg_clock Axel Lin
2015-04-21 10:31 ` Sascha Hauer
2015-04-21 11:43   ` Matthias Brugger
2015-04-21 12:52     ` Sascha Hauer
2015-04-21 15:42       ` Matthias Brugger
2015-05-08  9:33         ` Axel Lin
2015-05-08  9:51           ` Eddie Huang

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 NNTP newsgroup(s).