Skip to contentSkip to conversation

Use dev_err_probe in i2c probe function

PATCH Applied Liao Chang 6 participants 29 messages Aug 8, 2023 – Aug 14, 2023

Subsystems (12)
lore
Share & tools
lore

Liao Chang

author
#0 lore raw

v3 cover Use dev_err_probe in i2c probe function

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

NOTICE: dev_err_probe always print the second parameter that happens to be the return value, hence the return errno will be removed from the third parameter to avoid a redundant error message.

v3:
Convert all dev_err() in synquacer_i2c_probe() to dev_err_probe() even if the return value is known to never be -EPROBE_DEFER.

v2:
1. Convert all dev_err() in lpi2c_imx_probe(), synquacer_i2c_probe(), mlxbf_i2c_probe() to dev_err_probe().
2. Add Reviewed-by: Florian Fainelli <[email protected]>
3. Add Reviewed-by: Yicong Yang <[email protected]>
4. Add Reviewed-by: Andi Shyti <[email protected]>

Liao Chang (9):
i2c: bcm2835: Use dev_err_probe in probe function
i2c: mlxbf: Use dev_err_probe in probe function
i2c: xlp9xx: Use dev_err_probe in probe function
i2c: hisi: Use dev_err_probe in probe function
i2c: qcom-cci: Use dev_err_probe in probe function
i2c: pxa: Use dev_err_probe in probe function
i2c: dln2: Use dev_err_probe in probe function
i2c: imx-lpi2c: Use dev_err_probe in probe function
i2c: synquacer: Use dev_err_probe in probe function

 drivers/i2c/busses/i2c-bcm2835.c   | 14 ++++-----
 drivers/i2c/busses/i2c-dln2.c      |  6 ++--
 drivers/i2c/busses/i2c-hisi.c      | 12 +++----
 drivers/i2c/busses/i2c-imx-lpi2c.c | 12 +++----
 drivers/i2c/busses/i2c-mlxbf.c     | 50 ++++++++++--------------------
 drivers/i2c/busses/i2c-pxa.c       |  7 ++---
 drivers/i2c/busses/i2c-qcom-cci.c  |  6 ++--
 drivers/i2c/busses/i2c-synquacer.c | 28 ++++++-----------
 drivers/i2c/busses/i2c-xlp9xx.c    |  6 ++--
 9 files changed, 50 insertions(+), 91 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v3 1/9 i2c: bcm2835: Use dev_err_probe in probe function

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-bcm2835.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-bcm2835.c +6 -8
index 8ce6d3f49551..9af1a68269ab 100644
@@ -430,10 +430,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 
 	i2c_dev->bus_clk = bcm2835_i2c_register_div(&pdev->dev, mclk, i2c_dev);
 
-	if (IS_ERR(i2c_dev->bus_clk)) {
-		dev_err(&pdev->dev, "Could not register clock\n");
-		return PTR_ERR(i2c_dev->bus_clk);
-	}
+	if (IS_ERR(i2c_dev->bus_clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->bus_clk),
+				     "Could not register clock\n");
 
 	ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
 				   &bus_clk_rate);
@@ -444,10 +443,9 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	}
 
 	ret = clk_set_rate_exclusive(i2c_dev->bus_clk, bus_clk_rate);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "Could not set clock frequency\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&pdev->dev, ret,
+				     "Could not set clock frequency\n");
 
 	ret = clk_prepare_enable(i2c_dev->bus_clk);
 	if (ret) {
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH v3 1/9] i2c: bcm2835: Use dev_err_probe in probe function

Hi Markus,

Quoted 4 lines · Markus Elfring

…

Quoted 1 line

so that the printed messge includes …

Please avoid a typo in such a wording.

yes, I noticed this... and thanks for pointing it out. If no other version will be sent I can fix /messge/message/ while applying this series.

Thank you,
Andi

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#4 lore raw

PATCH v3 2/9 i2c: mlxbf: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-mlxbf.c | 50 ++++++++++++----------------------
 1 file changed, 17 insertions(+), 33 deletions(-)
