Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1016398ybl; Mon, 2 Dec 2019 23:40:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwpt140AbzaIPZ9ts0LkRefI8tPAr8IxTEYU8oD2hJThvah0680imLiVHcxur7tOjcBfKEJ X-Received: by 2002:aca:5cc6:: with SMTP id q189mr2452565oib.101.1575358835387; Mon, 02 Dec 2019 23:40:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575358835; cv=none; d=google.com; s=arc-20160816; b=RK7oPwxcCqj0qAvRchwKDAwH58WQoAgLi5vkkcJ4CL26TgFN8tQL4Cs8BN8ouDGEHm wRa6eFHUUqsOb0JzWCXTmV2RtAoW6cD+QmXNnuKNkyuOiy0u90d24VFjnga8VNuqAVa+ ZK4B9Do8HNNpAZ8wCA/r/ElSFlz4PWRrmupUj+eDRQKxmccdet/SVpMxLmcIrvt/Aj3o uijdKsilrlj5fskOGge9qlQEC3OJ3378/JwU0Q/aoRr+zm1+sqHLpsPp1kKXi4EpAMxh 8EqgxAF7r824UjIHcHZN+XFRuAhcibVCXFeYEFGp2ILYKB1elJrFwn6vH9eF2M2GXEfT HAMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=NNQ6Du1fqjt/4SkN9h6Ut9TwYWE4trzeqIx7ZiHgDZo=; b=Za3baGh6R2v61N2r14GGAwiNeR5jUyhSs0xkI5t/Ai7eo9xC/Xf661GmdPDDzUXy4Y TZhCwJ3if+wXKnZWPLgPb4xMwnnY1nBt0DSNwBH9kTGn+ahjgnbSZB8VXVqaZxrdbOg+ fWyYdJMjMkRtAspB53GDaLe4CM+Fm19UGdWKwhf7pTFSKxelC+u0h00vf8nJMKY5T8o6 uIhUy2a63zfp7LaJnZdCsJnJYvX1QNGMXj9uzOsQUNK1kBd2u8WAqDxdE5th+GrcSq1f 14tYlXw1w/ZrCoFdmwJkhIGsVl24tHKUdYZv57EptsETUrvvdpYkr3HD6ajis+O2bAxX EZeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e73si906706oib.145.2019.12.02.23.40.23; Mon, 02 Dec 2019 23:40:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727472AbfLCHis (ORCPT + 99 others); Tue, 3 Dec 2019 02:38:48 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:57125 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbfLCHis (ORCPT ); Tue, 3 Dec 2019 02:38:48 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ic2lf-0006ab-40; Tue, 03 Dec 2019 08:38:43 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1ic2ld-0007Cq-KN; Tue, 03 Dec 2019 08:38:41 +0100 Date: Tue, 3 Dec 2019 08:38:41 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Peng Fan Cc: "rjui@broadcom.com" , "linus.walleij@linaro.org" , "bgolaszewski@baylibre.com" , "f.fainelli@gmail.com" , "sbranden@broadcom.com" , "thierry.reding@gmail.com" , "robh@kernel.org" , "bcm-kernel-feedback-list@broadcom.com" , dl-linux-imx , "linux-gpio@vger.kernel.org" , "linux-pwm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Alice Guo Subject: Re: [PATCH 2/2] gpio: bcm-kona: use platform_irq_count Message-ID: <20191203073841.6j5viopvzpuckmzo@pengutronix.de> References: <1575352925-17271-1-git-send-email-peng.fan@nxp.com> <1575352925-17271-2-git-send-email-peng.fan@nxp.com> <20191203065751.w23dypag4745qv7i@pengutronix.de> <20191203071534.zqxlizjkav4ul2n5@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 03, 2019 at 07:23:14AM +0000, Peng Fan wrote: > > Subject: Re: [PATCH 2/2] gpio: bcm-kona: use platform_irq_count > > > > On Tue, Dec 03, 2019 at 07:00:40AM +0000, Peng Fan wrote: > > > > Subject: Re: [PATCH 2/2] gpio: bcm-kona: use platform_irq_count > > > > > > > > On Tue, Dec 03, 2019 at 06:04:27AM +0000, Peng Fan wrote: > > > > > From: Peng Fan > > > > > > > > > > Use platform_irq_count to replace of_irq_count > > > > > > > > > > Signed-off-by: Peng Fan > > > > > --- > > > > > > > > > > V1: > > > > > Code inspection, not tested > > > > > > > > > > drivers/gpio/gpio-bcm-kona.c | 3 +-- > > > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > > > > > diff --git a/drivers/gpio/gpio-bcm-kona.c > > > > > b/drivers/gpio/gpio-bcm-kona.c index 4122683eb1f9..c50721980a7c > > > > 100644 > > > > > --- a/drivers/gpio/gpio-bcm-kona.c > > > > > +++ b/drivers/gpio/gpio-bcm-kona.c > > > > > @@ -19,7 +19,6 @@ > > > > > #include > > > > > #include > > > > > #include > > > > > -#include > > > > > #include > > > > > #include > > > > > #include @@ -586,7 +585,7 @@ static > > > > > int bcm_kona_gpio_probe(struct platform_device *pdev) > > > > > > > > > > kona_gpio->gpio_chip = template_chip; > > > > > chip = &kona_gpio->gpio_chip; > > > > > - kona_gpio->num_bank = of_irq_count(dev->of_node); > > > > > + kona_gpio->num_bank = platform_irq_count(pdev); > > > > > > > > of_irq_count returns 0 or a positive int while platform_irq_count > > > > might return a negative error code. This needs handling. Also I > > > > wonder why > > > > platform_irq_count() is better than of_irq_count() which would be > > > > good to describe in the commit log. > > > > > > Inspired from > > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml > > > .org%2Flkml%2F2015%2F11%2F18%2F466&data=02%7C01%7Cpeng.f > > an%40nxp.c > > > > > om%7C46364bf12479463df7d308d777c09b39%7C686ea1d3bc2b4c6fa92cd9 > > 9c5c3016 > > > > > 35%7C0%7C0%7C637109541440912984&sdata=awTvwwmo4692Hx7IJ > > H%2BllEVJH7 > > > ngINufoMH8UsosU%2BA%3D&reserved=0 > > > From Rob: > > > " > > > So I started looking at why you are using of_irq_count which drivers > > > shouldn't need to. In patch 5 you use it to allocate memory to store > > > the irq names, then use them here... > > > " > > > > > > Is this ok? > > > > I would say something like: > > > > platform_irq_count() is the more generic way (independent of > > device trees) to determine the count of available interrupts. So > > use this instead. > > > > As platform_irq_count() might return an error code (which > > of_irq_count doesn't) some additional handling is necessary. > > Thanks, how about this change? > @@ -586,11 +585,15 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) > > kona_gpio->gpio_chip = template_chip; > chip = &kona_gpio->gpio_chip; > - kona_gpio->num_bank = of_irq_count(dev->of_node); > - if (kona_gpio->num_bank == 0) { > + ret = platform_irq_count(pdev); > + if (!ret) { > dev_err(dev, "Couldn't determine # GPIO banks\n"); > return -ENOENT; > + } else if (ret < 0) { > + return ret; This is inconsitent. In the ret==0 case you emit an error message, in the ret < 0 case you don't. I think the sensible approach would be to do: if (ret == 0) { dev_err(dev, "Couldn't determine # GPIO banks\n"); return -ENOENT; } else if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(dev, "Failed to determine count of GPIO banks (%pe)\n", ERR_PTR(ret)); return ret; } Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | https://www.pengutronix.de/ |