Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753297AbdLEKM3 (ORCPT ); Tue, 5 Dec 2017 05:12:29 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42069 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900AbdLEKM0 (ORCPT ); Tue, 5 Dec 2017 05:12:26 -0500 X-Google-Smtp-Source: AGs4zMaC4Qs0KT1z7xniZnahTzpPsgm7wS8lXIERNm6fjypmBGORkrtwPhd9T4zPkOuPB+XsoHxCgQ== Subject: Re: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking To: David Miller , arvind.yadav.cs@gmail.com 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 References: <1512409703-20881-1-git-send-email-arvind.yadav.cs@gmail.com> <1512409703-20881-5-git-send-email-arvind.yadav.cs@gmail.com> <20171204.132556.1601454745789376393.davem@davemloft.net> From: Sergei Shtylyov Message-ID: <791fdb7d-e0ec-eefb-c703-205c039eddc3@cogentembedded.com> Date: Tue, 5 Dec 2017 13:12:23 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171204.132556.1601454745789376393.davem@davemloft.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1149 Lines: 40 On 12/4/2017 9:25 PM, David Miller wrote: >> @@ -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. Well, we can have: return r && r->start ? r->start : -ENXIO; instead of: return r ? r->start : -ENXIO; at the end of platform_get_irq(). But I don't really think it's worth doing -- request_irq() doesn't filter out IRQ0 anyway, IIRC... MBR, Sergei