提交 5728d95f 编写于 作者: S Sifan Naeem 提交者: Wolfram Sang

i2c: img-scb: use DIV_ROUND_UP to round divisor values

Using % can be slow depending on the architecture.

Using DIV_ROUND_UP is nicer and more efficient way to do it.

Fixes: commit 27bce457 ("i2c: img-scb: Add Imagination Technologies I2C SCB driver")
Signed-off-by: NSifan Naeem <sifan.naeem@imgtec.com>
Acked-by: NJames Hogan <james.hogan@imgtec.com>
Reviewed-by: NJames Hartley <james.hartley@imgtec.com>
Signed-off-by: NWolfram Sang <wsa@the-dreams.de>
上级 2aefb1bd
......@@ -1179,9 +1179,7 @@ static int img_i2c_init(struct img_i2c *i2c)
int_bitrate++;
/* Setup TCKH value */
tckh = timing.tckh / clk_period;
if (timing.tckh % clk_period)
tckh++;
tckh = DIV_ROUND_UP(timing.tckh, clk_period);
if (tckh > 0)
data = tckh - 1;
......@@ -1201,9 +1199,7 @@ static int img_i2c_init(struct img_i2c *i2c)
img_i2c_writel(i2c, SCB_TIME_TCKL_REG, data);
/* Setup TSDH value */
tsdh = timing.tsdh / clk_period;
if (timing.tsdh % clk_period)
tsdh++;
tsdh = DIV_ROUND_UP(timing.tsdh, clk_period);
if (tsdh > 1)
data = tsdh - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册