Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbdLDS0C (ORCPT ); Mon, 4 Dec 2017 13:26:02 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:51318 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbdLDSZ6 (ORCPT ); Mon, 4 Dec 2017 13:25:58 -0500 Date: Mon, 04 Dec 2017 13:25:56 -0500 (EST) Message-Id: <20171204.132556.1601454745789376393.davem@davemloft.net> To: 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 Subject: Re: [PATCH 4/7 v2] net: ethernet: i825xx: Fix platform_get_irq's error checking From: David Miller In-Reply-To: <1512409703-20881-5-git-send-email-arvind.yadav.cs@gmail.com> References: <1512409703-20881-1-git-send-email-arvind.yadav.cs@gmail.com> <1512409703-20881-5-git-send-email-arvind.yadav.cs@gmail.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 04 Dec 2017 10:25:57 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 885 Lines: 28 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.