From: arvind.yadav.cs@gmail.com (arvindY)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking
Date: Fri, 8 Dec 2017 15:08:38 +0530 [thread overview]
Message-ID: <5A2A5D9E.9040907@gmail.com> (raw)
In-Reply-To: <d0b7e1cc-4190-437a-6461-35cee6edc203@cogentembedded.com>
Hi David,
On Wednesday 06 December 2017 05:49 PM, Sergei Shtylyov wrote:
> On 12/05/2017 06:49 PM, David Miller wrote:
>
>>>> From: Arvind Yadav <arvind.yadav.cs@gmail.com>
>>>> Date: Mon, 4 Dec 2017 23:18:20 +0530
>>>>
>>>>> @@ -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;
>>>>> }
>>>> Ok, thinking about this some more...
>>>>
>>>> It is impossible to use platform_get_irq() without every single call
>>>> site having this funny:
>>>>
>>>> ret = val ? val : -ENODEV;
>>>>
>>>> sequence.
>>>>
>>>> This is unnecessary duplication and it is also error prone, so I
>>>> really think this logic belongs in platform_get_irq() itself. It can
>>>> convert '0' to -ENODEV and that way we need no special logic in the
>>>> callers at all.
>>> platform_get_irq() will return 0 only for sparc, If sparc initialize
>>> platform
>>> data irq[PROMINTR_MAX] as zero. Otherwise platform_get_irq() will
>>> never return
>>> 0. It will return either IRQ number or error (as negative number). But
>>> I am getting
>>> review comment by reviewer/maintainer in other subsystem to add check
>>> for
>>> zero. So I have done same changes here. Please correct me if i am
>>> wrong.
>>
>> If you make the change that I suggest, you instead can check for
>
> I assume such change is needed only for the SPARC-specific section
> of platform_get_irq()?
>
>> '-ENODEV' to mean no IRQ.
>
> No specific error check is needed, just irq < 0 check should be
> enough...
> Also, looking at platform_get_irq(), -ENXIO should be returned in this
> case.
>
> MBR, Sergei
Is it ok. If We will add a check for only < 0.
Regards
Arvind
WARNING: multiple messages have this Message-ID (diff)
From: arvindY <arvind.yadav.cs@gmail.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
David Miller <davem@davemloft.net>
Cc: wg@grandegger.com, mkl@pengutronix.de, michal.simek@xilinx.com,
opendmb@gmail.com, f.fainelli@gmail.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org
Subject: Re: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking
Date: Fri, 8 Dec 2017 15:08:38 +0530 [thread overview]
Message-ID: <5A2A5D9E.9040907@gmail.com> (raw)
In-Reply-To: <d0b7e1cc-4190-437a-6461-35cee6edc203@cogentembedded.com>
Hi David,
On Wednesday 06 December 2017 05:49 PM, Sergei Shtylyov wrote:
> On 12/05/2017 06:49 PM, David Miller wrote:
>
>>>> From: Arvind Yadav <arvind.yadav.cs@gmail.com>
>>>> Date: Mon, 4 Dec 2017 23:18:20 +0530
>>>>
>>>>> @@ -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;
>>>>> }
>>>> Ok, thinking about this some more...
>>>>
>>>> It is impossible to use platform_get_irq() without every single call
>>>> site having this funny:
>>>>
>>>> ret = val ? val : -ENODEV;
>>>>
>>>> sequence.
>>>>
>>>> This is unnecessary duplication and it is also error prone, so I
>>>> really think this logic belongs in platform_get_irq() itself. It can
>>>> convert '0' to -ENODEV and that way we need no special logic in the
>>>> callers at all.
>>> platform_get_irq() will return 0 only for sparc, If sparc initialize
>>> platform
>>> data irq[PROMINTR_MAX] as zero. Otherwise platform_get_irq() will
>>> never return
>>> 0. It will return either IRQ number or error (as negative number). But
>>> I am getting
>>> review comment by reviewer/maintainer in other subsystem to add check
>>> for
>>> zero. So I have done same changes here. Please correct me if i am
>>> wrong.
>>
>> If you make the change that I suggest, you instead can check for
>
> I assume such change is needed only for the SPARC-specific section
> of platform_get_irq()?
>
>> '-ENODEV' to mean no IRQ.
>
> No specific error check is needed, just irq < 0 check should be
> enough...
> Also, looking at platform_get_irq(), -ENXIO should be returned in this
> case.
>
> MBR, Sergei
Is it ok. If We will add a check for only < 0.
Regards
Arvind
WARNING: multiple messages have this Message-ID (diff)
From: arvindY <arvind.yadav.cs@gmail.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
David Miller <davem@davemloft.net>
Cc: f.fainelli@gmail.com, netdev@vger.kernel.org,
michal.simek@xilinx.com, linux-kernel@vger.kernel.org,
opendmb@gmail.com, mkl@pengutronix.de,
linux-arm-kernel@lists.infradead.org, wg@grandegger.com
Subject: Re: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking
Date: Fri, 8 Dec 2017 15:08:38 +0530 [thread overview]
Message-ID: <5A2A5D9E.9040907@gmail.com> (raw)
In-Reply-To: <d0b7e1cc-4190-437a-6461-35cee6edc203@cogentembedded.com>
Hi David,
On Wednesday 06 December 2017 05:49 PM, Sergei Shtylyov wrote:
> On 12/05/2017 06:49 PM, David Miller wrote:
>
>>>> From: Arvind Yadav <arvind.yadav.cs@gmail.com>
>>>> Date: Mon, 4 Dec 2017 23:18:20 +0530
>>>>
>>>>> @@ -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;
>>>>> }
>>>> Ok, thinking about this some more...
>>>>
>>>> It is impossible to use platform_get_irq() without every single call
>>>> site having this funny:
>>>>
>>>> ret = val ? val : -ENODEV;
>>>>
>>>> sequence.
>>>>
>>>> This is unnecessary duplication and it is also error prone, so I
>>>> really think this logic belongs in platform_get_irq() itself. It can
>>>> convert '0' to -ENODEV and that way we need no special logic in the
>>>> callers at all.
>>> platform_get_irq() will return 0 only for sparc, If sparc initialize
>>> platform
>>> data irq[PROMINTR_MAX] as zero. Otherwise platform_get_irq() will
>>> never return
>>> 0. It will return either IRQ number or error (as negative number). But
>>> I am getting
>>> review comment by reviewer/maintainer in other subsystem to add check
>>> for
>>> zero. So I have done same changes here. Please correct me if i am
>>> wrong.
>>
>> If you make the change that I suggest, you instead can check for
>
> I assume such change is needed only for the SPARC-specific section
> of platform_get_irq()?
>
>> '-ENODEV' to mean no IRQ.
>
> No specific error check is needed, just irq < 0 check should be
> enough...
> Also, looking at platform_get_irq(), -ENXIO should be returned in this
> case.
>
> MBR, Sergei
Is it ok. If We will add a check for only < 0.
Regards
Arvind
next prev parent reply other threads:[~2017-12-08 9:38 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 17:48 [PATCH 0/7 v2] net: Fix platform_get_irq's error checking Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` [PATCH 1/7 v2] net: bcmgenet: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-05 1:01 ` Doug Berger
2017-12-05 1:01 ` Doug Berger
2017-12-04 17:48 ` [PATCH 2/7 v2] net: ezchip: nps_enet: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` [PATCH 3/7 v2] can: xilinx: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` [PATCH 4/7 v2] net: ethernet: i825xx: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 18:25 ` David Miller
2017-12-04 18:25 ` David Miller
2017-12-05 5:34 ` Arvind Yadav
2017-12-05 5:34 ` Arvind Yadav
2017-12-05 15:49 ` David Miller
2017-12-05 15:49 ` David Miller
2017-12-06 12:19 ` Sergei Shtylyov
2017-12-06 12:19 ` Sergei Shtylyov
2017-12-08 9:38 ` arvindY [this message]
2017-12-08 9:38 ` arvindY
2017-12-08 9:38 ` arvindY
2017-12-05 10:12 ` Sergei Shtylyov
2017-12-05 10:12 ` Sergei Shtylyov
2017-12-05 10:58 ` Russell King - ARM Linux
2017-12-05 10:58 ` Russell King - ARM Linux
2017-12-04 17:48 ` [PATCH 5/7 v2] net: ethernet: natsemi: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` [PATCH 6/7 v2] net: ethernet: smsc: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-04 17:48 ` [PATCH 7/7 v2] net: fjes: " Arvind Yadav
2017-12-04 17:48 ` Arvind Yadav
2017-12-05 9:54 ` [PATCH 0/7 v2] net: " Sergei Shtylyov
2017-12-05 9:54 ` Sergei Shtylyov
2017-12-05 9:57 ` Sergei Shtylyov
2017-12-05 9:57 ` Sergei Shtylyov
2017-12-05 10:02 ` Arvind Yadav
2017-12-05 10:02 ` Arvind Yadav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5A2A5D9E.9040907@gmail.com \
--to=arvind.yadav.cs@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.