From patchwork Fri Mar 25 20:03:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12792040 X-Patchwork-Delegate: geert@linux-m68k.org 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 8B154C433F5 for ; Fri, 25 Mar 2022 20:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232081AbiCYUIc (ORCPT ); Fri, 25 Mar 2022 16:08:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232349AbiCYUH5 (ORCPT ); Fri, 25 Mar 2022 16:07:57 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 770F62BB28; Fri, 25 Mar 2022 13:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238655; x=1679774655; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=I9qL3XzxipS1lgo6CpdL7eX6zDMQG8eU8y3dPwQxX+Y=; b=O+/skQHCsifZ14BSN7Uy15tbo5g4s/Jyvg4DN2Z3oEBfFPA63/Sa0G6e 5j7oEQHcpr+3/1+Et3CTNe9E/QrIPTmutCaTZJwJ+acrzc6RNZcceZ9Fa v304SzwzTIc+T/bzw5HpqgGpSOsbteO8Ou0zcN6n4dAuX7b419nPH54GX jgWNC7pfPca6++ufBqCBz9co6nlLE/ysluceDU2w6vriXUlBxlTJCmpgp G0ttNksdCJ3Gdt5ei/lGehDJ9+czS2qRTXqfmoM7v/XmBEGAcd5ZCfuWR WjndAspSjBYZRaKm2Beucg6It3nEAza4BTFQBQ5Bj29aGiHYS285GB+fJ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="258900034" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="258900034" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 13:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="501886245" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 25 Mar 2022 13:04:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 75E9F11E; Fri, 25 Mar 2022 22:04:30 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski Subject: [PATCH v1 1/5] gpiolib: Introduce gpiochip_count() helper Date: Fri, 25 Mar 2022 22:03:34 +0200 Message-Id: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The gpiochip_count() helper iterates over the device child nodes that have the "gpio-controller" property set. It returns the number of such nodes under given device. Signed-off-by: Andy Shevchenko --- include/linux/gpio/driver.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 894eab753fdf..52918ef5d288 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -9,6 +9,7 @@ #include #include #include +#include #include struct gpio_desc; @@ -750,4 +751,17 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc, } #endif /* CONFIG_GPIOLIB */ +static inline unsigned int gpiochip_count(struct device *dev) +{ + struct fwnode_handle *child; + unsigned int count = 0; + + device_for_each_child_node(dev, child) { + if (device_property_read_bool(child, "gpio-controller")) + count++; + } + + return count; +} + #endif /* __LINUX_GPIO_DRIVER_H */ From patchwork Fri Mar 25 20:03:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12792041 X-Patchwork-Delegate: geert@linux-m68k.org 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 B0E93C433FE for ; Fri, 25 Mar 2022 20:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232350AbiCYUId (ORCPT ); Fri, 25 Mar 2022 16:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232341AbiCYUH5 (ORCPT ); Fri, 25 Mar 2022 16:07:57 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC2F42B18C; Fri, 25 Mar 2022 13:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238654; x=1679774654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KugfsYLZVZCrCzDcruBf/OOyAOySyQSAT5HxYxx99mU=; b=U7XyWDFQwnE7PBjzw5HFxoj7PZhgdUNwMu/x3mWe3ran6G5TJ4rYQzfc 7TxoCgZJO0fKCZBA8uXL0ul+U5m28s2b8Nk0pRveXKNsk3+6UkzCttwzh HeXBjTK/1YZ5kK1AUG+XRQBrO6L6NO8pYU5rZQINOu39oqlEfj/5ENqVB Fg+Orp2Y0Z78PZfYlAvOZHDVp7AdcWJm6hVOo0SbcA4Fm3bb2hS3hsrBu f6NOJibfi2nNrKMDfEufPBkfRHOMsmLi9fn/+fSnz0OE0aRYL0GeawT6L B5QDoJT8tJ5N2wu/3YCNltnMxyC7SKvz8g3MKjD5k5gxXQsYgeESNwrlj A==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="256283599" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="256283599" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 13:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="584576733" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 25 Mar 2022 13:04:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 80AEB73; Fri, 25 Mar 2022 22:04:30 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski Subject: [PATCH v1 2/5] pinctrl: stm32: Replace custom code by gpiochip_count() call Date: Fri, 25 Mar 2022 22:03:35 +0200 Message-Id: <20220325200338.54270-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> References: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 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 Reviewed-by: Fabien Dessenne --- drivers/pinctrl/stm32/pinctrl-stm32.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index 9ed764731570..d4bbeec82c1f 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1423,7 +1423,8 @@ int stm32_pctl_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct stm32_pinctrl *pctl; struct pinctrl_pin_desc *pins; - int i, ret, hwlock_id, banks = 0; + int i, ret, hwlock_id; + unsigned int banks; if (!np) return -EINVAL; @@ -1513,10 +1514,7 @@ int stm32_pctl_probe(struct platform_device *pdev) return PTR_ERR(pctl->pctl_dev); } - for_each_available_child_of_node(np, child) - if (of_property_read_bool(child, "gpio-controller")) - banks++; - + banks = gpiochip_count(dev); if (!banks) { dev_err(dev, "at least one GPIO bank is required\n"); return -EINVAL; From patchwork Fri Mar 25 20:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12792038 X-Patchwork-Delegate: geert@linux-m68k.org 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 E39B7C433EF for ; Fri, 25 Mar 2022 20:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231844AbiCYUIb (ORCPT ); Fri, 25 Mar 2022 16:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232338AbiCYUH5 (ORCPT ); Fri, 25 Mar 2022 16:07:57 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4D942B18D; Fri, 25 Mar 2022 13:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238654; x=1679774654; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s157fb9lA4a8XOSEq9n0q0pdUa5Gw9sK4n7L6BfC7jE=; b=MrfDQR4SBZpLVpd9l0jHg0K3ahLikmX6eJvB2DUlbkEINw81nqp+Q414 2yUclt0hO4LN/WpcJ1TTe9cvCHXGSDJyeOQnt9poPvC6qNSNNCzRegFnn hTdgKhIHW0o8dkT8uXKL6Cx3R2f/omlJfVy2N4ZDmQ2spX6WuveAuk1Lr k/T+mcCHsMkzb5aGp0UP8NuC2Gc7fRAJ2PStf7OKd+9JRK5K6gFC5HiFQ eJ234Vu2Jg3c9UnvPE685VVxbaP2QpDPQ/faXJXM6mFGvbTXFHrFVqkmA JltaEOhW0I7ClVxX8YyR6M++1lG4AKVQ9iwtL0uEy4HeP1LeEEValWtWW w==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="257537296" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="257537296" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 13:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="638321942" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 25 Mar 2022 13:04:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8C8E61C8; Fri, 25 Mar 2022 22:04:30 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski Subject: [PATCH v1 3/5] pinctrl: renesas: Replace custom code by gpiochip_count() call Date: Fri, 25 Mar 2022 22:03:36 +0200 Message-Id: <20220325200338.54270-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> References: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 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/renesas/pinctrl-rza1.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c index c1d6e9512c7a..c66e72e7dd71 100644 --- a/drivers/pinctrl/renesas/pinctrl-rza1.c +++ b/drivers/pinctrl/renesas/pinctrl-rza1.c @@ -1154,21 +1154,6 @@ static const struct pinmux_ops rza1_pinmux_ops = { * RZ/A1 pin controller driver operations */ -static unsigned int rza1_count_gpio_chips(struct device_node *np) -{ - struct device_node *child; - unsigned int count = 0; - - for_each_child_of_node(np, child) { - if (!of_property_read_bool(child, "gpio-controller")) - continue; - - count++; - } - - return count; -} - /** * rza1_parse_gpiochip() - parse and register a gpio chip and pin range * @@ -1255,7 +1240,7 @@ static int rza1_gpio_register(struct rza1_pinctrl *rza1_pctl) unsigned int i; int ret; - ngpiochips = rza1_count_gpio_chips(np); + ngpiochips = gpiochip_count(rza1_pctl->dev); if (ngpiochips == 0) { dev_dbg(rza1_pctl->dev, "No gpiochip registered\n"); return 0; From patchwork Fri Mar 25 20:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12792042 X-Patchwork-Delegate: geert@linux-m68k.org 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 3EA36C4332F for ; Fri, 25 Mar 2022 20:07:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232365AbiCYUIv (ORCPT ); Fri, 25 Mar 2022 16:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232378AbiCYUH6 (ORCPT ); Fri, 25 Mar 2022 16:07:58 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576F7140A2; Fri, 25 Mar 2022 13:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238661; x=1679774661; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5sK09O1uc6ZSl4vR7vWfGqwrFgZiRRMtY41JRk11RA8=; b=OUGP2dgAzHx2mlnynnamky6jCGR7RzWYyBGar7D6VHIMcz+ScXrm6ZV9 4i2oxRs5CR6bW3BqUr6RCDWEPOnwydn1V+heVZGPcc0AmIA2eI2IXYzCb SlJ1Oyt2ZN30OoxZhPKDw09f4W1+3m7UR35UL3tOHQc+lgwPBfK6/57zJ Dl6Jevm1RbJnEtd5H+EYCAFr2T6/YEZP/j8+k5odIIWZT5DgWjH50bPBX yLiy0/mLLZK+F90mfJnkgGesbbXFmmwR2SxqRBQ8vQcPWjc5Wz119JUd4 ZV6gRjukVA+phUDlATCf325/L5CdyuQtAPj5MJdpTFcT7UpOAw2NRfA8X A==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="345146243" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="345146243" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 13:04:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="602159418" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 25 Mar 2022 13:04:16 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 98EFD217; Fri, 25 Mar 2022 22:04:30 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski Subject: [PATCH v1 4/5] pinctrl: meson: Replace custom code by gpiochip_count() call Date: Fri, 25 Mar 2022 22:03:37 +0200 Message-Id: <20220325200338.54270-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> References: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 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 Reviewed-by: Neil Armstrong --- drivers/pinctrl/meson/pinctrl-meson.c | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 49851444a6e3..7db70d4e214a 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -662,27 +663,22 @@ static struct regmap *meson_map_resource(struct meson_pinctrl *pc, return devm_regmap_init_mmio(pc->dev, base, &meson_regmap_config); } -static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc, - struct device_node *node) +static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc) { - struct device_node *np, *gpio_np = NULL; + struct device_node *gpio_np; + unsigned int chips; - for_each_child_of_node(node, np) { - if (!of_find_property(np, "gpio-controller", NULL)) - continue; - if (gpio_np) { - dev_err(pc->dev, "multiple gpio nodes\n"); - of_node_put(np); - return -EINVAL; - } - gpio_np = np; - } - - if (!gpio_np) { + chips = gpiochip_count(pc->dev); + if (!chips) { dev_err(pc->dev, "no gpio node found\n"); return -EINVAL; } + if (chips > 1) { + dev_err(pc->dev, "multiple gpio nodes\n"); + return -EINVAL; + } + gpio_np = to_of_node(device_get_named_child_node(pc->dev, "gpio-controller")); pc->of_node = gpio_np; pc->reg_mux = meson_map_resource(pc, gpio_np, "mux"); @@ -751,7 +747,7 @@ int meson_pinctrl_probe(struct platform_device *pdev) pc->dev = dev; pc->data = (struct meson_pinctrl_data *) of_device_get_match_data(dev); - ret = meson_pinctrl_parse_dt(pc, dev->of_node); + ret = meson_pinctrl_parse_dt(pc); if (ret) return ret; From patchwork Fri Mar 25 20:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12792039 X-Patchwork-Delegate: geert@linux-m68k.org 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 7BAADC4332F for ; Fri, 25 Mar 2022 20:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbiCYUIb (ORCPT ); Fri, 25 Mar 2022 16:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbiCYUH5 (ORCPT ); Fri, 25 Mar 2022 16:07:57 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24CE02BB19; Fri, 25 Mar 2022 13:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238655; x=1679774655; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+3cMN1f1lEcXuRBrNDyNybfnJAqjD8jUdUQVryZwyuU=; b=VGbWWgqKbqXccXQql6hhvf8UAJkQJ6ZRaxfzgmH2DkLmuc1H//obZUyN Ev4MPix2rKWPgIqduFRM5sAoC4/6XGJ2ORuIFWU2C2XmNTl19WkzH9dgE GcExgFY7xAwFwf8Qsy/W6tvD8xXwY0bEqBSBLIGse1JkapXVlm/eRjP3L fOaYRBr3i65Sg/Mdy/gsrIFBo1alTeWdzlal6E5JCX29dM8Veao4sxs1n JPkts368v6zLr1YmsOteitgqyf7QkmmQKwrL7hjKzyKx1VABcxI/8m/Bw U7F0r+JPdsdnWdRK8eYn88BEplqn++SzIT60y8mwVH9CgAPORtXl7uzMp g==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="258427150" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="258427150" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 13:04:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="561956350" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 25 Mar 2022 13:04:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A508B314; Fri, 25 Mar 2022 22:04:30 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gregory CLEMENT , Geert Uytterhoeven , Fabien Dessenne , Linus Walleij , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Cc: Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Andrew Lunn , Sebastian Hesselbarth , Maxime Coquelin , Alexandre Torgue , Bartosz Golaszewski Subject: [PATCH v1 5/5] pinctrl: armada-37xx: Replace custom code by gpiochip_count() call Date: Fri, 25 Mar 2022 22:03:38 +0200 Message-Id: <20220325200338.54270-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> References: <20220325200338.54270-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org 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); + if (!nr_child_nodes) { dev_err(dev, "invalid or no IRQ\n"); return 0; } @@ -766,11 +762,11 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev, * controller. But we do not take advantage of this and use * the chained irq with all of them. */ - girq->num_parents = nr_irq_parent; - girq->parents = devm_kcalloc(dev, nr_irq_parent, sizeof(*girq->parents), GFP_KERNEL); + girq->num_parents = nr_child_nodes; + girq->parents = devm_kcalloc(dev, nr_child_nodes, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) return -ENOMEM; - for (i = 0; i < nr_irq_parent; i++) { + for (i = 0; i < nr_child_nodes; i++) { int irq = irq_of_parse_and_map(np, i); if (irq < 0)