Skip to contentSkip to conversation

clocksource: em_sti: fix error return codes in em_sti_probe()

PATCH Superseded Gustavo A. R. Silva 3 participants 5 messages Jun 30, 2017 – Aug 1, 2017 Clocksource, clockevent drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clocksource: em_sti: fix error return codes in em_sti_probe()

Propagate the return values of platform_get_irq and devm_request_irq on failure.

---
 drivers/clocksource/em_sti.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/clocksource/em_sti.c +5 -4
index bc48cbf..c4818dd 100644
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		return -EINVAL;
+		return irq;
 	}
 
 	/* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
-	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+	irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
 			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			     dev_name(&pdev->dev), p)) {
+			     dev_name(&pdev->dev), p);
+	if (irq) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		return -ENOENT;
+		return irq;
 	}
 
 	/* get hold of clock */
Signature · 1 line
2.5.0
#1 lore raw
Quoted 25 lines · Gustavo A. R. Silva

Propagate the return values of platform_get_irq and devm_request_irq on failure.

---
 drivers/clocksource/em_sti.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/clocksource/em_sti.c +1 -1
index bc48cbf..c4818dd 100644
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "failed to get irq\n");
-               return -EINVAL;
+               return irq;
        }
 
        /* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
        if (IS_ERR(p->base))
                return PTR_ERR(p->base);
 

drivers/clocksource/em_sti.c static int em_sti_probe(struct platform_device *pdev) · line 323

Quoted 10 lines
drivers/clocksource/em_sti.c +4 -3
-       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+       irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
                             IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-                            dev_name(&pdev->dev), p)) {
+                            dev_name(&pdev->dev), p);
+       if (irq) {
                dev_err(&pdev->dev, "failed to request low IRQ\n");
-               return -ENOENT;
+               return irq;
        }

This works. Yet I think that 'ret' would be a better candidate for taking the result of devm_request_irq, since it doesn't return the irq number on success. Should someone decide to reference irq at a later point in the code, this has to be changed.

#2 lore raw

Hi Frans,

Quoting Frans Klaver <[email protected]>:

Quoted 27 lines
Quoted 25 lines · Gustavo A. R. Silva

Propagate the return values of platform_get_irq and devm_request_irq on failure.

---
 drivers/clocksource/em_sti.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/clocksource/em_sti.c +1 -1
index bc48cbf..c4818dd 100644
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(&pdev->dev, "failed to get irq\n");
-               return -EINVAL;
+               return irq;
        }
 
        /* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
        if (IS_ERR(p->base))
                return PTR_ERR(p->base);
 
Quoted 15 lines

drivers/clocksource/em_sti.c static int em_sti_probe(struct platform_device *pdev) · line 323

Quoted 10 lines
drivers/clocksource/em_sti.c +4 -3
-       if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+       irq = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
                             IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-                            dev_name(&pdev->dev), p)) {
+                            dev_name(&pdev->dev), p);
+       if (irq) {
                dev_err(&pdev->dev, "failed to request low IRQ\n");
-               return -ENOENT;
+               return irq;
        }

This works. Yet I think that 'ret' would be a better candidate for taking the result of devm_request_irq, since it doesn't return the irq number on success. Should someone decide to reference irq at a later point in the code, this has to be changed.

Good point. I'll change it and send a new patch shortly.

Thanks!
--
Gustavo A. R. Silva

#3 lore raw

PATCH v2 1/1 clocksource: em_sti: fix error return codes in em_sti_probe()

Propagate the return values of platform_get_irq and devm_request_irq on failure.

---
Changes in v2:
Use 'ret' instead of 'irq' for taking the result of devm_request_irq.

 drivers/clocksource/em_sti.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/clocksource/em_sti.c +6 -5
index bc48cbf..269db74 100644
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		return -EINVAL;
+		return irq;
 	}
 
 	/* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
 	if (IS_ERR(p->base))
 		return PTR_ERR(p->base);
 
-	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
-			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
-			     dev_name(&pdev->dev), p)) {
+	ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
+			       IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+			       dev_name(&pdev->dev), p);
+	if (ret) {
 		dev_err(&pdev->dev, "failed to request low IRQ\n");
-		return -ENOENT;
+		return ret;
 	}
 
 	/* get hold of clock */
Signature · 1 line
2.5.0
#4 lore raw
Quoted 6 lines · Gustavo A. R. Silva

Propagate the return values of platform_get_irq and devm_request_irq on failure.

---

Applied, thanks.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog