From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-renesas-soc@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Chris Brandt <chris.brandt@renesas.com>,
Andi Shyti <andi.shyti@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] i2c: riic: avoid potential division by zero
Date: Wed, 6 Sep 2023 22:00:23 +0200 [thread overview]
Message-ID: <20230906200024.5305-6-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20230906200024.5305-1-wsa+renesas@sang-engineering.com>
Value comes from DT, so it could be 0. Unlikely, but could be.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/busses/i2c-riic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
index f0ee8871d5ae..e43ff483c56e 100644
--- a/drivers/i2c/busses/i2c-riic.c
+++ b/drivers/i2c/busses/i2c-riic.c
@@ -313,7 +313,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
* frequency with only 62 clock ticks max (31 high, 31 low).
* Aim for a duty of 60% LOW, 40% HIGH.
*/
- total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
+ total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);
for (cks = 0; cks < 7; cks++) {
/*
--
2.35.1
next prev parent reply other threads:[~2023-09-06 20:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 20:00 [PATCH 0/5] i2c: clock calculation cleanups for Renesas devices Wolfram Sang
2023-09-06 20:00 ` [PATCH 1/5] i2c: rcar: avoid non-standard use of goto Wolfram Sang
2023-09-08 15:03 ` Geert Uytterhoeven
2023-09-06 20:00 ` [PATCH 2/5] i2c: rcar: properly format a debug output Wolfram Sang
2023-09-08 15:04 ` Geert Uytterhoeven
2023-09-06 20:00 ` [PATCH 3/5] i2c: rcar: calculate divider instead of brute-forcing it Wolfram Sang
2023-09-19 8:33 ` Geert Uytterhoeven
2023-09-06 20:00 ` [PATCH 4/5] i2c: rcar: remove open coded DIV_ROUND_CLOSEST Wolfram Sang
2023-09-08 15:06 ` Geert Uytterhoeven
2023-09-06 20:00 ` Wolfram Sang [this message]
2023-09-07 6:42 ` [PATCH 5/5] i2c: riic: avoid potential division by zero Biju Das
2023-09-07 6:44 ` Biju Das
2023-09-07 12:08 ` Wolfram Sang
2023-09-08 15:09 ` Geert Uytterhoeven
2023-09-19 9:12 ` [PATCH 0/5] i2c: clock calculation cleanups for Renesas devices Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230906200024.5305-6-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=andi.shyti@kernel.org \
--cc=chris.brandt@renesas.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox