Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752971AbdLHJ4y (ORCPT ); Fri, 8 Dec 2017 04:56:54 -0500 Received: from mail-it0-f51.google.com ([209.85.214.51]:43650 "EHLO mail-it0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753463AbdLHJip (ORCPT ); Fri, 8 Dec 2017 04:38:45 -0500 X-Google-Smtp-Source: AGs4zMZChbCNP1r4eJjkz/DjT8+arG077U26Im7ATUjv3r1W0xkp2QoYFyMcXMKsxa9sWORkaIowRg== Subject: Re: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking To: Sergei Shtylyov , David Miller References: <1512409703-20881-5-git-send-email-arvind.yadav.cs@gmail.com> <20171204.132556.1601454745789376393.davem@davemloft.net> <39363858-995c-eea4-070e-b21a7ac49bec@gmail.com> <20171205.104947.121188625730183933.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 From: arvindY Message-ID: <5A2A5D9E.9040907@gmail.com> Date: Fri, 8 Dec 2017 15:08:38 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2065 Lines: 61 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 >>>> 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