Commit 9d64834b authored by Zheng Yongjun's avatar Zheng Yongjun Committed by Wolfram Sang

i2c: use DIV_ROUND_UP macro to do calculation

Don't open-code DIV_ROUND_UP() kernel macro.
Signed-off-by: default avatarZheng Yongjun <zhengyongjun3@huawei.com>
Reviewed-by: default avatarFabio Estevam <festevam@gmail.com>
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 2478b9c1
...@@ -537,7 +537,7 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, ...@@ -537,7 +537,7 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
i2c_imx->cur_clk = i2c_clk_rate; i2c_imx->cur_clk = i2c_clk_rate;
div = (i2c_clk_rate + i2c_imx->bitrate - 1) / i2c_imx->bitrate; div = DIV_ROUND_UP(i2c_clk_rate, i2c_imx->bitrate);
if (div < i2c_clk_div[0].div) if (div < i2c_clk_div[0].div)
i = 0; i = 0;
else if (div > i2c_clk_div[i2c_imx->hwdata->ndivs - 1].div) else if (div > i2c_clk_div[i2c_imx->hwdata->ndivs - 1].div)
...@@ -555,8 +555,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, ...@@ -555,8 +555,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
* This delay is used in I2C bus disable function * This delay is used in I2C bus disable function
* to fix chip hardware bug. * to fix chip hardware bug.
*/ */
i2c_imx->disable_delay = (500000U * i2c_clk_div[i].div i2c_imx->disable_delay = DIV_ROUND_UP(500000U * i2c_clk_div[i].div,
+ (i2c_clk_rate / 2) - 1) / (i2c_clk_rate / 2); i2c_clk_rate / 2);
#ifdef CONFIG_I2C_DEBUG_BUS #ifdef CONFIG_I2C_DEBUG_BUS
dev_dbg(&i2c_imx->adapter.dev, "I2C_CLK=%d, REQ DIV=%d\n", dev_dbg(&i2c_imx->adapter.dev, "I2C_CLK=%d, REQ DIV=%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment