linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT][PATCH 1/2] i2c: sirf: Prevent potential division by zero
@ 2016-04-13  0:49 Axel Lin
  2016-04-13  0:54 ` [RFT][PATCH 2/2] i2c: sun6i-p2wi: " Axel Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Axel Lin @ 2016-04-13  0:49 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Barry Song, Guoying Zhang, linux-i2c

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. Since the clock-frequency
property is optional in current code, use SIRFSOC_I2C_DEFAULT_SPEED
instead if clock-frequency is set to 0 in a DT.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/i2c/busses/i2c-sirf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index 792a42b..82743e4 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -353,7 +353,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 
 	err = of_property_read_u32(pdev->dev.of_node,
 		"clock-frequency", &bitrate);
-	if (err < 0)
+	if (err < 0 || bitrate == 0)
 		bitrate = SIRFSOC_I2C_DEFAULT_SPEED;
 
 	/*
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-13  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-13  0:49 [RFT][PATCH 1/2] i2c: sirf: Prevent potential division by zero Axel Lin
2016-04-13  0:54 ` [RFT][PATCH 2/2] i2c: sun6i-p2wi: " Axel Lin
2016-04-13  7:49   ` Boris Brezillon

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).