From: Axel Lin <axel.lin@ingics.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Boris BREZILLON <boris.brezillon@free-electrons.com>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-i2c@vger.kernel.org
Subject: [RFT][PATCH 2/2] i2c: sun6i-p2wi: Prevent potential division by zero
Date: Wed, 13 Apr 2016 08:54:30 +0800 [thread overview]
Message-ID: <1460508870.6009.3.camel@ingics.com> (raw)
In-Reply-To: <1460508570.6009.1.camel@ingics.com>
Make sure we don't OOPS in case clock-frequency is set to 0 in a DT. The
variable set here is later used as a divisor.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index 7668e2e..6448291 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -202,6 +202,11 @@ static int p2wi_probe(struct platform_device *pdev)
return -EINVAL;
}
+ if (clk_freq == 0) {
+ dev_err(dev, "clock-frequency is set to 0 in DT\n");
+ return -EINVAL;
+ }
+
if (of_get_child_count(np) > 1) {
dev_err(dev, "P2WI only supports one slave device\n");
return -EINVAL;
--
2.5.0
next prev parent reply other threads:[~2016-04-13 0:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 0:49 [RFT][PATCH 1/2] i2c: sirf: Prevent potential division by zero Axel Lin
2016-04-13 0:54 ` Axel Lin [this message]
2016-04-13 7:49 ` [RFT][PATCH 2/2] i2c: sun6i-p2wi: " Boris Brezillon
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=1460508870.6009.3.camel@ingics.com \
--to=axel.lin@ingics.com \
--cc=boris.brezillon@free-electrons.com \
--cc=linux-i2c@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=wens@csie.org \
--cc=wsa@the-dreams.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.