Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751634AbdHTElm (ORCPT ); Sun, 20 Aug 2017 00:41:42 -0400 Received: from smtp01.smtpout.orange.fr ([80.12.242.123]:54352 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbdHTElk (ORCPT ); Sun, 20 Aug 2017 00:41:40 -0400 X-ME-Helo: [192.168.1.10] X-ME-Date: Sun, 20 Aug 2017 06:41:39 +0200 X-ME-IP: 90.21.44.83 Subject: Re: [PATCH] net: ibm: emac: Fix some error handling path in 'emac_probe()' To: Christian Lamparter References: <20170818230757.10934-1-christophe.jaillet@wanadoo.fr> <2515086.XcP7alDqkk@debian64> Cc: davem@davemloft.net, jarod@redhat.com, ivan@de.ibm.com, ebiggers@google.com, tklauser@distanz.ch, tremyfr@gmail.com, robh@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Newsgroups: gmane.linux.kernel,gmane.linux.network,gmane.linux.kernel.janitors From: Christophe JAILLET Message-ID: Date: Sun, 20 Aug 2017 06:41:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <2515086.XcP7alDqkk@debian64> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2119 Lines: 58 Le 19/08/2017 ? 15:22, Christian Lamparter a ?crit : > On Saturday, August 19, 2017 1:07:57 AM CEST Christophe JAILLET wrote: >> If 'irq_of_parse_and_map()' or 'of_address_to_resource()' fail, 'err' is >> known to be 0 at this point. >> So return -ENODEV instead in the first case and propagate the error >> returned by 'of_address_to_resource()' in the 2nd case. >> >> While at it, turn a 'err != 0' test into an equivalent 'err' to be more >> consistent. >> >> Signed-off-by: Christophe JAILLET >> --- >> drivers/net/ethernet/ibm/emac/core.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c >> index 95135d20458f..1af56a97fb47 100644 >> --- a/drivers/net/ethernet/ibm/emac/core.c >> +++ b/drivers/net/ethernet/ibm/emac/core.c >> [...] >> /* Map EMAC regs */ >> - if (of_address_to_resource(np, 0, &dev->rsrc_regs)) { >> + err = of_address_to_resource(np, 0, &dev->rsrc_regs); >> + if (err) { >> printk(KERN_ERR "%pOF: Can't get registers address\n", np); >> goto err_irq_unmap; >> } >> // TODO : request_mem_region >> dev->emacp = ioremap(dev->rsrc_regs.start, >> resource_size(&dev->rsrc_regs)); >> ... > If you want to go for 101%: you could get rid of this block > altogether by doing: > dev->emacp = of_iomap(np, 0); > > Note1: > This will also make the rsrc_regs variable in the emac_instance > struct redundant. So simply remove it from the core.h. > > Note2: if you want to go for 110%, you could replace this with > platform_get_resource() and devm_ioremap_resource() (if you > are interested, take a look at devm_ioremap_resource's kdoc > it has an example). > > Thanks, > Christian > Hi, Thanks for the review and comments. I've sent a v2 to go for 101% which axes some lines of code. I won't propose anything for your other proposal. Sounds great but involves more changes in the error handling path and in the remove function. I don't have the hardware, so I won't be able to test this bigger change. Christophe