Skip to contentSkip to conversation

drivers/rtc/rtc-jz4740.c: fix error check

PATCH In review Nicolas Kaiser 3 participants 4 messages Mar 30, 2011 – Mar 31, 2011

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

PATCH 1/1 drivers/rtc/rtc-jz4740.c: fix error check

Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.

---
Untested.

 drivers/rtc/rtc-jz4740.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-jz4740.c +3 -2
index b647363..ba91bc6 100644
@@ -220,12 +220,13 @@ static int __devinit jz4740_rtc_probe(struct platform_device *pdev)
 	if (!rtc)
 		return -ENOMEM;
 
-	rtc->irq = platform_get_irq(pdev, 0);
-	if (rtc->irq < 0) {
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0) {
 		ret = -ENOENT;
 		dev_err(&pdev->dev, "Failed to get platform irq\n");
 		goto err_free;
 	}
+	rtc->irq = ret;
 
 	rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!rtc->mem) {
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Nicolas Kaiser

Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.

But while were at it we should change it, so that the result of platform_get_irq becomes the return value in case of an error instead of using the wrong or at least confusing -ENOENT.

Quoted 26 lines

---
Untested.

 drivers/rtc/rtc-jz4740.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-jz4740.c +3 -2
index b647363..ba91bc6 100644
@@ -220,12 +220,13 @@ static int __devinit jz4740_rtc_probe(struct platform_device *pdev)
 	if (!rtc)
 		return -ENOMEM;
 
-	rtc->irq = platform_get_irq(pdev, 0);
-	if (rtc->irq < 0) {
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0) {
 		ret = -ENOENT;
 		dev_err(&pdev->dev, "Failed to get platform irq\n");
 		goto err_free;
 	}
+	rtc->irq = ret;
 
 	rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!rtc->mem) {
#2 lore raw

PATCH 1/1 drivers/rtc/rtc-jz4740.c: fix error check v2

Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.

v2: return error code from platform_get_irq() instead of -ENOENT.

---
 drivers/rtc/rtc-jz4740.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-jz4740.c +3 -3
index b647363..efd9691 100644
@@ -220,12 +220,12 @@ static int __devinit jz4740_rtc_probe(struct platform_device *pdev)
 	if (!rtc)
 		return -ENOMEM;
 
-	rtc->irq = platform_get_irq(pdev, 0);
-	if (rtc->irq < 0) {
-		ret = -ENOENT;
+	ret = platform_get_irq(pdev, 0);
+	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to get platform irq\n");
 		goto err_free;
 	}
+	rtc->irq = ret;
 
 	rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!rtc->mem) {
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#3 lore raw

Re: [rtc-linux] [PATCH] drivers/rtc/rtc-jz4740.c: fix error check v2

2011/3/31 Nicolas Kaiser <[email protected]>:

Quoted 17 lines

Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.

v2: return error code from platform_get_irq() instead of -ENOENT.

---
 drivers/rtc/rtc-jz4740.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-jz4740.c +0 -0
index b647363..efd9691 100644
@@ -220,12 +220,12 @@ static int __devinit jz4740_rtc_probe(struct platform_device *pdev)
        if (!rtc)
                return -ENOMEM;
 

drivers/rtc/rtc-jz4740.c static int __devinit jz4740_rtc_probe(struct platform_device *pdev) · line 229

Quoted 10 lines
drivers/rtc/rtc-jz4740.c +3 -3
-       rtc->irq = platform_get_irq(pdev, 0);
-       if (rtc->irq < 0) {
-               ret = -ENOENT;
+       ret = platform_get_irq(pdev, 0);
+       if (ret < 0) {
                dev_err(&pdev->dev, "Failed to get platform irq\n");
                goto err_free;
        }
+       rtc->irq = ret;
 

This patch looks good to me.

Quoted 10 lines
drivers/rtc/rtc-jz4740.c +0 -1
        rtc->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!rtc->mem) {
--

1.7.3.4

--
You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.

Signature · 10 lines
*linux-arm-kernel mailing list
mail addr:[email protected]
you can subscribe by:
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

* linux-arm-NUC900 mailing list
mail addr:[email protected]
main web: https://groups.google.com/group/NUC900
you can subscribe it by sending me mail:
[email protected]