From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644B3C433EF for ; Sat, 26 Mar 2022 08:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbiCZInR (ORCPT ); Sat, 26 Mar 2022 04:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiCZInQ (ORCPT ); Sat, 26 Mar 2022 04:43:16 -0400 Received: from mxout03.lancloud.ru (mxout03.lancloud.ru [45.84.86.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC21DB6E7D; Sat, 26 Mar 2022 01:41:35 -0700 (PDT) Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout03.lancloud.ru DA04E20A8247 Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: Re: [PATCH v1 5/5] pinctrl: armada-37xx: Replace custom code by gpiochip_count() call To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , , , , , , CC: Neil Armstrong , Kevin Hilman , Jerome Brunet , "Martin Blumenstingl" , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski References: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> <20220325200338.54270-5-andriy.shevchenko@linux.intel.com> From: Sergey Shtylyov Organization: Open Mobile Platform Message-ID: <3415996d-e8b5-2416-fb66-e65779a9b507@omp.ru> Date: Sat, 26 Mar 2022 11:41:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220325200338.54270-5-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.11.198] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1907.lancloud.ru (fd00:f066::207) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 3/25/22 11:03 PM, Andy Shevchenko wrote: > Since we have generic function to count GPIO controller nodes > under given device, there is no need to open code it. Replace > custom code by gpiochip_count() call. > > Signed-off-by: Andy Shevchenko > --- > drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 24 +++++++++------------ > 1 file changed, 10 insertions(+), 14 deletions(-) > > diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c > index 08cad14042e2..ba94125f6566 100644 > --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c > +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c > @@ -728,22 +728,18 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, > struct gpio_irq_chip *girq = &gc->irq; > struct device *dev = &pdev->dev; > struct device_node *np; > - int ret = -ENODEV, i, nr_irq_parent; > + unsigned int nr_child_nodes, i; > + int ret; > > /* Check if we have at least one gpio-controller child node */ > - for_each_child_of_node(dev->of_node, np) { > - if (of_property_read_bool(np, "gpio-controller")) { > - ret = 0; > - break; > - } > - } > - if (ret) > - return dev_err_probe(dev, ret, "no gpio-controller child node\n"); > + nr_child_nodes = gpiochip_count(dev); > + if (!nr_child_nodes) > + return dev_err_probe(dev, -ENODEV, "no gpio-controller child node\n"); > > - nr_irq_parent = of_irq_count(np); > spin_lock_init(&info->irq_lock); > > - if (!nr_irq_parent) { > + nr_child_nodes = of_irq_count(np); Mhm, 'np' is no longer assigned to at this point... > + if (!nr_child_nodes) { > dev_err(dev, "invalid or no IRQ\n"); > return 0; > } [...] MBR, Sergey