* [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation
@ 2020-12-22 13:31 Zheng Yongjun
2020-12-22 14:10 ` Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Zheng Yongjun @ 2020-12-22 13:31 UTC (permalink / raw)
To: linux, shawnguo, s.hauer, linux-i2c, linux-kernel
Cc: kernel, festevam, linux-imx, Zheng Yongjun
Don't open-code DIV_ROUND_UP() kernel macro.
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/i2c/busses/i2c-imx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index e6f8d6e45a15..346c196cbce7 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -529,7 +529,7 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
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)
i = 0;
else if (div > i2c_clk_div[i2c_imx->hwdata->ndivs - 1].div)
@@ -547,8 +547,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
* This delay is used in I2C bus disable function
* to fix chip hardware bug.
*/
- i2c_imx->disable_delay = (500000U * i2c_clk_div[i].div
- + (i2c_clk_rate / 2) - 1) / (i2c_clk_rate / 2);
+ i2c_imx->disable_delay = DIV_ROUND_UP(500000U * i2c_clk_div[i].div,
+ i2c_clk_rate / 2);
#ifdef CONFIG_I2C_DEBUG_BUS
dev_dbg(&i2c_imx->adapter.dev, "I2C_CLK=%d, REQ DIV=%d\n",
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation
2020-12-22 13:31 [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
@ 2020-12-22 14:10 ` Fabio Estevam
2020-12-22 22:25 ` Uwe Kleine-König
2021-01-05 16:45 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2020-12-22 14:10 UTC (permalink / raw)
To: Zheng Yongjun
Cc: Oleksij Rempel, Shawn Guo, Sascha Hauer, linux-i2c, linux-kernel,
Sascha Hauer, NXP Linux Team
Hi Zheng,
On Tue, Dec 22, 2020 at 10:31 AM Zheng Yongjun <zhengyongjun3@huawei.com> wrote:
>
> Don't open-code DIV_ROUND_UP() kernel macro.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation
2020-12-22 13:31 [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
2020-12-22 14:10 ` Fabio Estevam
@ 2020-12-22 22:25 ` Uwe Kleine-König
2021-01-05 16:45 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2020-12-22 22:25 UTC (permalink / raw)
To: Zheng Yongjun
Cc: linux, shawnguo, s.hauer, linux-i2c, linux-kernel, festevam,
linux-imx, kernel
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
On Tue, Dec 22, 2020 at 09:31:31PM +0800, Zheng Yongjun wrote:
> Don't open-code DIV_ROUND_UP() kernel macro.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
LGTM,
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation
2020-12-22 13:31 [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
2020-12-22 14:10 ` Fabio Estevam
2020-12-22 22:25 ` Uwe Kleine-König
@ 2021-01-05 16:45 ` Wolfram Sang
2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-01-05 16:45 UTC (permalink / raw)
To: Zheng Yongjun
Cc: linux, shawnguo, s.hauer, linux-i2c, linux-kernel, kernel,
festevam, linux-imx
[-- Attachment #1: Type: text/plain, Size: 209 bytes --]
On Tue, Dec 22, 2020 at 09:31:31PM +0800, Zheng Yongjun wrote:
> Don't open-code DIV_ROUND_UP() kernel macro.
>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-05 16:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 13:31 [PATCH -next] i2c: busses: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
2020-12-22 14:10 ` Fabio Estevam
2020-12-22 22:25 ` Uwe Kleine-König
2021-01-05 16:45 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).