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: 12792047 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4002AC433F5 for ; Fri, 25 Mar 2022 20:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jvlJmrNg4szSNHhev39uXVEBxrmQqdVNkM2F+UjtB64=; b=3ooyR3tcpYs/zH B7+Ixbukn8UOd8HDDtI9QvkqzdT17aMb7snL1Nm24VQyR7uFwO9i5C5vBm0aDYKZ/rqEkvreBJmLB kBcPexUm05AEN53tPi/Uwx/+j4MDfEpRM3aknQ4Y1o3BTWXY8l9m6IiGbWf5Osm8h3pIIIH/nNGGS nd0Mn3nzhr29hrG06R3Bk71ytkM0KZLBwR8En1zHTLiTK5MAn0XdYRl1MTywnYAk08l2Nj/DOzdZL Jnxp7sYAW0AK5W83N0gpCwd5jMdMDwnz3+z+0D2VFgRsRkuBbMABUNOiDZEXidwK3PC4nqobj7jOF pdN4DlScqgIDfvFX/Gag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAU-003B0i-NI; Fri, 25 Mar 2022 20:04:18 +0000 Received: from mga14.intel.com ([192.55.52.115]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAS-003Azf-Dr; Fri, 25 Mar 2022 20:04:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238656; x=1679774656; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=I9qL3XzxipS1lgo6CpdL7eX6zDMQG8eU8y3dPwQxX+Y=; b=RnflvfzP4TD30gDb/532e1dlsLDiXB+b8QDrgGZRqZVyX0kau7lnr/77 9mMbUV0/ZKe9vHtaJoGiDbH446TRZM7aukgw1FyF4m+6yGT+nSNtJbpIR C65DMoEZmEZMbEHIy4KSFF708EeSU2oXh7LMokELJ2qdgxXLX11FLT84G 7mvQn6YugE2ZRZJo9JoRCz5UsqiG/0tKlE4BEcEFv8YM3Ch/igGSpzE9v yNTUthWRfczfPd/fESHsZM/rDMSW7xQ51E/pIEsBj8j9YwhjbhKK79ZWb 2nPtOFchgvBc8xn000VhErXVrHgbNf3JVXRPmfJTY2mHjSyiuz+o73BLd Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="258900035" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="258900035" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_130416_502660_30470F72 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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: 12792049 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A060EC433EF for ; Fri, 25 Mar 2022 20:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WTisfVvK8IAfCjVBZFKD926zm9LKHYzDzWYKYb/iwZU=; b=uo5/GDafvG5Skm 0ntQBhFMsnHscdNjUcMspbLYQ7ZHE75Fh474oVEcWlo0Da7QZReDldwEfHJjKF/UOLGZpa6bPPjdF 32jE0TqXDE+iK8hDHUqPuJ9CyAP3/mMp8v6QzEv5cNOZJyTHqk6lNGOL27T3fw1EAh1NXXkYrwAq/ 3MrZPva8dmazFlf9qcLNAQN3BSG1/avfj/ruQVScKhgALqOB5qMMk3WLO5Brdc8PT0NgDMVwIyYHa 2ICsKsduvjRADFF7O2wdDOskILZv1uQ/v0v//qIlDF4QhsxH6+DPSVuLj3lp50eDmoN70GjXWw2cK 6sFyWJlw7t0Soh9Za32g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAp-003B6D-4u; Fri, 25 Mar 2022 20:04:39 +0000 Received: from mga06.intel.com ([134.134.136.31]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAS-003Azh-LM; Fri, 25 Mar 2022 20:04:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238656; x=1679774656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KugfsYLZVZCrCzDcruBf/OOyAOySyQSAT5HxYxx99mU=; b=Excleh5dMvhLfnv9rZBEZUjtGMsg35R3SPE4z/QpMs9xpNjmVvISFQVA FW+UWXvjvSOJ4AoWOQWEHFGOpQSccVlBHO9FwmfjYe0puScDFd9xeMIkr tjyww+lyIzs8lpVP3OHBxtFvqtdAAA/+hVekx9YFl3UlGRMITzvNqA8Hv xuD4d1/XwG/+Vh9VdBrsfT2kSWRV1eV+xI+hITqekQt1oQ3hamCGSooma 7ZGTdOBKj2oCsgLQgYMvCnx3BiBSi/0AAgtDe2dzmcn/kegNfByRIXuBo Lz4UnDsacWvabmTVEsybo9jplCF07gfS0/DLZhFNE9e0ocifuMr1mlDQe g==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="319414701" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="319414701" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.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="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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_130416_779712_3A683D45 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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: 12792048 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D4FCC433F5 for ; Fri, 25 Mar 2022 20:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5nv+6RnfAo3zdVoxt5TqLA1LLnlDFuaTeqD/gYqcFhc=; b=Cau60mG5+uPSm2 +E1pTh1nk1ksBV4YLo1LB8PRfxJCNBheR+Jgj7sjZnOZFUZGOj+Lc+LvtTtdlCz9EXBZXMMl2qSTd XbjsiwOiI+MG+Xd7mOueOmCtwtR/EapUgWq9DAfNXOE8yCblWNgo26cp6RRchTi1OnndbVWWDxp5U s2muPDOlEwz+QC5HKqtGBCRd6XCE/fa3C+IeXGEdkhIYWJQSsXxYNhnCT7IfTAdy02V8nIyShpxoD O2IzCUAdPVHGKzBbzqrg/aHhgaiarZ9fJ5mKTkKhCNYOX3yPglojRdtbDyZUTtI0Mik2My+uPdX41 1Bq3eYtOs0GQ71sxSb5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAe-003B3V-TW; Fri, 25 Mar 2022 20:04:28 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAS-003Azg-Jz; Fri, 25 Mar 2022 20:04:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238656; x=1679774656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=s157fb9lA4a8XOSEq9n0q0pdUa5Gw9sK4n7L6BfC7jE=; b=SPrCOXHxQzgMYwokmPwL6bHmyQZvXg4N83LPvJjUxw6/esn7N9+1XEiN J5z6nJk0IGD6cfhxokgZx8SnHUmjA9rGuaRrJdu0RogfEeyJj9+GVD/Jf wHhGkaaUYENIWir4KN6Vka2kZI/ofS08zUC1vXvrtFb7vsBi1oxgLk9XJ kmZMvLd1oQRcb3bcLo/PkO4MTPVXn3nC/ZV3kqY3/T+E8iOcJ0fIAWiKg 87Tkt4lfzsIigEq+qsKdxA20MLInthFuFvdkPsi4EAFN6eEeD7QQDsPcJ Upg3yzZDIf+t+BGh6E0B8xHykPF94H4sgcvvL91F3XvXf+WZV8NMM24m8 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="246195672" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="246195672" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.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="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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_130416_721543_394AF047 X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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: 12792050 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F374CC433F5 for ; Fri, 25 Mar 2022 20:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RE8zCZLgKwF87uvpXdUlVQgbbNmchUbfgZTpl/w1/CU=; b=koDRPKVF4NW11s DOdSzUPVQPezIJHMXqn5P6QSaD4vMG6Mz40J8RRYF3kOH4X54bsSr1aXiyT+wbUwD4TerImIkdPLX Rfn2K6MKciKtseGVC2DIZrr7P/ZOjWBHTyuHuvEOlXJ42vW1Jc5n1tgpTSHM6a5kMJuxJLtKEDmTC VKWTeZ0kpPCTaU27qhUssqRHTmMl5riMcbxXrChi/w9bcQTGSbCLChJqAh4MX8ox/+lzYbMi9nku8 foacEUw2+X5SQimXnnNI2CnagxzC4VKyOu3DjCmNPW8p/4YjzX2xGEOyu/NlMmtfNIUIyVhyYNgHL wLeDs/DO3HgbUVDt1etQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqB1-003B9u-DK; Fri, 25 Mar 2022 20:04:51 +0000 Received: from mga04.intel.com ([192.55.52.120]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAY-003B1Z-4e; Fri, 25 Mar 2022 20:04:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238662; x=1679774662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5sK09O1uc6ZSl4vR7vWfGqwrFgZiRRMtY41JRk11RA8=; b=iwVe5zhsnNSJmy9rX0brR1JECtMhDqjk+7HBrQf6HYO3RRxJ/2EWfERP ccVlPye2g2y6iVzN8icod0CnM+m8uTQiS1iF/c6+EK+geNRKy761kR9Ib 3ff1o/phvGJ3s0cGthIl2400VVFqkmZuKTQjUHYw9qQoK/Vi3btK7dk9g zfmqiEgIFAFZJCEf8ExescL+o+LTJEnpJiIzoJ2g20ND8r6K6I8jsbyXd 7ZBdQOipPsfaJWEWB5XznLLRa9AUboj76Tqw8/3kgfE7Y8vCQUbL+ohKt VJS75cNxuYFMSukIyzuzmjiQBzLc7pS2Pq3ZCgrGNZGRebm/+v2SeMDuz A==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="257537315" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="257537315" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_130422_228685_F5372188 X-CRM114-Status: GOOD ( 13.71 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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: 12792051 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 188ACC433EF for ; Fri, 25 Mar 2022 20:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JWNRbKiRKJEOriqw5j6M2tF3ctOnHFuvbvjn4KeKAPc=; b=JLkFyFM9WZrJY9 fgoUY7lBQkW6sjF9STuiD6Ee+dtERq5IxvXiPmsxK2GGJwCFunPprBtOWLIDJSA8nKhYrtREjktL9 bysvNb2Eyn9I5novrc6WN1Q7LpjJX/R6zz3d3EJuIsoqw5iegLSnHZvemzcQaCmbf4GUCbetz0TKy mL6SWx5df7iedaqYEShz9/no34ZstvZ35t0eRbbPDH1rduoKPurwq8pfALXvWbTquOj/7inYVD6hJ Q8X4LxrYqjIQNEOGI7GYC1230ulqVLfZU+GIjibabVOJuHyhwXwKHoGvBu3651wEMnrJOt5MZe7Ep rmiRVu3h9wGwa/FNuLtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqB2-003BAI-6o; Fri, 25 Mar 2022 20:04:52 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXqAZ-003B1y-RG; Fri, 25 Mar 2022 20:04:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648238663; x=1679774663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+3cMN1f1lEcXuRBrNDyNybfnJAqjD8jUdUQVryZwyuU=; b=JNB9/rPiWkEYQlXLtLQHfpdOIetPuEWtWwudVR+xLaMLCVy4C/Q/2vmE kjcdQdug1cVTd4Ya8/d4Mb8k45OhKuJ6TUsl5DWWQmDGZA5VC5Qsxy0Db wqiZ9Fq4PSzpOaNK10/OpampnsP2kMETfHVKYDDCNg0EjdM4fk6e8ONFA wrzmqU9NyJ9XQqg/jl3TCfWlujA8mgPMquN3svGOuh3t+A7wGNjmuimQJ Fzswt6gvB139Gi56w0FH0mSa5UpHtnYjmDdygN0VTrpXK0+wC7L8iBTxn VCIOCWJX5FHTcmPrsksjFDa/4TAGdBZS7v8L2CFt/9GLPlDcVmwV7diFV g==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="238647057" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="238647057" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.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="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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_130423_938747_BA7AD206 X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.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)