Commit 9c6cf03d authored by Sifan Naeem's avatar Sifan Naeem Committed by Kamal Mostafa

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

commit 5728d95f upstream.

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: default avatarSifan Naeem <sifan.naeem@imgtec.com>
Acked-by: default avatarJames Hogan <james.hogan@imgtec.com>
Reviewed-by: default avatarJames Hartley <james.hartley@imgtec.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 34c04da8
...@@ -1177,9 +1177,7 @@ static int img_i2c_init(struct img_i2c *i2c) ...@@ -1177,9 +1177,7 @@ static int img_i2c_init(struct img_i2c *i2c)
int_bitrate++; int_bitrate++;
/* Setup TCKH value */ /* Setup TCKH value */
tckh = timing.tckh / clk_period; tckh = DIV_ROUND_UP(timing.tckh, clk_period);
if (timing.tckh % clk_period)
tckh++;
if (tckh > 0) if (tckh > 0)
data = tckh - 1; data = tckh - 1;
...@@ -1199,9 +1197,7 @@ static int img_i2c_init(struct img_i2c *i2c) ...@@ -1199,9 +1197,7 @@ static int img_i2c_init(struct img_i2c *i2c)
img_i2c_writel(i2c, SCB_TIME_TCKL_REG, data); img_i2c_writel(i2c, SCB_TIME_TCKL_REG, data);
/* Setup TSDH value */ /* Setup TSDH value */
tsdh = timing.tsdh / clk_period; tsdh = DIV_ROUND_UP(timing.tsdh, clk_period);
if (timing.tsdh % clk_period)
tsdh++;
if (tsdh > 1) if (tsdh > 1)
data = tsdh - 1; data = tsdh - 1;
......
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