[PATCH] i2c: jz4780: Return error if clk_freq is set to 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Current code returns 0 in probe if clk_freq is set to 0.
As a result, the probe success but the module does not work. Fix it.

Fixes: 34cf2acdafaa ("i2c: jz4780: prevent potential division by zero")
Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
---
 drivers/i2c/busses/i2c-jz4780.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
index 597408f..0b3ba8d 100644
--- a/drivers/i2c/busses/i2c-jz4780.c
+++ b/drivers/i2c/busses/i2c-jz4780.c
@@ -772,6 +772,8 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
 				   &clk_freq);
 	if (ret || clk_freq == 0) {
 		dev_err(&pdev->dev, "clock-frequency not specified in DT");
+		if (ret == 0)
+			ret = -EINVAL;
 		goto err;
 	}
 
-- 
2.1.4



--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux