diff mbox

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

Message ID 20110330181201.29e473bf@absol.kitzblitz
State Superseded
Headers show

Commit Message

Nicolas Kaiser March 30, 2011, 4:12 p.m. UTC
Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.

Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
---
Untested.

 drivers/rtc/rtc-jz4740.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Comments

Lars-Peter Clausen March 30, 2011, 4:37 p.m. UTC | #1
On 03/30/2011 06:12 PM, Nicolas Kaiser wrote:
> Checking 'rtc->irq < 0' doesn't work because 'rtc->irq' is unsigned.
> 
> Signed-off-by: Nicolas Kaiser <nikai@nikai.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>

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.

> ---
> Untested.
> 
>  drivers/rtc/rtc-jz4740.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
> index b647363..ba91bc6 100644
> --- a/drivers/rtc/rtc-jz4740.c
> +++ b/drivers/rtc/rtc-jz4740.c
> @@ -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) {
diff mbox

Patch

diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c
index b647363..ba91bc6 100644
--- a/drivers/rtc/rtc-jz4740.c
+++ b/drivers/rtc/rtc-jz4740.c
@@ -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) {