* [PATCH 1/4] i2c: uniphier: error out if clock rate is zero
2015-11-30 9:53 [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada
@ 2015-11-30 9:53 ` Masahiro Yamada
2015-11-30 9:53 ` [PATCH 2/4] i2c: uniphier: error out if bus speed " Masahiro Yamada
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2015-11-30 9:53 UTC (permalink / raw)
To: linux-arm-kernel
This input clock is used to generate the sampling clock for I2C bus.
If the clock rate is zero, there is something wrong with the clock
driver. Bail out with the appropriate error message in such a case.
It would make it easier to find the root cause of failure.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
index e3c3861..2b2c20b 100644
--- a/drivers/i2c/busses/i2c-uniphier.c
+++ b/drivers/i2c/busses/i2c-uniphier.c
@@ -342,6 +342,10 @@ static int uniphier_i2c_clk_init(struct device *dev,
return ret;
clk_rate = clk_get_rate(priv->clk);
+ if (!clk_rate) {
+ dev_err(dev, "input clock rate should not be zero\n");
+ return -EINVAL;
+ }
uniphier_i2c_reset(priv, true);
@@ -388,7 +392,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
ret = uniphier_i2c_clk_init(dev, priv);
if (ret)
- return ret;
+ goto err;
ret = devm_request_irq(dev, irq, uniphier_i2c_interrupt, 0, pdev->name,
priv);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] i2c: uniphier: error out if bus speed is zero
2015-11-30 9:53 [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada
2015-11-30 9:53 ` [PATCH 1/4] i2c: uniphier: error out if clock rate is zero Masahiro Yamada
@ 2015-11-30 9:53 ` Masahiro Yamada
2015-11-30 9:53 ` [PATCH 3/4] i2c: uniphier_f: error out if clock rate " Masahiro Yamada
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2015-11-30 9:53 UTC (permalink / raw)
To: linux-arm-kernel
There is code to divide by "bus_speed" some lines below.
To eliminate the possibility of division by zero, bail out if
"clock-frequency" is specified as zero.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
index 2b2c20b..1f4f3f5 100644
--- a/drivers/i2c/busses/i2c-uniphier.c
+++ b/drivers/i2c/busses/i2c-uniphier.c
@@ -327,6 +327,11 @@ static int uniphier_i2c_clk_init(struct device *dev,
if (of_property_read_u32(np, "clock-frequency", &bus_speed))
bus_speed = UNIPHIER_I2C_DEFAULT_SPEED;
+ if (!bus_speed) {
+ dev_err(dev, "clock-freqyency should not be zero\n");
+ return -EINVAL;
+ }
+
if (bus_speed > UNIPHIER_I2C_MAX_SPEED)
bus_speed = UNIPHIER_I2C_MAX_SPEED;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] i2c: uniphier_f: error out if clock rate is zero
2015-11-30 9:53 [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada
2015-11-30 9:53 ` [PATCH 1/4] i2c: uniphier: error out if clock rate is zero Masahiro Yamada
2015-11-30 9:53 ` [PATCH 2/4] i2c: uniphier: error out if bus speed " Masahiro Yamada
@ 2015-11-30 9:53 ` Masahiro Yamada
2015-11-30 9:53 ` [PATCH 4/4] i2c: uniphier_f: error out if bus speed " Masahiro Yamada
2015-12-14 10:01 ` [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Wolfram Sang
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2015-11-30 9:53 UTC (permalink / raw)
To: linux-arm-kernel
This input clock is used to generate the sampling clock for I2C bus.
If the clock rate is zero, there is something wrong with the clock
driver. Bail out with the appropriate error message in such a case.
It would make it easier to find the root cause of failure.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier-f.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index e8d03bc..67109e1 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -481,6 +481,10 @@ static int uniphier_fi2c_clk_init(struct device *dev,
return ret;
clk_rate = clk_get_rate(priv->clk);
+ if (!clk_rate) {
+ dev_err(dev, "input clock rate should not be zero\n");
+ return -EINVAL;
+ }
uniphier_fi2c_reset(priv);
@@ -531,7 +535,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
ret = uniphier_fi2c_clk_init(dev, priv);
if (ret)
- return ret;
+ goto err;
ret = devm_request_irq(dev, irq, uniphier_fi2c_interrupt, 0,
pdev->name, priv);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] i2c: uniphier_f: error out if bus speed is zero
2015-11-30 9:53 [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada
` (2 preceding siblings ...)
2015-11-30 9:53 ` [PATCH 3/4] i2c: uniphier_f: error out if clock rate " Masahiro Yamada
@ 2015-11-30 9:53 ` Masahiro Yamada
2015-12-14 10:01 ` [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Wolfram Sang
4 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2015-11-30 9:53 UTC (permalink / raw)
To: linux-arm-kernel
There is code to divide by "bus_speed" some lines below.
To eliminate the possibility of division by zero, bail out if
"clock-frequency" is specified as zero.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier-f.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index 67109e1..f3e5ff8 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -466,6 +466,11 @@ static int uniphier_fi2c_clk_init(struct device *dev,
if (of_property_read_u32(np, "clock-frequency", &bus_speed))
bus_speed = UNIPHIER_FI2C_DEFAULT_SPEED;
+ if (!bus_speed) {
+ dev_err(dev, "clock-freqyency should not be zero\n");
+ return -EINVAL;
+ }
+
if (bus_speed > UNIPHIER_FI2C_MAX_SPEED)
bus_speed = UNIPHIER_FI2C_MAX_SPEED;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f
2015-11-30 9:53 [PATCH 0/4] i2c: uniphier: add minor sanity checks to i2c-uniphier/i2c-uniphier-f Masahiro Yamada
` (3 preceding siblings ...)
2015-11-30 9:53 ` [PATCH 4/4] i2c: uniphier_f: error out if bus speed " Masahiro Yamada
@ 2015-12-14 10:01 ` Wolfram Sang
4 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2015-12-14 10:01 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Nov 30, 2015 at 06:53:32PM +0900, Masahiro Yamada wrote:
>
>
>
> Masahiro Yamada (4):
> i2c: uniphier: error out if clock rate is zero
> i2c: uniphier: error out if bus speed is zero
> i2c: uniphier_f: error out if clock rate is zero
> i2c: uniphier_f: error out if bus speed is zero
Applied to for-next, thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151214/1db31c29/attachment.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread