Skip to contentSkip to conversation

i2c: exynos5: fix platform_get_irq error handling

PATCH In review Martin Kaiser 2 participants 8 messages Oct 27, 2020 – Nov 2, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: exynos5: fix platform_get_irq error handling

platform_get_irq already prints an error message if the requested irq was not found. Don't print another message in the driver.

If platform_get_irq returns an error, relay this error to the caller of the probe function. Don't change all errors to -EINVAL. This breaks the case where platform_get_irq returns -EPROBE_DEFER.

platform_get_irq never returns 0. Don't check for this. Make it clear that the error path always returns a negative error code.

---
 drivers/i2c/busses/i2c-exynos5.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/busses/i2c-exynos5.c +1 -4
index 6ce3ec03b595..20a9881a0d6c 100644
@@ -778,11 +778,8 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 	init_completion(&i2c->msg_complete);
 
 	i2c->irq = ret = platform_get_irq(pdev, 0);
-	if (ret <= 0) {
-		dev_err(&pdev->dev, "cannot find HS-I2C IRQ\n");
-		ret = -EINVAL;
+	if (ret < 0)
 		goto err_clk;
-	}
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
 			       IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 9 lines · Martin Kaiser

platform_get_irq already prints an error message if the requested irq was not found. Don't print another message in the driver.

If platform_get_irq returns an error, relay this error to the caller of the probe function. Don't change all errors to -EINVAL. This breaks the case where platform_get_irq returns -EPROBE_DEFER.

platform_get_irq never returns 0. Don't check for this. Make it clear that the error path always returns a negative error code.

These should be three separate commits.

Best regards,
Krzysztof

#2 lore raw

PATCH v2 1/3 i2c: exynos5: remove duplicate error message

In reply to Martin Kaiser

platform_get_irq already prints an error message if the requested irq was not found. Don't print another message in the driver.

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 1 -
 1 file changed, 1 deletion(-)
drivers/i2c/busses/i2c-exynos5.c +0 -1
index 6ce3ec03b595..c5f5fb28762d 100644
@@ -779,7 +779,6 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 
 	i2c->irq = ret = platform_get_irq(pdev, 0);
 	if (ret <= 0) {
-		dev_err(&pdev->dev, "cannot find HS-I2C IRQ\n");
 		ret = -EINVAL;
 		goto err_clk;
 	}
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 2/3 i2c: exynos5: fix platform_get_irq error handling

If platform_get_irq returns an error, relay this error to the caller of the probe function. Don't change all errors to -EINVAL. This breaks the case where platform_get_irq returns -EPROBE_DEFER.

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/busses/i2c-exynos5.c +1 -3
index c5f5fb28762d..fad1c52857aa 100644
@@ -778,10 +778,8 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 	init_completion(&i2c->msg_complete);
 
 	i2c->irq = ret = platform_get_irq(pdev, 0);
-	if (ret <= 0) {
-		ret = -EINVAL;
+	if (ret <= 0)
 		goto err_clk;
-	}
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
 			       IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c);
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 2/3
#4 lore raw
Quoted 4 lines · Martin Kaiser

If platform_get_irq returns an error, relay this error to the caller of the probe function. Don't change all errors to -EINVAL. This breaks the case where platform_get_irq returns -EPROBE_DEFER.

Quoted 8 lines

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Best regards,
Krzysztof

#5 lore raw

PATCH v2 3/3 i2c: exynos5: don't check for irq 0

In reply to Martin Kaiser

platform_get_irq never returns 0. Don't check for this. Make it clear that the error path always returns a negative error code.

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-exynos5.c +1 -1
index fad1c52857aa..20a9881a0d6c 100644
@@ -778,7 +778,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 	init_completion(&i2c->msg_complete);
 
 	i2c->irq = ret = platform_get_irq(pdev, 0);
-	if (ret <= 0)
+	if (ret < 0)
 		goto err_clk;
 
 	ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH v2 3/3] i2c: exynos5: don't check for irq 0

Quoted 11 lines · Martin Kaiser

platform_get_irq never returns 0. Don't check for this. Make it clear that the error path always returns a negative error code.

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Best regards,
Krzysztof

maintainer Reviewed-by on v2 1/3
#7 lore raw

Re: [PATCH v2 1/3] i2c: exynos5: remove duplicate error message

In reply to Martin Kaiser
Quoted 10 lines · Martin Kaiser

platform_get_irq already prints an error message if the requested irq was not found. Don't print another message in the driver.

---
changes in v2
- split the patch in three parts

 drivers/i2c/busses/i2c-exynos5.c | 1 -
 1 file changed, 1 deletion(-)

Best regards,
Krzysztof