Skip to contentSkip to conversation

soc: mediatek: Fix off-by-one checking for rate_spi

PATCH New Axel Lin 3 participants 3 messages Apr 21, 2015 Arm MediaTek

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 soc: mediatek: Fix off-by-one checking for rate_spi

If rate_spi is 26000000, current code set ck_mhz to 18 rather than 26. Fix the off-by-one checking for rate_spi.

---
 drivers/soc/mediatek/mtk-pmic-wrap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/mediatek/mtk-pmic-wrap.c +2 -2
index db5be1e..e910e19 100644
@@ -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;
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 soc: mediatek: Fix off-by-one checking for rate_spi

Quoted 4 lines · Axel Lin

If rate_spi is 26000000, current code set ck_mhz to 18 rather than 26. Fix the off-by-one checking for rate_spi.

Quoted 26 lines
---
 drivers/soc/mediatek/mtk-pmic-wrap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/mediatek/mtk-pmic-wrap.c +2 -2
index db5be1e..e910e19 100644
@@ -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;
Signature · 1 line
2.1.0
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer
#2 lore raw

PATCH 1/1 soc: mediatek: Fix off-by-one checking for rate_spi

Hi Sascha,

2015-04-21 12:59 GMT+02:00 Sascha Hauer <[email protected]>:

Quoted 8 lines · Axel Lin
Quoted 4 lines

If rate_spi is 26000000, current code set ck_mhz to 18 rather than 26. Fix the off-by-one checking for rate_spi.

Can you please explain why you think this is a bug? Please see my concerns here [1].

Best regards,
Matthias

[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-April/000419.html