[4.2.y-ckt stable] Patch "i2c: img-scb: use DIV_ROUND_UP to round divisor values" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Mon Jan 4 23:23:16 UTC 2016


This is a note to let you know that I have just added a patch titled

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

to the linux-4.2.y-queue branch of the 4.2.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-4.2.y-queue

This patch is scheduled to be released in version 4.2.8-ckt1.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 4.2.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From f5cf39be97345daff3053f36eabc501f2d6b1b5d Mon Sep 17 00:00:00 2001
From: Sifan Naeem <sifan.naeem at imgtec.com>
Date: Thu, 10 Sep 2015 15:50:03 +0100
Subject: i2c: img-scb: use DIV_ROUND_UP to round divisor values

commit 5728d95f2458887ae3d95547c04352bba5080ad6 upstream.

Using % can be slow depending on the architecture.

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

Fixes: commit 27bce457d588 ("i2c: img-scb: Add Imagination Technologies I2C SCB driver")
Signed-off-by: Sifan Naeem <sifan.naeem at imgtec.com>
Acked-by: James Hogan <james.hogan at imgtec.com>
Reviewed-by: James Hartley <james.hartley at imgtec.com>
Signed-off-by: Wolfram Sang <wsa at the-dreams.de>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 drivers/i2c/busses/i2c-img-scb.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 0368d91..b4f59e1 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -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;
--
1.9.1





More information about the kernel-team mailing list