Skip to content

Commit 9d64834

Browse files
Zheng Yongjunwsakernel
authored andcommitted
i2c: use DIV_ROUND_UP macro to do calculation
Don't open-code DIV_ROUND_UP() kernel macro. Signed-off-by: Zheng Yongjun <[email protected]> Reviewed-by: Fabio Estevam <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 2478b9c commit 9d64834

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
537537

538538
i2c_imx->cur_clk = i2c_clk_rate;
539539

540-
div = (i2c_clk_rate + i2c_imx->bitrate - 1) / i2c_imx->bitrate;
540+
div = DIV_ROUND_UP(i2c_clk_rate, i2c_imx->bitrate);
541541
if (div < i2c_clk_div[0].div)
542542
i = 0;
543543
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,
555555
* This delay is used in I2C bus disable function
556556
* to fix chip hardware bug.
557557
*/
558-
i2c_imx->disable_delay = (500000U * i2c_clk_div[i].div
559-
+ (i2c_clk_rate / 2) - 1) / (i2c_clk_rate / 2);
558+
i2c_imx->disable_delay = DIV_ROUND_UP(500000U * i2c_clk_div[i].div,
559+
i2c_clk_rate / 2);
560560

561561
#ifdef CONFIG_I2C_DEBUG_BUS
562562
dev_dbg(&i2c_imx->adapter.dev, "I2C_CLK=%d, REQ DIV=%d\n",

0 commit comments

Comments
 (0)