drivers/i2c/busses/i2c-mlxbf.c +17 -33
index ae66bdd1b737..5ee82016c805 100644
@@ -2323,10 +2323,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 
 		ret = mlxbf_i2c_init_resource(pdev, &priv->smbus,
 					      MLXBF_I2C_SMBUS_RES);
-		if (ret < 0) {
-			dev_err(dev, "Cannot fetch smbus resource info");
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(dev, ret, "Cannot fetch smbus resource info");
 
 		priv->timer->io = priv->smbus->io;
 		priv->mst->io = priv->smbus->io + MLXBF_I2C_MST_ADDR_OFFSET;
@@ -2334,39 +2332,29 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	} else {
 		ret = mlxbf_i2c_init_resource(pdev, &priv->timer,
 					      MLXBF_I2C_SMBUS_TIMER_RES);
-		if (ret < 0) {
-			dev_err(dev, "Cannot fetch timer resource info");
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(dev, ret, "Cannot fetch timer resource info");
 
 		ret = mlxbf_i2c_init_resource(pdev, &priv->mst,
 					      MLXBF_I2C_SMBUS_MST_RES);
-		if (ret < 0) {
-			dev_err(dev, "Cannot fetch master resource info");
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(dev, ret, "Cannot fetch master resource info");
 
 		ret = mlxbf_i2c_init_resource(pdev, &priv->slv,
 					      MLXBF_I2C_SMBUS_SLV_RES);
-		if (ret < 0) {
-			dev_err(dev, "Cannot fetch slave resource info");
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(dev, ret, "Cannot fetch slave resource info");
 	}
 
 	ret = mlxbf_i2c_init_resource(pdev, &priv->mst_cause,
 				      MLXBF_I2C_MST_CAUSE_RES);
-	if (ret < 0) {
-		dev_err(dev, "Cannot fetch cause master resource info");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot fetch cause master resource info");
 
 	ret = mlxbf_i2c_init_resource(pdev, &priv->slv_cause,
 				      MLXBF_I2C_SLV_CAUSE_RES);
-	if (ret < 0) {
-		dev_err(dev, "Cannot fetch cause slave resource info");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot fetch cause slave resource info");
 
 	adap = &priv->adap;
 	adap->owner = THIS_MODULE;
@@ -2397,11 +2385,9 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	 * does not really hurt, then keep the code as is.
 	 */
 	ret = mlxbf_i2c_init_master(pdev, priv);
-	if (ret < 0) {
-		dev_err(dev, "failed to initialize smbus master %d",
-			priv->bus);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "failed to initialize smbus master %d",
+				     priv->bus);
 
 	mlxbf_i2c_init_timings(pdev, priv);
 
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);
 
 	priv->irq = irq;
 
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#6 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Hi Krzysztof,

Quoted 10 lines · Krzysztof Kozlowski
Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

Quoted 13 lines

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Hmm, that's a bit borderline, I'd say. The change to devm_request_irq/devm_request_threaded_irq_probe seems like something for another series. But for now, I think I'll accept this as it is since it fits within the scope of this current series.

Andi

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#7 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Quoted 27 lines · Andi Shyti

Hi Krzysztof,

Quoted 10 lines · Krzysztof Kozlowski
Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

Quoted 13 lines

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Quoted 1 line

Hmm, that's a bit borderline, I'd say. The change to

What's borderline exactly? devm_request_threaded_irq_probe() is coming, right? If it is accepted this hunk is useless and soon should be replaced with proper one.

Instead of making many trivial changes doing the same, all these series should be aligned.

Quoted 4 lines

devm_request_irq/devm_request_threaded_irq_probe seems like something for another series. But for now, I think I'll accept this as it is since it fits within the scope of this current series.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#8 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Hi Krzysztof,

Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Andi Shyti

Hi Krzysztof,

Quoted 23 lines · Krzysztof Kozlowski
Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Quoted 5 lines
Quoted 1 line

Hmm, that's a bit borderline, I'd say. The change to

What's borderline exactly? devm_request_threaded_irq_probe() is coming, right? If it is accepted this hunk is useless and soon should be replaced with proper one.

Such change is out of the scope of this series, there are two options that I'd prefer (in the listed order):

1. accept the patch as it is, this patch is not sent today the first time and at the current state it's correct.
2. not accept a change on this line

Replacing devm_request_irq belongs to another series and, besides, I don't want to ask Liao to hold on this series for such trivialities.

Thank you,
Andi

Quoted 12 lines

Instead of making many trivial changes doing the same, all these series should be aligned.

Quoted 4 lines

devm_request_irq/devm_request_threaded_irq_probe seems like something for another series. But for now, I think I'll accept this as it is since it fits within the scope of this current series.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#9 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Quoted 37 lines · Andi Shyti

Hi Krzysztof,

Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Andi Shyti

Hi Krzysztof,

Quoted 23 lines · Krzysztof Kozlowski
Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Quoted 5 lines
Quoted 1 line

Hmm, that's a bit borderline, I'd say. The change to

What's borderline exactly? devm_request_threaded_irq_probe() is coming, right? If it is accepted this hunk is useless and soon should be replaced with proper one.

Quoted 6 lines

Such change is out of the scope of this series, there are two options that I'd prefer (in the listed order):

1. accept the patch as it is, this patch is not sent today the first time and at the current state it's correct.
2. not accept a change on this line

The 2 is what I commented here. This change should not be made and instead we should just switch all such users to new API, because this is preferred for all error messages, when applicable and does not result in lost context. If there was no such API, sure, but we have this API coming.

Quoted 4 lines

Replacing devm_request_irq belongs to another series and, besides, I don't want to ask Liao to hold on this series for such trivialities.

So the comment about this redundant and unneeded change, thus switching to new API you call 'triviality' but a comment of yours of changing the tone of error message to 'please' is appropriate.
https://lore.kernel.org/all/[email protected]/

That's double standards.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#10 lore raw

Re: [PATCH v3 2/9] i2c: mlxbf: Use dev_err_probe in probe function

Quoted 41 lines · Krzysztof Kozlowski
Quoted 40 lines · Andi Shyti

Hi Krzysztof,

Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Andi Shyti

Hi Krzysztof,

Quoted 23 lines · Krzysztof Kozlowski
Quoted 6 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

...

drivers/i2c/busses/i2c-mlxbf.c static int mlxbf_i2c_probe(struct platform_device *pdev) · line 2403

Quoted 10 lines
drivers/i2c/busses/i2c-mlxbf.c +2 -4
@@ -2413,10 +2399,8 @@ static int mlxbf_i2c_probe(struct platform_device *pdev)
 	ret = devm_request_irq(dev, irq, mlxbf_i2c_irq,
 			       IRQF_SHARED | IRQF_PROBE_SHARED,
 			       dev_name(dev), priv);
-	if (ret < 0) {
-		dev_err(dev, "Cannot get irq %d\n", irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Cannot get irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Quoted 5 lines
Quoted 1 line

Hmm, that's a bit borderline, I'd say. The change to

What's borderline exactly? devm_request_threaded_irq_probe() is coming, right? If it is accepted this hunk is useless and soon should be replaced with proper one.

Such change is out of the scope of this series, there are two options that I'd prefer (in the listed order):

Quoted 8 lines
Quoted 3 lines

1. accept the patch as it is, this patch is not sent today the first time and at the current state it's correct.
2. not accept a change on this line

The 2 is what I commented here. This change should not be made and instead we should just switch all such users to new API, because this is preferred for all error messages, when applicable and does not result in lost context. If there was no such API, sure, but we have this API coming.

To me the patch is correct... I am OK also with 2, but I find 1 more complete... let's say that it's a matter of taste?

Quoted 10 lines
Quoted 3 lines

Replacing devm_request_irq belongs to another series and, besides, I don't want to ask Liao to hold on this series for such trivialities.

So the comment about this redundant and unneeded change, thus switching to new API you call 'triviality' but a comment of yours of changing the tone of error message to 'please' is appropriate.
https://lore.kernel.org/all/[email protected]/

That's double standards.

That was a joke, the review was somewhere else in my comment.

Thanks for your inputs,
Andi

author
#12 lore raw

PATCH v3 3/9 i2c: xlp9xx: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-xlp9xx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-xlp9xx.c +2 -4
index f59e8c544f36..08a59a920929 100644
@@ -529,10 +529,8 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
 
 	err = devm_request_irq(&pdev->dev, priv->irq, xlp9xx_i2c_isr, 0,
 			       pdev->name, priv);
-	if (err) {
-		dev_err(&pdev->dev, "IRQ request failed!\n");
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err, "IRQ request failed!\n");
 
 	init_completion(&priv->msg_complete);
 	priv->adapter.dev.parent = &pdev->dev;
Signature · 1 line
2.25.1
#13 lore raw

Re: [PATCH v3 3/9] i2c: xlp9xx: Use dev_err_probe in probe function

Quoted 15 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-xlp9xx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-xlp9xx.c +0 -0
index f59e8c544f36..08a59a920929 100644

drivers/i2c/busses/i2c-xlp9xx.c static int xlp9xx_i2c_probe(struct platform_device *pdev) · line 533

Quoted 5 lines
drivers/i2c/busses/i2c-xlp9xx.c +0 -2
@@ -529,10 +529,8 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
 
 	err = devm_request_irq(&pdev->dev, priv->irq, xlp9xx_i2c_isr, 0,
 			       pdev->name, priv);
-	if (err) {
-		dev_err(&pdev->dev, "IRQ request failed!\n");

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#14 lore raw

PATCH v3 4/9 i2c: hisi: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-hisi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-hisi.c +4 -8
index e067671b3ce2..6fc8d6fa43b6 100644
@@ -462,18 +462,14 @@ static int hisi_i2c_probe(struct platform_device *pdev)
 	hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);
 
 	ret = devm_request_irq(dev, ctlr->irq, hisi_i2c_irq, 0, "hisi-i2c", ctlr);
-	if (ret) {
-		dev_err(dev, "failed to request irq handler, ret = %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to request irq handler\n");
 
 	ctlr->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
 	if (IS_ERR_OR_NULL(ctlr->clk)) {
 		ret = device_property_read_u64(dev, "clk_rate", &clk_rate_hz);
-		if (ret) {
-			dev_err(dev, "failed to get clock frequency, ret = %d\n", ret);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(dev, ret, "failed to get clock frequency\n");
 	} else {
 		clk_rate_hz = clk_get_rate(ctlr->clk);
 	}
Signature · 1 line
2.25.1
#15 lore raw

Re: [PATCH v3 4/9] i2c: hisi: Use dev_err_probe in probe function

Quoted 15 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-hisi.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-hisi.c +0 -0
index e067671b3ce2..6fc8d6fa43b6 100644

drivers/i2c/busses/i2c-hisi.c static int hisi_i2c_probe(struct platform_device *pdev) · line 466

Quoted 9 lines
drivers/i2c/busses/i2c-hisi.c +2 -4
@@ -462,18 +462,14 @@ static int hisi_i2c_probe(struct platform_device *pdev)
 	hisi_i2c_disable_int(ctlr, HISI_I2C_INT_ALL);
 
 	ret = devm_request_irq(dev, ctlr->irq, hisi_i2c_irq, 0, "hisi-i2c", ctlr);
-	if (ret) {
-		dev_err(dev, "failed to request irq handler, ret = %d\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to request irq handler\n");

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#16 lore raw

PATCH v3 5/9 i2c: qcom-cci: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-qcom-cci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-qcom-cci.c +2 -4
index 622dc14add9d..cf13abec05f1 100644
@@ -588,10 +588,8 @@ static int cci_probe(struct platform_device *pdev)
 	/* Clocks */
 
 	ret = devm_clk_bulk_get_all(dev, &cci->clocks);
-	if (ret < 1) {
-		dev_err(dev, "failed to get clocks %d\n", ret);
-		return ret;
-	}
+	if (ret < 1)
+		return dev_err_probe(dev, ret, "failed to get clocks\n");
 	cci->nclocks = ret;
 
 	/* Retrieve CCI clock rate */
Signature · 1 line
2.25.1
#17 lore raw

Re: [PATCH v3 5/9] i2c: qcom-cci: Use dev_err_probe in probe function

Quoted 15 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-qcom-cci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-qcom-cci.c +0 -0
index 622dc14add9d..cf13abec05f1 100644

drivers/i2c/busses/i2c-qcom-cci.c static int cci_probe(struct platform_device *pdev) · line 592

Quoted 9 lines
drivers/i2c/busses/i2c-qcom-cci.c +2 -4
@@ -588,10 +588,8 @@ static int cci_probe(struct platform_device *pdev)
 	/* Clocks */
 
 	ret = devm_clk_bulk_get_all(dev, &cci->clocks);
-	if (ret < 1) {
-		dev_err(dev, "failed to get clocks %d\n", ret);
-		return ret;
-	}
+	if (ret < 1)
+		return dev_err_probe(dev, ret, "failed to get clocks\n");

devm_clk_bulk_get_all() will already have printed a more useful/specific error message. Unfortunately will not be carried as the deferred probe reason, but this error will just indicate that some clock controller wasn't ready...

TL;DR I think we should just drop the error print from here instead.

Regards,
Bjorn

author
#18 lore raw

PATCH v3 6/9 i2c: pxa: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-pxa.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-pxa.c +3 -4
index 937f7eebe906..79df4da0166e 100644
@@ -1404,10 +1404,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 	strscpy(i2c->adap.name, "pxa_i2c-i2c", sizeof(i2c->adap.name));
 
 	i2c->clk = devm_clk_get(&dev->dev, NULL);
-	if (IS_ERR(i2c->clk)) {
-		dev_err(&dev->dev, "failed to get the clk: %ld\n", PTR_ERR(i2c->clk));
-		return PTR_ERR(i2c->clk);
-	}
+	if (IS_ERR(i2c->clk))
+		return dev_err_probe(&dev->dev, PTR_ERR(i2c->clk),
+				     "failed to get the clk\n");
 
 	i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[i2c_type].ibmr;
 	i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[i2c_type].idbr;
Signature · 1 line
2.25.1
author
#19 lore raw

PATCH v3 7/9 i2c: dln2: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-dln2.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-dln2.c +2 -4
index 4f02cc2fb567..631109c7a098 100644
@@ -218,10 +218,8 @@ static int dln2_i2c_probe(struct platform_device *pdev)
 
 	/* initialize the i2c interface */
 	ret = dln2_i2c_enable(dln2, true);
-	if (ret < 0) {
-		dev_err(dev, "failed to initialize adapter: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "failed to initialize adapter\n");
 
 	/* and finally attach to i2c layer */
 	ret = i2c_add_adapter(&dln2->adapter);
Signature · 1 line
2.25.1
author
#20 lore raw

PATCH v3 8/9 i2c: imx-lpi2c: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-imx-lpi2c.c +4 -8
index c3287c887c6f..bfa788b3775b 100644
@@ -569,10 +569,8 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
 		sizeof(lpi2c_imx->adapter.name));
 
 	ret = devm_clk_bulk_get_all(&pdev->dev, &lpi2c_imx->clks);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "can't get I2C peripheral clock, ret=%d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&pdev->dev, ret, "can't get I2C peripheral clock\n");
 	lpi2c_imx->num_clks = ret;
 
 	ret = of_property_read_u32(pdev->dev.of_node,
@@ -582,10 +580,8 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
 
 	ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0,
 			       pdev->name, lpi2c_imx);
-	if (ret) {
-		dev_err(&pdev->dev, "can't claim irq %d\n", irq);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "can't claim irq %d\n", irq);
 
 	i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx);
 	platform_set_drvdata(pdev, lpi2c_imx);
Signature · 1 line
2.25.1
#21 lore raw

Re: [PATCH v3 8/9] i2c: imx-lpi2c: Use dev_err_probe in probe function

Quoted 4 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles

drivers/i2c/busses/i2c-imx-lpi2c.c +0 -1
-EPROBE_DEFER nicely.

drivers/i2c/busses/i2c-imx-lpi2c.c static int lpi2c_imx_probe(struct platform_device *pdev) · line 584

Quoted 10 lines
drivers/i2c/busses/i2c-imx-lpi2c.c +2 -4
 
 
 	ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0,
 			       pdev->name, lpi2c_imx);
-	if (ret) {
-		dev_err(&pdev->dev, "can't claim irq %d\n", irq);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "can't claim irq %d\n", irq);

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#22 lore raw

PATCH v3 9/9 i2c: synquacer: Use dev_err_probe in probe function

In reply to Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

---
 drivers/i2c/busses/i2c-synquacer.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/i2c/busses/i2c-synquacer.c +10 -18
index 4cc196ca8f6d..bbea521b05dd 100644
@@ -557,20 +557,16 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
 		dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk);
 
 		ret = clk_prepare_enable(i2c->pclk);
-		if (ret) {
-			dev_err(&pdev->dev, "failed to enable clock (%d)\n",
-				ret);
-			return ret;
-		}
+		if (ret)
+			return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n");
 		i2c->pclkrate = clk_get_rate(i2c->pclk);
 	}
 
 	if (i2c->pclkrate < SYNQUACER_I2C_MIN_CLK_RATE ||
-	    i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE) {
-		dev_err(&pdev->dev, "PCLK missing or out of range (%d)\n",
-			i2c->pclkrate);
-		return -EINVAL;
-	}
+	    i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE)
+		return dev_err_probe(&pdev->dev, -EINVAL,
+				     "PCLK missing or out of range (%d)\n",
+				     i2c->pclkrate);
 
 	i2c->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(i2c->base))
@@ -582,10 +578,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, synquacer_i2c_isr,
 			       0, dev_name(&pdev->dev), i2c);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&pdev->dev, ret, "cannot claim IRQ %d\n", i2c->irq);
 
 	i2c->state = STATE_IDLE;
 	i2c->dev = &pdev->dev;
@@ -605,10 +599,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
 	synquacer_i2c_hw_init(i2c);
 
 	ret = i2c_add_numbered_adapter(&i2c->adapter);
-	if (ret) {
-		dev_err(&pdev->dev, "failed to add bus to i2c core\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "failed to add bus to i2c core\n");
 
 	platform_set_drvdata(pdev, i2c);
 
Signature · 1 line
2.25.1
#23 lore raw

Re: [PATCH v3 9/9] i2c: synquacer: Use dev_err_probe in probe function

Quoted 10 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

drivers/i2c/busses/i2c-synquacer.c +0 -0
 	i2c->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(i2c->base))

drivers/i2c/busses/i2c-synquacer.c static int synquacer_i2c_probe(struct platform_device *pdev) · line 583

Quoted 10 lines
drivers/i2c/busses/i2c-synquacer.c +2 -4
@@ -582,10 +578,8 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, synquacer_i2c_isr,
 			       0, dev_name(&pdev->dev), i2c);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&pdev->dev, ret, "cannot claim IRQ %d\n", i2c->irq);
 

I don't think this is needed:
https://lore.kernel.org/all/[email protected]/

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Reviewed-by on v3 9/9
#24 lore raw

Re: [PATCH v3 9/9] i2c: synquacer: Use dev_err_probe in probe function

In reply to Liao Chang

Hi Liao,

Quoted 5 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

After some discussions and time, I think it's right to r-b this patch. If you agree more with Krzysztof, feel free to follow his recommendation and send another version otherwise I will go ahead and take this series in my branch. I do not really mind, both arguments are valid.

Thanks,
Andi

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#25 lore raw

Re: [PATCH v3 9/9] i2c: synquacer: Use dev_err_probe in probe function

Hi Andi and Krzysztof,

Quoted 7 lines · Andi Shyti

Hi Liao,

Quoted 4 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

Quoted 7 lines
Quoted 1 line

After some discussions and time, I think it's right to r-b this patch. If you agree more with Krzysztof, feel free to follow his recommendation and send another version otherwise I will go ahead and take this series in my branch. I do not really mind, both arguments are valid.

I saw that Frank Li developed some new APIs that look like they would be very helpful for aligning the error messages of devm_request_irq in device probes. However, the patches have been pending for weeks and the author hasn't sent a new version. So I'm not planning to switch to the new APIs in this patch series, if there are no objections.

Do I need to resend a new revision to add your R-B at this patch?

Thanks.

Quoted 5 lines

Thanks,
Andi

Signature · 2 lines
BR
Liao, Chang
maintainer
#26 lore raw

Re: [PATCH v3 9/9] i2c: synquacer: Use dev_err_probe in probe function

Hi Liao,

Quoted 18 lines · Chang

Hi Andi and Krzysztof,

Quoted 7 lines · Andi Shyti

Hi Liao,

Quoted 4 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

Quoted 7 lines
Quoted 1 line

After some discussions and time, I think it's right to r-b this patch. If you agree more with Krzysztof, feel free to follow his recommendation and send another version otherwise I will go ahead and take this series in my branch. I do not really mind, both arguments are valid.

Quoted 7 lines

I saw that Frank Li developed some new APIs that look like they would be very helpful for aligning the error messages of devm_request_irq in device probes. However, the patches have been pending for weeks and the author hasn't sent a new version. So I'm not planning to switch to the new APIs in this patch series, if there are no objections.

Do I need to resend a new revision to add your R-B at this patch?

no, no need. I'm also going to fix a typo in the commit message (messge/message) that Markus has pointed out.

Thanks for this series of cleanups,
Andi

Quoted 11 lines

Thanks.

Quoted 5 lines

Thanks,
Andi

Signature · 2 lines
BR
Liao, Chang
maintainer
#27 lore raw
In reply to Liao Chang

Hi

Quoted 9 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

NOTICE: dev_err_probe always print the second parameter that happens to be the return value, hence the return errno will be removed from the third parameter to avoid a redundant error message.

[...]

With the messge/message change in the commit log, applied to i2c/andi-for-next on

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Please note that this patch may still undergo further evaluation and the final decision will be made in collaboration with Wolfram.

Thank you,
Andi

Patches applied
===============
[1/9] i2c: bcm2835: Use dev_err_probe in probe function

      commit: 7aec2f39a1a4be99a7872e2342a69b96396c3e0c
[2/9] i2c: mlxbf: Use dev_err_probe in probe function
      commit: 45a7a0524bff52360f82277f165bbdef7a199484
[3/9] i2c: xlp9xx: Use dev_err_probe in probe function
      commit: 9a648b3f56c49551081b9560392e9a640aa3d5cb
[4/9] i2c: hisi: Use dev_err_probe in probe function
      commit: 3c5e6ae40164ba6af1efaa1ca94e2cdea0c8f25e
[5/9] i2c: qcom-cci: Use dev_err_probe in probe function
      commit: 605efbf43813857d8110ca0b5bda75f93426a789
[6/9] i2c: pxa: Use dev_err_probe in probe function
      commit: d29066600a85b15077221be404a38d9c4bf5b888
[7/9] i2c: dln2: Use dev_err_probe in probe function
      commit: 235712aa7ebf75a8442905ae672c02a4f9f8468c
[8/9] i2c: imx-lpi2c: Use dev_err_probe in probe function
      commit: 5d51af11f41eb348d9c3ccb5c74ffa9078673166
[9/9] i2c: synquacer: Use dev_err_probe in probe function
      commit: 7a34bab2daeaae6d2f32bdfa20b876a8f210cd7a

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Applied
#28 lore raw
Quoted 12 lines · Andi Shyti

Hi

Quoted 9 lines · Liao Chang

Use the dev_err_probe function instead of dev_err in the probe function so that the printed messge includes the return value and also handles -EPROBE_DEFER nicely.

NOTICE: dev_err_probe always print the second parameter that happens to be the return value, hence the return errno will be removed from the third parameter to avoid a redundant error message.

[...]

Applied to for-next (via Andi's branch), thanks!

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel