diff mbox

power: supply: cpcap-battery: Fix platform_get_irq_byname's error checking

Message ID 638d9bb5ac4c0ef44d3e83cc0f74d6e80cddcf7d.1511542695.git.arvind.yadav.cs@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Arvind Yadav Nov. 24, 2017, 5:01 p.m. UTC
The platform_get_irq_byname() function returns -1 if an error occurs.
zero or positive number on success. platform_get_irq_byname() error
checking for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/power/supply/cpcap-battery.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sebastian Reichel Dec. 1, 2017, 3:30 p.m. UTC | #1
Hi,

On Fri, Nov 24, 2017 at 10:31:40PM +0530, Arvind Yadav wrote:
> The platform_get_irq_byname() function returns -1 if an error occurs.
> zero or positive number on success. platform_get_irq_byname() error
> checking for zero is not correct.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/cpcap-battery.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
> index ee71a2b..98ba078 100644
> --- a/drivers/power/supply/cpcap-battery.c
> +++ b/drivers/power/supply/cpcap-battery.c
> @@ -586,8 +586,8 @@ static int cpcap_battery_init_irq(struct platform_device *pdev,
>  	int irq, error;
>  
>  	irq = platform_get_irq_byname(pdev, name);
> -	if (!irq)
> -		return -ENODEV;
> +	if (irq < 0)
> +		return irq;
>  
>  	error = devm_request_threaded_irq(ddata->dev, irq, NULL,
>  					  cpcap_battery_irq_thread,
> -- 
> 2.7.4
>
diff mbox

Patch

diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c
index ee71a2b..98ba078 100644
--- a/drivers/power/supply/cpcap-battery.c
+++ b/drivers/power/supply/cpcap-battery.c
@@ -586,8 +586,8 @@  static int cpcap_battery_init_irq(struct platform_device *pdev,
 	int irq, error;
 
 	irq = platform_get_irq_byname(pdev, name);
-	if (!irq)
-		return -ENODEV;
+	if (irq < 0)
+		return irq;
 
 	error = devm_request_threaded_irq(ddata->dev, irq, NULL,
 					  cpcap_battery_irq_thread,