From patchwork Fri Jan 13 17:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13101271 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 AD248C54EBD for ; Fri, 13 Jan 2023 17:18:30 +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=b8p2EQ9jznX/A95/3KbZMy1p8HMChhlmHSRT4rFba/8=; b=czJQugAKNberpz dVBTZTanQFnQkhUzyrjqVuchW3Z989RSZvY0+HLWCA2dCngtdj6fx/UtC8qNtRnjGxTt5zSCJPBVy 8jyOANUJ49M56w/t/2THgWi3jWQ9sxvUMp3RcPtIsEBcb6X9raxpAP8uU25k5I1tLnFIVL/9Qh6AO /wTTybuZBzNtiFUoKWrdXQvJz//FW3pX22p/aL5rXxdVmIBdhwLXfsWRZq8GMEzZ0I9LMrLD6cgIb XV0JOqqDcAu9V+mz4TVsl5EEBxCJjHhA/TREjTKoenvzVMjnsuOZUQUtIa303OOglUyxifmVbc1cq M/iBV/oLGSYSRvbf2hDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGNg7-003eHo-BL; Fri, 13 Jan 2023 17:17:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGNbC-003aqE-V2; Fri, 13 Jan 2023 17:12:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=JQVTvpTvw4pPHdH4hQE2iTGLCaDZsY6Pj6FW7NrvY7U=; b=IfUAuEYKXMLxu+64CmVF33jlV9 0qqkzhalpBA4UL9Q02kI0NnryF1uiQv5C8KD0HQNL2UAmaTeV3efdpDoEarUBkr66k7ccFet/Nsk5 /hFordcRz5QpqIJIyzANBD/haN6lZVdRZCBG7AnEI1KVKRiOe6oZ2XecLO8EHYaa/NMf79WqdnKmn RnjIqkRiIGlJR/9C41BN8WoYv3JB2UvOMUbi9LP/QAN+MpNqKP1fc6oP6oxyYuFhU5z6pwrEXHkve EA1uqqPexh2AfdTHeoBJPq6ZX1INfy10rbQ3qc8IpPHuzkGmCIHJLOBgNYpWFKdnxKgnuSuJ2K3bJ P3JfQLmg==; Received: from mga04.intel.com ([192.55.52.120]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pGNb0-004Pxh-0r; Fri, 13 Jan 2023 17:12:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673629930; x=1705165930; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=4czDnVSkFSUSOJn9OForI+BzEj1U5wZMtWZ0AIG6g9Q=; b=DtYwIoM7C2J2Qo7NAFmss4xbaoUbzHiRow5+Iaw7igjJYow8QkDYvxbC VQcJrkBrdhQrHZiiQDYgkeRh7MlxOZ5w5JquicbtSqJ5Z/W7PMrThdV+G fPAPOz57T7qs9REfhvv0RJL0SvRdGDUrfZ4yPSpm6eNU6T3i93cjjBYKQ V1Gp7KS6vBujSRlB4noz5w1WKHwo2bu2BdmYhNH+Zq/l6XKTOj5ofCjEL 3b620VBJA+B4+9x/pjs+I2TMbVlNOAn8SaCDxw2Z9u5nGnb86k4P6DZOP ZlXdlXQ8ehplbpRMGwkUB/yhNy/GIRCq7DcaOjA8GEZN8husWlI4A1ZuJ A==; X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="322742822" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="322742822" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 09:10:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="608221583" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="608221583" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 13 Jan 2023 09:10:18 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7C93AE1; Fri, 13 Jan 2023 19:10:52 +0200 (EET) From: Andy Shevchenko To: Bartosz Golaszewski , Dmitry Torokhov , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Bartosz Golaszewski , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Stefan Wahren , Andy Shevchenko Subject: [PATCH v2 1/2] pinctrl: bcm: bcm2835: Switch to use ->add_pin_ranges() Date: Fri, 13 Jan 2023 19:10:50 +0200 Message-Id: <20230113171051.19309-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230113_171202_825990_29E298AA X-CRM114-Status: GOOD ( 18.57 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Yeah, while the ->add_pin_ranges() shouldn't be used by DT drivers, this one requires it to support quite old firmware descriptions that do not have gpio-ranges property. The change allows to clean up GPIO library from OF specifics. There is no functional change intended. Signed-off-by: Andy Shevchenko --- v2: fixed compilation issues (LKP), Cc'ed to the author of original code Btw, the commit d2b67744fd99 ("pinctrl: bcm2835: implement hook for missing gpio-ranges") seems problematic in the fist place due to odd of_node_put() call. I dunno how that part had been tested, or how it's supposed to work, i.e. where is the counterpart of_node_get(). Anyway this change drops it for good. Perhaps we can check gpio-ranges property presence inside the GPIO library, so this ->add_pin_ranges() won't be called at all. Also I would like to understand the dance around checking for pin control device. The original commit lacks of comments in the non-trivial code. drivers/pinctrl/bcm/pinctrl-bcm2835.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 7857e612a100..29f278c49103 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -358,16 +358,17 @@ static int bcm2835_gpio_direction_output(struct gpio_chip *chip, return 0; } -static int bcm2835_of_gpio_ranges_fallback(struct gpio_chip *gc, - struct device_node *np) +static int bcm2835_add_pin_ranges_fallback(struct gpio_chip *gc) { + struct device_node *np = dev_of_node(gc->parent); struct pinctrl_dev *pctldev = of_pinctrl_get(np); - of_node_put(np); - if (!pctldev) return 0; + if (of_property_read_bool(np, "gpio-ranges")) + return 0; + gpiochip_add_pin_range(gc, pinctrl_dev_get_devname(pctldev), 0, 0, gc->ngpio); @@ -388,7 +389,7 @@ static const struct gpio_chip bcm2835_gpio_chip = { .base = -1, .ngpio = BCM2835_NUM_GPIOS, .can_sleep = false, - .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback, + .add_pin_ranges = bcm2835_add_pin_ranges_fallback, }; static const struct gpio_chip bcm2711_gpio_chip = { @@ -405,7 +406,7 @@ static const struct gpio_chip bcm2711_gpio_chip = { .base = -1, .ngpio = BCM2711_NUM_GPIOS, .can_sleep = false, - .of_gpio_ranges_fallback = bcm2835_of_gpio_ranges_fallback, + .add_pin_ranges = bcm2835_add_pin_ranges_fallback, }; static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,