diff mbox series

[10/11] i2c: imx-lpi2c: fix type char overflow issue when calculating the clock cycle

Message ID 20210317065359.3109394-11-xiaoning.wang@nxp.com
State Superseded
Headers show
Series i2c: imx-lpi2c: New features and bug fixes | expand

Commit Message

Clark Wang March 17, 2021, 6:53 a.m. UTC
Claim clkhi and clklo as integer type to avoid possible calculation
errors caused by data overflow.

Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Aisheng Dong March 19, 2021, 5:16 a.m. UTC | #1
> From: Clark Wang <xiaoning.wang@nxp.com>

> Sent: Wednesday, March 17, 2021 2:54 PM

> 

> Claim clkhi and clklo as integer type to avoid possible calculation errors caused

> by data overflow.

> 

> Reviewed-by: Fugang Duan <fugang.duan@nxp.com>

> Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>


Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>


Regards
Aisheng

> ---

>  drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c

> b/drivers/i2c/busses/i2c-imx-lpi2c.c

> index 5dbe85126f24..1e26672d47bf 100644

> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c

> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c

> @@ -213,8 +213,8 @@ static void lpi2c_imx_stop(struct lpi2c_imx_struct

> *lpi2c_imx)

>     CLKHI = I2C_CLK_RATIO * clk_cycle */  static int lpi2c_imx_config(struct

> lpi2c_imx_struct *lpi2c_imx)  {

> -	u8 prescale, filt, sethold, clkhi, clklo, datavd;

> -	unsigned int clk_rate, clk_cycle;

> +	u8 prescale, filt, sethold, datavd;

> +	unsigned int clk_rate, clk_cycle, clkhi, clklo;

>  	enum lpi2c_imx_pincfg pincfg;

>  	unsigned int temp;

> 

> --

> 2.25.1
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index 5dbe85126f24..1e26672d47bf 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -213,8 +213,8 @@  static void lpi2c_imx_stop(struct lpi2c_imx_struct *lpi2c_imx)
    CLKHI = I2C_CLK_RATIO * clk_cycle */
 static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
 {
-	u8 prescale, filt, sethold, clkhi, clklo, datavd;
-	unsigned int clk_rate, clk_cycle;
+	u8 prescale, filt, sethold, datavd;
+	unsigned int clk_rate, clk_cycle, clkhi, clklo;
 	enum lpi2c_imx_pincfg pincfg;
 	unsigned int temp;