diff mbox

[05/10] net: ethernet: i825xx: Fix platform_get_irq's error checking

Message ID 1512242782-7134-6-git-send-email-arvind.yadav.cs@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arvind Yadav Dec. 2, 2017, 7:26 p.m. UTC
The platform_get_irq() function returns negative if an error occurs.
zero or positive number on success. platform_get_irq() error checking
for zero is not correct.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/net/ethernet/i825xx/sni_82596.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Sergei Shtylyov Dec. 2, 2017, 8:08 p.m. UTC | #1
Hello.

On 12/02/2017 10:26 PM, Arvind Yadav wrote:

> The platform_get_irq() function returns negative if an error occurs.
> zero or positive number on success. platform_get_irq() error checking
> for zero is not correct.

    The why you consider returning 0 a sign of failure?

> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>   drivers/net/ethernet/i825xx/sni_82596.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/i825xx/sni_82596.c b/drivers/net/ethernet/i825xx/sni_82596.c
> index b2c04a7..a6d56f5 100644
> --- a/drivers/net/ethernet/i825xx/sni_82596.c
> +++ b/drivers/net/ethernet/i825xx/sni_82596.c
> @@ -120,9 +120,10 @@ static int sni_82596_probe(struct platform_device *dev)
>   	netdevice->dev_addr[5] = readb(eth_addr + 0x06);
>   	iounmap(eth_addr);
>   
> -	if (!netdevice->irq) {
> +	if (netdevice->irq <= 0) {
>   		printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
>   			__FILE__, netdevice->base_addr);
> +		retval = netdevice->irq ? netdevice->irq : -ENODEV;
>   		goto probe_failed;
>   	}
>   

MBR, Sergei
Arvind Yadav Dec. 2, 2017, 8:22 p.m. UTC | #2
Hi Sergei,

On Sunday 03 December 2017 01:38 AM, Sergei Shtylyov wrote:
> Hello.
>
> On 12/02/2017 10:26 PM, Arvind Yadav wrote:
>
>> The platform_get_irq() function returns negative if an error occurs.
>> zero or positive number on success. platform_get_irq() error checking
>> for zero is not correct.
>
>    The why you consider returning 0 a sign of failure?
Here, Returning 0 is a problem. Because IRQ0 is always a problem.
This function is for getting an IRQ for a device. So we should check for
0 also.
>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>>   drivers/net/ethernet/i825xx/sni_82596.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/i825xx/sni_82596.c 
>> b/drivers/net/ethernet/i825xx/sni_82596.c
>> index b2c04a7..a6d56f5 100644
>> --- a/drivers/net/ethernet/i825xx/sni_82596.c
>> +++ b/drivers/net/ethernet/i825xx/sni_82596.c
>> @@ -120,9 +120,10 @@ static int sni_82596_probe(struct 
>> platform_device *dev)
>>       netdevice->dev_addr[5] = readb(eth_addr + 0x06);
>>       iounmap(eth_addr);
>>   -    if (!netdevice->irq) {
>> +    if (netdevice->irq <= 0) {
>>           printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
>>               __FILE__, netdevice->base_addr);
>> +        retval = netdevice->irq ? netdevice->irq : -ENODEV;
>>           goto probe_failed;
>>       }
>
> MBR, Sergei
~arvind
diff mbox

Patch

diff --git a/drivers/net/ethernet/i825xx/sni_82596.c b/drivers/net/ethernet/i825xx/sni_82596.c
index b2c04a7..a6d56f5 100644
--- a/drivers/net/ethernet/i825xx/sni_82596.c
+++ b/drivers/net/ethernet/i825xx/sni_82596.c
@@ -120,9 +120,10 @@  static int sni_82596_probe(struct platform_device *dev)
 	netdevice->dev_addr[5] = readb(eth_addr + 0x06);
 	iounmap(eth_addr);
 
-	if (!netdevice->irq) {
+	if (netdevice->irq <= 0) {
 		printk(KERN_ERR "%s: IRQ not found for i82596 at 0x%lx\n",
 			__FILE__, netdevice->base_addr);
+		retval = netdevice->irq ? netdevice->irq : -ENODEV;
 		goto probe_failed;
 	}