From patchwork Tue Nov 9 10:02:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610351 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5544C433F5 for ; Tue, 9 Nov 2021 10:05:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 700EC611BD for ; Tue, 9 Nov 2021 10:05:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 700EC611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=I2s58RVYYbQfnQIqyt4fnzf9Sa4kGBzPyuEHBmemO04=; b=quZ8jET2TwuTV6 z/BgSm6EzdMLGZI5MpWmJPM3xT0IkZD0SBQbaYfXqhKZxac1uK6yGqrv0aUpeuHfGT0K/WM1HsCrl G1TKG9INeZZBwPBvHMRzjyKPzFKWPpAQZ06zK7szfOYmR5iSVKfxsrDQKSvrxrQCTrNcjZ0isGkbD At6fG5Aq1+Za3RS5MHcH1FIWpXGIMWIPIiCsgOluoALaBXxN7pKjuXfDqpHnBm1/7SRpNc28E4Wa/ U58dhjJNqXrM8xTqIW/9itWQwhXZc7/xac0XdkyCnk6uvJvZ/WL1geU3OesbebF9GRuM1uFaGtO1z E4AGdMsjXfmVJXpspfDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNyW-001OkY-R4; Tue, 09 Nov 2021 10:03:33 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxK-001OQ9-W8 for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:20 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7705561130; Tue, 9 Nov 2021 10:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452138; bh=DUehqWf4vbNszyHCVSiu/iWrhygFDGGAmXDS6YG4J44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YST7JT7IimcM4PZpvx4nixkBdfxoyI3W9rYtID0k3tHTHhTusYZs59m4q9nn++l6A bEraa++DgFEBdkHib9c4QgX1+43GMugBhtlfDF1Qx9HUrf+/OCW5OjstP2VXGluTlW UBkjtoZFh9rKUOILiXi+dht2+aJvkjWqo51NQNwPuPwus+7zHv4YktVy+N4bKeCSQT aqzaLJpcsP2yClo9e/sTQ8itN57rr2lLLUqV7yIasVptcIc+Id5D02WAfr+lZtT0TD NPg2BHuW9qMkst4bQgnoW09GfBscyevrMr5mnlR6qxOFvEzPJDooArmoOeiSzUhcc6 epp9CVhhi5uvA== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Fu Wei , Alex Shi , Hu Haowen , linux-doc-tw-discuss@lists.sourceforge.net Subject: [PATCH v2 1/8] gpiolib: remove irq_to_gpio() definition Date: Tue, 9 Nov 2021 11:02:00 +0100 Message-Id: <20211109100207.2474024-2-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020219_120642_6B65585C X-CRM114-Status: GOOD ( 18.66 ) 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 From: Arnd Bergmann All implementations other than coldfire have returned an error since the avr32 and blackfin architectures got removed, and the last user in driver code was removed in 2016, so just remove this old interface. The only reference is now in the Chinese documentation, which should be changed to remove this reference as well. Cc: Fu Wei Cc: Alex Shi Cc: Hu Haowen Cc: linux-doc-tw-discuss@lists.sourceforge.net Reviewed-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Signed-off-by: Arnd Bergmann --- Documentation/driver-api/gpio/legacy.rst | 20 +++++--------------- arch/m68k/include/asm/gpio.h | 7 ------- arch/sh/include/asm/gpio.h | 5 ----- include/linux/gpio.h | 12 ------------ 4 files changed, 5 insertions(+), 39 deletions(-) diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst index 9b12eeb89170..06c05e2d62c1 100644 --- a/Documentation/driver-api/gpio/legacy.rst +++ b/Documentation/driver-api/gpio/legacy.rst @@ -382,22 +382,18 @@ GPIOs mapped to IRQs -------------------- GPIO numbers are unsigned integers; so are IRQ numbers. These make up two logically distinct namespaces (GPIO 0 need not use IRQ 0). You can -map between them using calls like:: +map between them using:: /* map GPIO numbers to IRQ numbers */ int gpio_to_irq(unsigned gpio); - /* map IRQ numbers to GPIO numbers (avoid using this) */ - int irq_to_gpio(unsigned irq); - -Those return either the corresponding number in the other namespace, or +This returns an irq number corresponding to the gpio number, or else a negative errno code if the mapping can't be done. (For example, some GPIOs can't be used as IRQs.) It is an unchecked error to use a GPIO -number that wasn't set up as an input using gpio_direction_input(), or -to use an IRQ number that didn't originally come from gpio_to_irq(). +number that wasn't set up as an input using gpio_direction_input(). -These two mapping calls are expected to cost on the order of a single -addition or subtraction. They're not allowed to sleep. +The mapping call is expected to cost on the order of a single +addition or subtraction. It is not allowed to sleep. Non-error values returned from gpio_to_irq() can be passed to request_irq() or free_irq(). They will often be stored into IRQ resources for platform @@ -405,12 +401,6 @@ devices, by the board-specific initialization code. Note that IRQ trigger options are part of the IRQ interface, e.g. IRQF_TRIGGER_FALLING, as are system wakeup capabilities. -Non-error values returned from irq_to_gpio() would most commonly be used -with gpio_get_value(), for example to initialize or update driver state -when the IRQ is edge-triggered. Note that some platforms don't support -this reverse mapping, so you should avoid using it. - - Emulating Open Drain Signals ---------------------------- Sometimes shared signals need to use "open drain" signaling, where only the diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h index a50b27719a58..5cfc0996ba94 100644 --- a/arch/m68k/include/asm/gpio.h +++ b/arch/m68k/include/asm/gpio.h @@ -66,13 +66,6 @@ static inline int gpio_to_irq(unsigned gpio) return __gpio_to_irq(gpio); } -static inline int irq_to_gpio(unsigned irq) -{ - return (irq >= MCFGPIO_IRQ_VECBASE && - irq < (MCFGPIO_IRQ_VECBASE + MCFGPIO_IRQ_MAX)) ? - irq - MCFGPIO_IRQ_VECBASE : -ENXIO; -} - static inline int gpio_cansleep(unsigned gpio) { return gpio < MCFGPIO_PIN_MAX ? 0 : __gpio_cansleep(gpio); diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h index d643250f0a0f..588c1380e4cb 100644 --- a/arch/sh/include/asm/gpio.h +++ b/arch/sh/include/asm/gpio.h @@ -40,11 +40,6 @@ static inline int gpio_to_irq(unsigned gpio) return __gpio_to_irq(gpio); } -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - #endif /* CONFIG_GPIOLIB */ #endif /* __ASM_SH_GPIO_H */ diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 008ad3ee56b7..d8d7daa7eb94 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -81,11 +81,6 @@ static inline int gpio_to_irq(unsigned int gpio) return __gpio_to_irq(gpio); } -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - #endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */ /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ @@ -219,13 +214,6 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int irq_to_gpio(unsigned irq) -{ - /* irq can never have been returned from gpio_to_irq() */ - WARN_ON(1); - return -EINVAL; -} - static inline int devm_gpio_request(struct device *dev, unsigned gpio, const char *label) { From patchwork Tue Nov 9 10:02:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610353 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A13C433F5 for ; Tue, 9 Nov 2021 10:06:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 95724611BD for ; Tue, 9 Nov 2021 10:06:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 95724611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=tFNtFLwlVuhNeS04HFLkK+bG7DRzCDwHLYdvXcZNIdQ=; b=GHJYrH3P1H55oZ dlufyJ/KOWkSE61ltR+2KgIgR980QwP4XTndDsy7vMplYmeiwdw6im3mPAQYGAabfgMXWgCel1n/y GHKEbx4lHglGorr/Vuip+gYuHn0kXBhcNIgm0GGncS5d3BoewpL3Ham+z6qHxGcZH0nt06SwKN9fz zbUQN5UxCnJzfqBHfYCf6urz40ENQtI28BWdE6i7zJRwZc67DqDKMOqi3NL5SNX7Q5krqa+mlyth2 o6Rn6m4A9uiUK+coknCC7gYhxWAVDMGGGp/5ID0y0cmmv1fsRNhQ/qbr+HFwsH0jBqd8FZtxUfvh4 LhyHj4EdFzxkMC/RrGbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNzR-001Oyn-La; Tue, 09 Nov 2021 10:04:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxN-001OQf-0C for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:23 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 10B6161175; Tue, 9 Nov 2021 10:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452140; bh=sGyffUbjTsf37wv3qzAs8sgQqDsEN2pyIDKyvecPpwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvtQ9DuBYZUdf3Xjd3eAVgH1RgsAReH3QU/kfyrm6R2jZO1UXr1ivQYfNJCdYh4WZ 7O+xW83W+TJHO3rPvtk3a67aKtoOczKmiuUeI+fY2GQa2cmFkWpowNMT+VOETwr0h5 8oHCxoYFYT+DXA8GB5xfgW3cvXWKkE/NUFxxBTaBxCvChJ4iP2hAmhjwlzQgEcIevo T3xUS6y2K7pWcq8GrY/YtqRjhBiORv1o0nOttCio13P65+ihOJYon8KxMePB0s/urK xzxqSqYCFxWBwGBMQLnmEW4yVl/D21kBoE/APDrGeSJVAPCwrd1UgBU8Ehssm25+fc BY/x9DmL9Jo4A== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] gpiolib: remove empty asm/gpio.h files Date: Tue, 9 Nov 2021 11:02:01 +0100 Message-Id: <20211109100207.2474024-3-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020221_146504_009C27DA X-CRM114-Status: GOOD ( 16.70 ) 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 From: Arnd Bergmann The arm and sh versions of this file are identical to the generic versions and can just be removed. The drivers that actually use the sh3 specific version also include cpu/gpio.h directly, with the exception of magicpanelr2, which is easily fixed. This leaves coldfire as the only gpio driver that needs something custom for gpiolib. Reviewed-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann --- arch/arm/Kconfig | 1 - arch/arm/include/asm/gpio.h | 22 -------------- arch/sh/Kconfig | 1 - arch/sh/boards/board-magicpanelr2.c | 1 + arch/sh/include/asm/gpio.h | 45 ----------------------------- 5 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 arch/arm/include/asm/gpio.h delete mode 100644 arch/sh/include/asm/gpio.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 526ae94b1c9a..80378eeee760 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -23,7 +23,6 @@ config ARM select ARCH_HAS_SYNC_DMA_FOR_CPU if SWIOTLB || !MMU select ARCH_HAS_TEARDOWN_DMA_OPS if MMU select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST - select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_KEEP_MEMBLOCK diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h deleted file mode 100644 index f3bb8a2bf788..000000000000 --- a/arch/arm/include/asm/gpio.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ARCH_ARM_GPIO_H -#define _ARCH_ARM_GPIO_H - -/* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ -#include - -/* The trivial gpiolib dispatchers */ -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - -/* - * Provide a default gpio_to_irq() which should satisfy every case. - * However, some platforms want to do this differently, so allow them - * to override it. - */ -#ifndef gpio_to_irq -#define gpio_to_irq __gpio_to_irq -#endif - -#endif /* _ARCH_ARM_GPIO_H */ diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 2474a04ceac4..cebd04314d76 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -4,7 +4,6 @@ config SUPERH select ARCH_32BIT_OFF_T select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU - select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) select ARCH_HAS_BINFMT_FLAT if !MMU select ARCH_HAS_GIGANTIC_PAGE diff --git a/arch/sh/boards/board-magicpanelr2.c b/arch/sh/boards/board-magicpanelr2.c index 56bd386ff3b0..75de893152af 100644 --- a/arch/sh/boards/board-magicpanelr2.c +++ b/arch/sh/boards/board-magicpanelr2.c @@ -21,6 +21,7 @@ #include #include #include +#include #include /* Dummy supplies, where voltage doesn't matter */ diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h deleted file mode 100644 index 588c1380e4cb..000000000000 --- a/arch/sh/include/asm/gpio.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 - * - * include/asm-sh/gpio.h - * - * Generic GPIO API and pinmux table support for SuperH. - * - * Copyright (c) 2008 Magnus Damm - */ -#ifndef __ASM_SH_GPIO_H -#define __ASM_SH_GPIO_H - -#include -#include - -#if defined(CONFIG_CPU_SH3) -#include -#endif - -#include - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SH_GPIO_H */ From patchwork Tue Nov 9 10:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610355 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91E96C433EF for ; Tue, 9 Nov 2021 10:07:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5FE80600CD for ; Tue, 9 Nov 2021 10:07:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5FE80600CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=vvTv7GqPGtDRvtOJUaPaJUWu9QRuDHbsNVDlL2MYRKM=; b=DfU2JG7+FOqaS9 +sp2VjfgG0MytdpNPs+FRjCu8NT6H80ig4UBPXCAAdy0j35n5P17MOQg2buuUSvItRXlOKQogvnkA tX5YdlXrIjkpNhPMClqgy4i2b9tiymKWD0lkX1j/URnOYc3wJnojGVUaFvO19+IXdH0qo7vgQ8imz ntUnGdp9bDfNlULj1kGvqPIn2zkUI8YQcSxIS0YiXpbonUu6AT5w/hWvCoPKt0jP9iVzQQc+YEs0X xXd2YcoiaOkkIOCc3/q9GCjxrfWb5RUJqqhZrHjRdAfRg+dExZcYqk4qN9m27XOpfuypjHcyFQvv9 05FXdaq26HMxVGdu0A3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO0d-001PK0-EY; Tue, 09 Nov 2021 10:05:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxP-001ORl-D9 for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0192461167; Tue, 9 Nov 2021 10:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452142; bh=EzXJDdqEufRXNThBmzGwTXvlUQSESBryaJA48Na6KwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H95s8m35vRx7tLVdkW0MOexu7tzjamkXDkcXvtrUacwbN0f6U34bLWd6+NY6vtE1u JtzaXgDnpv/02oP+5xL10Jo+IATS3mj8cj5NKevx5OBqgcOemdAKdxfC6KnKoVWIdT ECS2XKMy8GXXjSXDLCAs0gMedccvnG1JPaiTKlt4h1+aXBoTBbudAxIMiNegAh8QSy ckReEOokawFskRyCFJhICyVBmOMPhdAPh7bzHs2/ijDJv/3F9Pu9Nl+Tp0T3fhnsP7 Qy2wULGAp9pQp+BjBGOY3McZhc8Ui6zg0lIq1M9tBOhhCDVrVXHJ0taAvLbN3vi3AR hXszXMylCOy9Q== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 3/8] gpiolib: coldfire: remove custom asm/gpio.h Date: Tue, 9 Nov 2021 11:02:02 +0100 Message-Id: <20211109100207.2474024-4-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020223_534183_842B12DA X-CRM114-Status: GOOD ( 19.07 ) 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 From: Arnd Bergmann Now that coldfire is the only user of a custom asm/gpio.h, it seems better to remove this as well, and have the same interface everywhere. For the gpio_get_value()/gpio_set_value()/gpio_to_irq(), gpio_cansleep() functions, the custom version is only a micro-optimization to inline the function for constant GPIO numbers. However, in the coldfire defconfigs, I was unable to find a single instance where this micro-optimization was even used, and according to Geert the only user appears to be the QSPI chip that is disabled everywhere. The custom gpio_request_one() function is even less useful, as it is guarded by an #ifdef that is never true. Reviewed-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann --- arch/m68k/Kconfig.cpu | 1 - arch/m68k/include/asm/gpio.h | 95 ------------------------------------ drivers/gpio/Kconfig | 8 --- include/linux/gpio.h | 7 --- 4 files changed, 111 deletions(-) delete mode 100644 arch/m68k/include/asm/gpio.h diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu index 0d00ef5117dc..8256ff6b5b87 100644 --- a/arch/m68k/Kconfig.cpu +++ b/arch/m68k/Kconfig.cpu @@ -24,7 +24,6 @@ config M68KCLASSIC config COLDFIRE bool "Coldfire CPU family support" - select ARCH_HAVE_CUSTOM_GPIO_H select CPU_HAS_NO_BITFIELDS select CPU_HAS_NO_CAS select CPU_HAS_NO_MULDIV64 diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h deleted file mode 100644 index 5cfc0996ba94..000000000000 --- a/arch/m68k/include/asm/gpio.h +++ /dev/null @@ -1,95 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Coldfire generic GPIO support - * - * (C) Copyright 2009, Steven King -*/ - -#ifndef coldfire_gpio_h -#define coldfire_gpio_h - -#include -#include -#include -#include -/* - * The Generic GPIO functions - * - * If the gpio is a compile time constant and is one of the Coldfire gpios, - * use the inline version, otherwise dispatch thru gpiolib. - */ - -static inline int gpio_get_value(unsigned gpio) -{ - if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) - return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio); - else - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned gpio, int value) -{ - if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) { - if (gpio < MCFGPIO_SCR_START) { - unsigned long flags; - MCFGPIO_PORTTYPE data; - - local_irq_save(flags); - data = mcfgpio_read(__mcfgpio_podr(gpio)); - if (value) - data |= mcfgpio_bit(gpio); - else - data &= ~mcfgpio_bit(gpio); - mcfgpio_write(data, __mcfgpio_podr(gpio)); - local_irq_restore(flags); - } else { - if (value) - mcfgpio_write(mcfgpio_bit(gpio), - MCFGPIO_SETR_PORT(gpio)); - else - mcfgpio_write(~mcfgpio_bit(gpio), - MCFGPIO_CLRR_PORT(gpio)); - } - } else - __gpio_set_value(gpio, value); -} - -static inline int gpio_to_irq(unsigned gpio) -{ -#if defined(MCFGPIO_IRQ_MIN) - if ((gpio >= MCFGPIO_IRQ_MIN) && (gpio < MCFGPIO_IRQ_MAX)) -#else - if (gpio < MCFGPIO_IRQ_MAX) -#endif - return gpio + MCFGPIO_IRQ_VECBASE; - else - return __gpio_to_irq(gpio); -} - -static inline int gpio_cansleep(unsigned gpio) -{ - return gpio < MCFGPIO_PIN_MAX ? 0 : __gpio_cansleep(gpio); -} - -#ifndef CONFIG_GPIOLIB -static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) -{ - int err; - - err = gpio_request(gpio, label); - if (err) - return err; - - if (flags & GPIOF_DIR_IN) - err = gpio_direction_input(gpio); - else - err = gpio_direction_output(gpio, - (flags & GPIOF_INIT_HIGH) ? 1 : 0); - - if (err) - gpio_free(gpio); - - return err; -} -#endif /* !CONFIG_GPIOLIB */ -#endif diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 5c3b29bddc5b..e2a3e9b66151 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -3,14 +3,6 @@ # GPIO infrastructure and drivers # -config ARCH_HAVE_CUSTOM_GPIO_H - bool - help - Selecting this config option from the architecture Kconfig allows - the architecture to provide a custom asm/gpio.h implementation - overriding the default implementations. New uses of this are - strongly discouraged. - menuconfig GPIOLIB bool "GPIO Support" help diff --git a/include/linux/gpio.h b/include/linux/gpio.h index d8d7daa7eb94..7e6b1b8277ca 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -54,11 +54,6 @@ struct gpio { }; #ifdef CONFIG_GPIOLIB - -#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H -#include -#else - #include static inline int gpio_get_value(unsigned int gpio) @@ -81,8 +76,6 @@ static inline int gpio_to_irq(unsigned int gpio) return __gpio_to_irq(gpio); } -#endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */ - /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ struct device; From patchwork Tue Nov 9 10:02:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610357 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA939C433F5 for ; Tue, 9 Nov 2021 10:08:12 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8AB2161027 for ; Tue, 9 Nov 2021 10:08:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8AB2161027 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=23H/1D0INjhpyS6RNAjBLC/AXWIuvg8Yn2iQRW5M8CE=; b=b4pi2uxCdRGWAJ DbW1zgCNRQMZOsIwFqS7Z84/x42nsbPclfhnXZIPIz1hEA6sjEIXgbNlqOqGghkyMWMq6yiHBu4v9 3gqzUAoUmWzK36gGQGGGdkL/Oyp052/yy5WPpJEZKRAG97uERdMifJtE6udf+AoT2qo6lZCoByhil 3vrsT0+Gp6P7GE9RCl00fsSGCeh6xPQOkkaDfFc2IrN+hBeDqUFTLud04i5xrNq0eB44qMA5fhVu8 LU73b9tX9jDEJsIUNgfBRaDSKL5IDxXUFcDNwuf5dtkXOjHTjKfy8lHcLT6Fv9Xkxja0rQH2znvYX jCvScrZ7ajZorxVC/lpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO1S-001PZP-Fk; Tue, 09 Nov 2021 10:06:35 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxQ-001OSk-VM for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:27 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 174C46117A; Tue, 9 Nov 2021 10:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452144; bh=Z1NymZZtUq2kgHWr0PNUheUe4YlyE526bn9lOaR7lu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u3HOAUCv/CEkE1B4jERL+E9Hvw/DmJXHfPi62fdjnk4fgx7vCc6SjdsNNuDv4dG0P N8qOQw2QWWo9TLtXpagLWKmGOVNtPEGg9s4vkRmO47O7Xlcp8z4Cw7PnOg1phaq1cy An/twrpMKG8UnSFQZrkYENKFA5T2KnFs7JypAPD2YqXA20/HaexZcWPeBK3YgcvK9d nsOxSeuNx438jjfMKupMR79XEaeD/HdaDpf6svgFtSVnCsfJVL/neA+FoOrIYvaBNi edltE9/Aksi3VsDlQWOEUSzDWLjSFZft4jcZAaD2ME1fUHCorW3p1oUnRxvhVgYZPL Sh17AimVJ4lkw== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] gpiolib: remove asm-generic/gpio.h Date: Tue, 9 Nov 2021 11:02:03 +0100 Message-Id: <20211109100207.2474024-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020225_131467_79F3E912 X-CRM114-Status: GOOD ( 24.05 ) 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 From: Arnd Bergmann The asm-generic/gpio.h file is now always included when using gpiolib, so just move its contents into linux/gpio.h with a few minor simplifications. Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko --- arch/m68k/include/asm/mcfgpio.h | 2 +- drivers/gpio/gpio-davinci.c | 3 +- drivers/pinctrl/core.c | 2 +- include/asm-generic/gpio.h | 172 -------------------------------- include/linux/gpio.h | 116 +++++++++++++++++++-- 5 files changed, 110 insertions(+), 185 deletions(-) delete mode 100644 include/asm-generic/gpio.h diff --git a/arch/m68k/include/asm/mcfgpio.h b/arch/m68k/include/asm/mcfgpio.h index 27f32cc81da6..2cefe8445980 100644 --- a/arch/m68k/include/asm/mcfgpio.h +++ b/arch/m68k/include/asm/mcfgpio.h @@ -9,7 +9,7 @@ #define mcfgpio_h #ifdef CONFIG_GPIOLIB -#include +#include #else int __mcfgpio_get_value(unsigned gpio); diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index cb5afaa7ed48..8122c3a8d659 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -23,8 +24,6 @@ #include #include -#include - #define MAX_REGS_BANKS 5 #define MAX_INT_PER_BANK 32 diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index ffe39336fcac..976607758e98 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -28,7 +28,7 @@ #ifdef CONFIG_GPIOLIB #include "../gpio/gpiolib.h" -#include +#include #endif #include "core.h" diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h deleted file mode 100644 index aea9aee1f3e9..000000000000 --- a/include/asm-generic/gpio.h +++ /dev/null @@ -1,172 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_GENERIC_GPIO_H -#define _ASM_GENERIC_GPIO_H - -#include -#include - -#ifdef CONFIG_GPIOLIB - -#include -#include -#include - -/* Platforms may implement their GPIO interface with library code, - * at a small performance cost for non-inlined operations and some - * extra memory (for code and for per-GPIO table entries). - * - * While the GPIO programming interface defines valid GPIO numbers - * to be in the range 0..MAX_INT, this library restricts them to the - * smaller range 0..ARCH_NR_GPIOS-1. - * - * ARCH_NR_GPIOS is somewhat arbitrary; it usually reflects the sum of - * builtin/SoC GPIOs plus a number of GPIOs on expanders; the latter is - * actually an estimate of a board-specific value. - */ - -#ifndef ARCH_NR_GPIOS -#if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0 -#define ARCH_NR_GPIOS CONFIG_ARCH_NR_GPIO -#else -#define ARCH_NR_GPIOS 512 -#endif -#endif - -/* - * "valid" GPIO numbers are nonnegative and may be passed to - * setup routines like gpio_request(). only some valid numbers - * can successfully be requested and used. - * - * Invalid GPIO numbers are useful for indicating no-such-GPIO in - * platform data and other tables. - */ - -static inline bool gpio_is_valid(int number) -{ - return number >= 0 && number < ARCH_NR_GPIOS; -} - -struct device; -struct gpio; -struct seq_file; -struct module; -struct device_node; -struct gpio_desc; - -/* caller holds gpio_lock *OR* gpio is marked as requested */ -static inline struct gpio_chip *gpio_to_chip(unsigned gpio) -{ - return gpiod_to_chip(gpio_to_desc(gpio)); -} - -/* Always use the library code for GPIO management calls, - * or when sleeping may be involved. - */ -extern int gpio_request(unsigned gpio, const char *label); -extern void gpio_free(unsigned gpio); - -static inline int gpio_direction_input(unsigned gpio) -{ - return gpiod_direction_input(gpio_to_desc(gpio)); -} -static inline int gpio_direction_output(unsigned gpio, int value) -{ - return gpiod_direction_output_raw(gpio_to_desc(gpio), value); -} - -static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) -{ - return gpiod_set_debounce(gpio_to_desc(gpio), debounce); -} - -static inline int gpio_get_value_cansleep(unsigned gpio) -{ - return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); -} -static inline void gpio_set_value_cansleep(unsigned gpio, int value) -{ - return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); -} - - -/* A platform's code may want to inline the I/O calls when - * the GPIO is constant and refers to some always-present controller, - * giving direct access to chip registers and tight bitbanging loops. - */ -static inline int __gpio_get_value(unsigned gpio) -{ - return gpiod_get_raw_value(gpio_to_desc(gpio)); -} -static inline void __gpio_set_value(unsigned gpio, int value) -{ - return gpiod_set_raw_value(gpio_to_desc(gpio), value); -} - -static inline int __gpio_cansleep(unsigned gpio) -{ - return gpiod_cansleep(gpio_to_desc(gpio)); -} - -static inline int __gpio_to_irq(unsigned gpio) -{ - return gpiod_to_irq(gpio_to_desc(gpio)); -} - -extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); -extern int gpio_request_array(const struct gpio *array, size_t num); -extern void gpio_free_array(const struct gpio *array, size_t num); - -/* - * A sysfs interface can be exported by individual drivers if they want, - * but more typically is configured entirely from userspace. - */ -static inline int gpio_export(unsigned gpio, bool direction_may_change) -{ - return gpiod_export(gpio_to_desc(gpio), direction_may_change); -} - -static inline int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) -{ - return gpiod_export_link(dev, name, gpio_to_desc(gpio)); -} - -static inline void gpio_unexport(unsigned gpio) -{ - gpiod_unexport(gpio_to_desc(gpio)); -} - -#else /* !CONFIG_GPIOLIB */ - -#include - -static inline bool gpio_is_valid(int number) -{ - /* only non-negative numbers are valid */ - return number >= 0; -} - -/* platforms that don't directly support access to GPIOs through I2C, SPI, - * or other blocking infrastructure can use these wrappers. - */ - -static inline int gpio_cansleep(unsigned gpio) -{ - return 0; -} - -static inline int gpio_get_value_cansleep(unsigned gpio) -{ - might_sleep(); - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value_cansleep(unsigned gpio, int value) -{ - might_sleep(); - __gpio_set_value(gpio, value); -} - -#endif /* !CONFIG_GPIOLIB */ - -#endif /* _ASM_GENERIC_GPIO_H */ diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 7e6b1b8277ca..c19256f67e02 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -54,26 +54,124 @@ struct gpio { }; #ifdef CONFIG_GPIOLIB -#include -static inline int gpio_get_value(unsigned int gpio) +#include +#include +#include + +/* Platforms may implement their GPIO interface with library code, + * at a small performance cost for non-inlined operations and some + * extra memory (for code and for per-GPIO table entries). + * + * While the GPIO programming interface defines valid GPIO numbers + * to be in the range 0..MAX_INT, this library restricts them to the + * smaller range 0..ARCH_NR_GPIOS-1. + * + * ARCH_NR_GPIOS is somewhat arbitrary; it usually reflects the sum of + * builtin/SoC GPIOs plus a number of GPIOs on expanders; the latter is + * actually an estimate of a board-specific value. + */ + +#ifndef ARCH_NR_GPIOS +#if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0 +#define ARCH_NR_GPIOS CONFIG_ARCH_NR_GPIO +#else +#define ARCH_NR_GPIOS 512 +#endif +#endif + +/* + * "valid" GPIO numbers are nonnegative and may be passed to + * setup routines like gpio_request(). only some valid numbers + * can successfully be requested and used. + * + * Invalid GPIO numbers are useful for indicating no-such-GPIO in + * platform data and other tables. + */ + +static inline bool gpio_is_valid(int number) { - return __gpio_get_value(gpio); + return number >= 0 && number < ARCH_NR_GPIOS; } -static inline void gpio_set_value(unsigned int gpio, int value) +struct device; + +/* caller holds gpio_lock *OR* gpio is marked as requested */ +static inline struct gpio_chip *gpio_to_chip(unsigned gpio) { - __gpio_set_value(gpio, value); + return gpiod_to_chip(gpio_to_desc(gpio)); } -static inline int gpio_cansleep(unsigned int gpio) +/* Always use the library code for GPIO management calls, + * or when sleeping may be involved. + */ +extern int gpio_request(unsigned gpio, const char *label); +extern void gpio_free(unsigned gpio); + +static inline int gpio_direction_input(unsigned gpio) +{ + return gpiod_direction_input(gpio_to_desc(gpio)); +} +static inline int gpio_direction_output(unsigned gpio, int value) +{ + return gpiod_direction_output_raw(gpio_to_desc(gpio), value); +} + +static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) { - return __gpio_cansleep(gpio); + return gpiod_set_debounce(gpio_to_desc(gpio), debounce); } -static inline int gpio_to_irq(unsigned int gpio) +static inline int gpio_get_value_cansleep(unsigned gpio) +{ + return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); +} +static inline void gpio_set_value_cansleep(unsigned gpio, int value) +{ + return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); +} + +static inline int gpio_get_value(unsigned gpio) +{ + return gpiod_get_raw_value(gpio_to_desc(gpio)); +} +static inline void gpio_set_value(unsigned gpio, int value) +{ + return gpiod_set_raw_value(gpio_to_desc(gpio), value); +} + +static inline int gpio_cansleep(unsigned gpio) +{ + return gpiod_cansleep(gpio_to_desc(gpio)); +} + +static inline int gpio_to_irq(unsigned gpio) +{ + return gpiod_to_irq(gpio_to_desc(gpio)); +} + +extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); +extern int gpio_request_array(const struct gpio *array, size_t num); +extern void gpio_free_array(const struct gpio *array, size_t num); + +/* + * A sysfs interface can be exported by individual drivers if they want, + * but more typically is configured entirely from userspace. + */ +static inline int gpio_export(unsigned gpio, bool direction_may_change) +{ + return gpiod_export(gpio_to_desc(gpio), direction_may_change); +} + +static inline int gpio_export_link(struct device *dev, const char *name, + unsigned gpio) +{ + return gpiod_export_link(dev, name, gpio_to_desc(gpio)); +} + +static inline void gpio_unexport(unsigned gpio) { - return __gpio_to_irq(gpio); + gpiod_unexport(gpio_to_desc(gpio)); } /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ From patchwork Tue Nov 9 10:02:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610359 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B73CC433F5 for ; Tue, 9 Nov 2021 10:09:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 03C5D61027 for ; Tue, 9 Nov 2021 10:09:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 03C5D61027 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=GxXTYLpyV9JfmswBP0bxaIeDVsj1YNYTIgHbxg7wRqw=; b=ygzqiEKOveDiNe oTy0gSuzy8n0PzoZynhd2m7jjKRY/wCZCg8cNEReHbjyEmhA5Xq8PNg+Ot+vW+3q/x49Cg6QUwcq+ VQQ7PFDPpLUid92sFZdQYrX5ARTcpRzYwbRZdzRp9AiwTy95u4h9H9M4daz2J7n9aXidDQc23y3/m siPP7qHOnQIrO5PSMsWXZAph5WOMdlkThvufcpBJiXHKp4PkN0bWnvY7PfGiyxC2InjBetESMR6Qe 05PLziT79htg3+CE3MMWY9C4lXM4SnLQIuNKDxyX/VjSAkc6hSWqXk3NcPhmQN9h5znwmxutIvnKW nOkKnwj9L5n/qGJb9DAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO2V-001PuD-Sw; Tue, 09 Nov 2021 10:07:40 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxS-001OTa-Tj for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:28 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0841361175; Tue, 9 Nov 2021 10:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452146; bh=KJmcwLJG+KEgzaRVE6V4y1Ie9xrUPZgAR8HZCp2KqGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n6rd/AHYdyBjwWwEJStADk/FqU0W3aflxO9Y1OsKlT0vQkA3WSwkaTR3M8hp9pLQg S8V8f5p66QjMIDGuTncneSsclV4p6GOr3uorGF+sKkseCM7EblkrsBXyXeGguGuIq+ X+RnWiLn/EpL1/1qWbwG76EEcLNvztaDLwmhTvcoOs2gddebcayMYoPFYemjkIlNnb e7uAVp6Zqq91ixUNL9p1d4tbRB5dg4z+o3k6O1q3NIbZTOXbCtSFePQtzhqDXVbVxf AU/Rytg28IcpIYpOzMURbjyk+lBut96NNqKPAPg79mLuRomagGfX4mqIR3QZsUE2uU TSNwWEpSmC6lQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] gpiolib: shrink further Date: Tue, 9 Nov 2021 11:02:04 +0100 Message-Id: <20211109100207.2474024-6-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020227_053473_66AA9E06 X-CRM114-Status: GOOD ( 19.52 ) 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 From: Arnd Bergmann gpio_set_debounce() only has a single user, which is trivially converted to gpiod_set_debounce(), while gpio_cansleep() and devm_gpio_free() have no users at all. Remove them all to shrink the old gpio interface. Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko --- .../driver-api/driver-model/devres.rst | 1 - Documentation/driver-api/gpio/legacy.rst | 2 -- drivers/gpio/gpiolib-devres.c | 25 ---------------- drivers/input/touchscreen/ads7846.c | 3 +- include/linux/gpio.h | 29 ------------------- 5 files changed, 2 insertions(+), 58 deletions(-) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index 148e19381b79..52821478decd 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -277,7 +277,6 @@ GPIO devm_gpiochip_add_data() devm_gpio_request() devm_gpio_request_one() - devm_gpio_free() I2C devm_i2c_new_dummy_device() diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst index 06c05e2d62c1..eae185f771d7 100644 --- a/Documentation/driver-api/gpio/legacy.rst +++ b/Documentation/driver-api/gpio/legacy.rst @@ -238,8 +238,6 @@ setup or driver probe/teardown code, so this is an easy constraint.):: ## gpio_free_array() gpio_free() - gpio_set_debounce() - Claiming and Releasing GPIOs diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 79da85d17b71..55465ead492f 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -385,13 +385,6 @@ static void devm_gpio_release(struct device *dev, void *res) gpio_free(*gpio); } -static int devm_gpio_match(struct device *dev, void *res, void *data) -{ - unsigned *this = res, *gpio = data; - - return *this == *gpio; -} - /** * devm_gpio_request - request a GPIO for a managed device * @dev: device to request the GPIO for @@ -459,24 +452,6 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio, } EXPORT_SYMBOL_GPL(devm_gpio_request_one); -/** - * devm_gpio_free - free a GPIO - * @dev: device to free GPIO for - * @gpio: GPIO to free - * - * Except for the extra @dev argument, this function takes the - * same arguments and performs the same function as gpio_free(). - * This function instead of gpio_free() should be used to manually - * free GPIOs allocated with devm_gpio_request(). - */ -void devm_gpio_free(struct device *dev, unsigned int gpio) -{ - - WARN_ON(devres_release(dev, devm_gpio_release, devm_gpio_match, - &gpio)); -} -EXPORT_SYMBOL_GPL(devm_gpio_free); - static void devm_gpio_chip_release(void *data) { struct gpio_chip *gc = data; diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index a25a77dd9a32..d0664e3b89bb 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1018,7 +1019,7 @@ static int ads7846_setup_pendown(struct spi_device *spi, ts->gpio_pendown = pdata->gpio_pendown; if (pdata->gpio_pendown_debounce) - gpio_set_debounce(pdata->gpio_pendown, + gpiod_set_debounce(gpio_to_desc(pdata->gpio_pendown), pdata->gpio_pendown_debounce); } else { dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); diff --git a/include/linux/gpio.h b/include/linux/gpio.h index c19256f67e02..64cc8f09eba8 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -117,11 +117,6 @@ static inline int gpio_direction_output(unsigned gpio, int value) return gpiod_direction_output_raw(gpio_to_desc(gpio), value); } -static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) -{ - return gpiod_set_debounce(gpio_to_desc(gpio), debounce); -} - static inline int gpio_get_value_cansleep(unsigned gpio) { return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); @@ -140,11 +135,6 @@ static inline void gpio_set_value(unsigned gpio, int value) return gpiod_set_raw_value(gpio_to_desc(gpio), value); } -static inline int gpio_cansleep(unsigned gpio) -{ - return gpiod_cansleep(gpio_to_desc(gpio)); -} - static inline int gpio_to_irq(unsigned gpio) { return gpiod_to_irq(gpio_to_desc(gpio)); @@ -181,8 +171,6 @@ struct device; int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); int devm_gpio_request_one(struct device *dev, unsigned gpio, unsigned long flags, const char *label); -void devm_gpio_free(struct device *dev, unsigned int gpio); - #else /* ! CONFIG_GPIOLIB */ #include @@ -239,11 +227,6 @@ static inline int gpio_direction_output(unsigned gpio, int value) return -ENOSYS; } -static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) -{ - return -ENOSYS; -} - static inline int gpio_get_value(unsigned gpio) { /* GPIO can never have been requested or set as {in,out}put */ @@ -257,13 +240,6 @@ static inline void gpio_set_value(unsigned gpio, int value) WARN_ON(1); } -static inline int gpio_cansleep(unsigned gpio) -{ - /* GPIO can never have been requested or set as {in,out}put */ - WARN_ON(1); - return 0; -} - static inline int gpio_get_value_cansleep(unsigned gpio) { /* GPIO can never have been requested or set as {in,out}put */ @@ -319,11 +295,6 @@ static inline int devm_gpio_request_one(struct device *dev, unsigned gpio, return -EINVAL; } -static inline void devm_gpio_free(struct device *dev, unsigned int gpio) -{ - WARN_ON(1); -} - #endif /* ! CONFIG_GPIOLIB */ #endif /* __LINUX_GPIO_H */ From patchwork Tue Nov 9 10:02:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610361 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD5EC4332F for ; Tue, 9 Nov 2021 10:10:45 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 293DA61207 for ; Tue, 9 Nov 2021 10:10:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 293DA61207 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=DD2cHTXi5KkPlYBKC6j72DjI7YvPnrxWtMReyHJBPh8=; b=Ysgypp32kyYZFd fLLr2YQGBU0iv8sKJkZdu9rn2Ca9/q57JxzutaKivkyeTpx8+fkhtSyfd2wxsOKx44Xe5zrm6oKhD g1fhLMPEnS3oLJellcKeFua6zVEanEzMHvpqDRv2JW1L1wKAz58AST83+kDYRgpVpKDPgcVlGudEg mqQiaLMCFhTKtIkmTiKxRgFmKcTS42j0tNUW/i46Sdxf+vfrdIA0uyCH1yFcwOtXlQdB9njk1D0L8 uiAyPqLGwkKnDoaQFiAvISwOx7CP6ez67U7AWO5E4T79ECcQ/nKQZkMCpezJoB3D9hpt4rwRu57ru d0bgDPhUYqXXudo4HdYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO3m-001QJz-CS; Tue, 09 Nov 2021 10:09:00 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxU-001OSk-Pf for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:31 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF7A461130; Tue, 9 Nov 2021 10:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452148; bh=pwmejsZnkl62Kuuzf1JnZ72Ygl7f6FNKemOPbCL9Ahs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DOMVkIn9MFZq7++K4ZjBt7bq2AUqKtmwdJj4Q20SEmWa0ig9VlZpwR1vx1fQcmmZg xLA872cnuEJQzF/ibG7D7zU3JrNHNTVclUkENwjZGTt7TGEf0TPFBk/miywYld4XoJ /0OChCZ6lWPMYDZ4c/KEFd8iKbtST5k9o6ibpLMpX64X18f4tpg4Ge+qxmdDqyxYvD olFMlLWYBHBtUxJMHVZGCPMAoaDDm7sNFYlk18s0/5yKApWrdLP5qFAEtLQ9DODi1L 1XgTZX+0SV5+p1haraxb4g3HDqqY3E2e54+BwrELhcJrfZ436Ad0pHUCd0srOUEhix Wu9Tvzt+oZywA== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] gpiolib: remove legacy gpio_export Date: Tue, 9 Nov 2021 11:02:05 +0100 Message-Id: <20211109100207.2474024-7-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020228_978384_AA3547DE X-CRM114-Status: GOOD ( 23.68 ) 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 From: Arnd Bergmann There are only a handful of users of gpio_export() and related functions. As these are just wrappers around the modern gpiod_export() helper, remove the wrappers and open-code the gpio_to_desc in all callers to shrink the legacy API. Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko --- Documentation/admin-guide/gpio/sysfs.rst | 2 +- Documentation/driver-api/gpio/legacy.rst | 30 ----------------- Documentation/translations/zh_CN/gpio.txt | 26 -------------- Documentation/translations/zh_TW/gpio.txt | 27 --------------- arch/arm/mach-davinci/board-dm646x-evm.c | 28 +++++++++------- arch/arm/mach-omap2/pdata-quirks.c | 9 ++--- arch/sh/boards/mach-ap325rxa/setup.c | 7 ++-- drivers/gpio/gpiolib-sysfs.c | 4 +-- drivers/media/i2c/noon010pc30.c | 5 +-- drivers/media/i2c/ov9650.c | 4 +-- drivers/media/i2c/s5k4ecgx.c | 3 +- drivers/media/pci/sta2x11/sta2x11_vip.c | 10 ++++-- drivers/mfd/dm355evm_msp.c | 3 +- drivers/net/ieee802154/ca8210.c | 3 +- include/linux/gpio.h | 41 ----------------------- 15 files changed, 45 insertions(+), 157 deletions(-) diff --git a/Documentation/admin-guide/gpio/sysfs.rst b/Documentation/admin-guide/gpio/sysfs.rst index ec09ffd983e7..35171d15f78d 100644 --- a/Documentation/admin-guide/gpio/sysfs.rst +++ b/Documentation/admin-guide/gpio/sysfs.rst @@ -145,7 +145,7 @@ requested using gpio_request():: /* export the GPIO to userspace */ int gpiod_export(struct gpio_desc *desc, bool direction_may_change); - /* reverse gpio_export() */ + /* reverse gpiod_export() */ void gpiod_unexport(struct gpio_desc *desc); /* create a sysfs link to an exported GPIO node */ diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst index eae185f771d7..34fcb14814db 100644 --- a/Documentation/driver-api/gpio/legacy.rst +++ b/Documentation/driver-api/gpio/legacy.rst @@ -717,36 +717,6 @@ gpiochip nodes (possibly in conjunction with schematics) to determine the correct GPIO number to use for a given signal. -Exporting from Kernel code --------------------------- -Kernel code can explicitly manage exports of GPIOs which have already been -requested using gpio_request():: - - /* export the GPIO to userspace */ - int gpio_export(unsigned gpio, bool direction_may_change); - - /* reverse gpio_export() */ - void gpio_unexport(); - - /* create a sysfs link to an exported GPIO node */ - int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) - -After a kernel driver requests a GPIO, it may only be made available in -the sysfs interface by gpio_export(). The driver can control whether the -signal direction may change. This helps drivers prevent userspace code -from accidentally clobbering important system state. - -This explicit exporting can help with debugging (by making some kinds -of experiments easier), or can provide an always-there interface that's -suitable for documenting as part of a board support package. - -After the GPIO has been exported, gpio_export_link() allows creating -symlinks from elsewhere in sysfs to the GPIO sysfs node. Drivers can -use this to provide the interface under their own device in sysfs with -a descriptive name. - - API Reference ============= diff --git a/Documentation/translations/zh_CN/gpio.txt b/Documentation/translations/zh_CN/gpio.txt index a23ee14fc927..e49fa88a2804 100644 --- a/Documentation/translations/zh_CN/gpio.txt +++ b/Documentation/translations/zh_CN/gpio.txt @@ -622,29 +622,3 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO 固定的,例如在扩展卡上的 GPIO会根据所使用的主板或所在堆叠架构中其他的板子而 有所不同。在这种情况下,你可能需要使用 gpiochip 节点(尽可能地结合电路图)来 确定给定信号所用的 GPIO 编号。 - - -从内核代码中导出 -------------- -内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出: - - /* 导出 GPIO 到用户空间 */ - int gpio_export(unsigned gpio, bool direction_may_change); - - /* gpio_export()的逆操作 */ - void gpio_unexport(); - - /* 创建一个 sysfs 连接到已导出的 GPIO 节点 */ - int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) - -在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs -接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间 -破坏重要的系统状态。 - -这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口, -与文档配合作为板级支持包的一部分。 - -在 GPIO 被导出之后,gpio_export_link()允许在 sysfs 文件系统的任何地方 -创建一个到这个 GPIO sysfs 节点的符号链接。这样驱动就可以通过一个描述性的 -名字,在 sysfs 中他们所拥有的设备下提供一个(到这个 GPIO sysfs 节点的)接口。 diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt index e3c076dd75a5..c9bf3ddd08b3 100644 --- a/Documentation/translations/zh_TW/gpio.txt +++ b/Documentation/translations/zh_TW/gpio.txt @@ -622,30 +622,3 @@ GPIO 控制器的路徑類似 /sys/class/gpio/gpiochip42/ (對於從#42 GPIO 固定的,例如在擴展卡上的 GPIO會根據所使用的主板或所在堆疊架構中其他的板子而 有所不同。在這種情況下,你可能需要使用 gpiochip 節點(儘可能地結合電路圖)來 確定給定信號所用的 GPIO 編號。 - - -從內核代碼中導出 -------------- -內核代碼可以明確地管理那些已通過 gpio_request()申請的 GPIO 的導出: - - /* 導出 GPIO 到用戶空間 */ - int gpio_export(unsigned gpio, bool direction_may_change); - - /* gpio_export()的逆操作 */ - void gpio_unexport(); - - /* 創建一個 sysfs 連接到已導出的 GPIO 節點 */ - int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) - -在一個內核驅動申請一個 GPIO 之後,它可以通過 gpio_export()使其在 sysfs -接口中可見。該驅動可以控制信號方向是否可修改。這有助於防止用戶空間代碼無意間 -破壞重要的系統狀態。 - -這個明確的導出有助於(通過使某些實驗更容易來)調試,也可以提供一個始終存在的接口, -與文檔配合作爲板級支持包的一部分。 - -在 GPIO 被導出之後,gpio_export_link()允許在 sysfs 文件系統的任何地方 -創建一個到這個 GPIO sysfs 節點的符號連結。這樣驅動就可以通過一個描述性的 -名字,在 sysfs 中他們所擁有的設備下提供一個(到這個 GPIO sysfs 節點的)接口。 - diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index ee91d81ebbfd..4a258e33021d 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -249,7 +249,7 @@ static int evm_led_teardown(struct i2c_client *client, int gpio, return 0; } -static int evm_sw_gpio[4] = { -EINVAL, -EINVAL, -EINVAL, -EINVAL }; +static struct gpio_desc *evm_sw_gpio[4]; static int evm_sw_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c) @@ -259,17 +259,19 @@ static int evm_sw_setup(struct i2c_client *client, int gpio, char label[10]; for (i = 0; i < 4; ++i) { + struct gpio_desc *desc = gpio_to_desc(gpio + i); + snprintf(label, 10, "user_sw%d", i); - status = gpio_request(gpio, label); + status = gpio_request(gpio + i, label); if (status) goto out_free; - evm_sw_gpio[i] = gpio++; + evm_sw_gpio[i] = desc; - status = gpio_direction_input(evm_sw_gpio[i]); + status = gpiod_direction_input(desc); if (status) goto out_free; - status = gpio_export(evm_sw_gpio[i], 0); + status = gpiod_export(desc, 0); if (status) goto out_free; } @@ -277,9 +279,9 @@ static int evm_sw_setup(struct i2c_client *client, int gpio, out_free: for (i = 0; i < 4; ++i) { - if (evm_sw_gpio[i] != -EINVAL) { - gpio_free(evm_sw_gpio[i]); - evm_sw_gpio[i] = -EINVAL; + if (evm_sw_gpio[i]) { + gpio_free(pin + i); + evm_sw_gpio[i] = NULL; } } return status; @@ -291,10 +293,10 @@ static int evm_sw_teardown(struct i2c_client *client, int gpio, int i; for (i = 0; i < 4; ++i) { - if (evm_sw_gpio[i] != -EINVAL) { - gpio_unexport(evm_sw_gpio[i]); - gpio_free(evm_sw_gpio[i]); - evm_sw_gpio[i] = -EINVAL; + if (evm_sw_gpio[i]) { + gpiod_unexport(evm_sw_gpio[i]); + gpio_free(gpio + i); + evm_sw_gpio[i] = NULL; } } return 0; diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index e7fd29a502a0..1fdf7fcf091e 100644 --- a/arch/arm/mach-omap2/pdata-quirks.c +++ b/arch/arm/mach-omap2/pdata-quirks.c @@ -6,6 +6,7 @@ */ #include #include +#include #include #include #include @@ -120,7 +121,7 @@ static int omap3_sbc_t3730_twl_callback(struct device *dev, if (res) return res; - gpio_export(gpio, 0); + gpiod_export(gpio_to_desc(gpio), 0); return 0; } @@ -135,7 +136,7 @@ static void __init omap3_sbc_t3x_usb_hub_init(int gpio, char *hub_name) return; } - gpio_export(gpio, 0); + gpiod_export(gpio_to_desc(gpio), 0); udelay(10); gpio_set_value(gpio, 1); @@ -212,8 +213,8 @@ static void __init omap3_sbc_t3517_wifi_init(void) return; } - gpio_export(cm_t3517_wlan_gpios[0].gpio, 0); - gpio_export(cm_t3517_wlan_gpios[1].gpio, 0); + gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0); + gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0); msleep(100); gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0); diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c index c77b5f00a66a..151792162152 100644 --- a/arch/sh/boards/mach-ap325rxa/setup.c +++ b/arch/sh/boards/mach-ap325rxa/setup.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -411,16 +412,16 @@ static int __init ap325rxa_devices_setup(void) /* LD3 and LD4 LEDs */ gpio_request(GPIO_PTX5, NULL); /* RUN */ gpio_direction_output(GPIO_PTX5, 1); - gpio_export(GPIO_PTX5, 0); + gpiod_export(gpio_to_desc(GPIO_PTX5), 0); gpio_request(GPIO_PTX4, NULL); /* INDICATOR */ gpio_direction_output(GPIO_PTX4, 0); - gpio_export(GPIO_PTX4, 0); + gpiod_export(gpio_to_desc(GPIO_PTX4), 0); /* SW1 input */ gpio_request(GPIO_PTF7, NULL); /* MODE */ gpio_direction_input(GPIO_PTF7); - gpio_export(GPIO_PTF7, 0); + gpiod_export(gpio_to_desc(GPIO_PTF7), 0); /* LCDC */ gpio_request(GPIO_FN_LCDD15, NULL); diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 4098bc7f88b7..a83fba3649c4 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -511,7 +511,7 @@ static ssize_t unexport_store(struct class *class, goto done; desc = gpio_to_desc(gpio); - /* reject bogus commands (gpio_unexport ignores them) */ + /* reject bogus commands (gpiod_unexport ignores them) */ if (!desc) { pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); return -EINVAL; @@ -814,7 +814,7 @@ static int __init gpiolib_sysfs_init(void) * early (e.g. before the class_register above was called). * * We run before arch_initcall() so chip->dev nodes can have - * registered, and so arch_initcall() can always gpio_export(). + * registered, and so arch_initcall() can always gpiod_export(). */ spin_lock_irqsave(&gpio_lock, flags); list_for_each_entry(gdev, &gpio_devices, list) { diff --git a/drivers/media/i2c/noon010pc30.c b/drivers/media/i2c/noon010pc30.c index f3ac379ef34a..6faa44eb5354 100644 --- a/drivers/media/i2c/noon010pc30.c +++ b/drivers/media/i2c/noon010pc30.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -755,7 +756,7 @@ static int noon010_probe(struct i2c_client *client, goto np_err; } info->gpio_nreset = pdata->gpio_nreset; - gpio_export(info->gpio_nreset, 0); + gpiod_export(gpio_to_desc(info->gpio_nreset), 0); } if (gpio_is_valid(pdata->gpio_nstby)) { @@ -767,7 +768,7 @@ static int noon010_probe(struct i2c_client *client, goto np_err; } info->gpio_nstby = pdata->gpio_nstby; - gpio_export(info->gpio_nstby, 0); + gpiod_export(gpio_to_desc(info->gpio_nstby), 0); } for (i = 0; i < NOON010_NUM_SUPPLIES; i++) diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index c313e11a9754..021acd20ede2 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1426,9 +1426,9 @@ static int ov965x_configure_gpios_pdata(struct ov965x *ov965x, return ret; v4l2_dbg(1, debug, &ov965x->sd, "set gpio %d to 1\n", gpio); - gpio_set_value_cansleep(gpio, 1); - gpio_export(gpio, 0); ov965x->gpios[i] = gpio_to_desc(gpio); + gpiod_set_value_cansleep(ov965x->gpios[i], 1); + gpiod_export(ov965x->gpios[i], 0); } return 0; diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c index af9a305242cd..419d03fcc978 100644 --- a/drivers/media/i2c/s5k4ecgx.c +++ b/drivers/media/i2c/s5k4ecgx.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -852,7 +853,7 @@ static int s5k4ecgx_config_gpio(int nr, int val, const char *name) return 0; ret = gpio_request_one(nr, flags, name); if (!ret) - gpio_export(nr, 0); + gpiod_export(gpio_to_desc(nr), 0); return ret; } diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 524912f20d9f..f7cef598f21d 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -893,6 +894,7 @@ static int sta2x11_vip_init_controls(struct sta2x11_vip *vip) static int vip_gpio_reserve(struct device *dev, int pin, int dir, const char *name) { + struct gpio_desc *desc = gpio_to_desc(pin); int ret = -ENODEV; if (!gpio_is_valid(pin)) @@ -904,7 +906,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir, return ret; } - ret = gpio_direction_output(pin, dir); + ret = gpiod_direction_output(desc, dir); if (ret) { dev_err(dev, "Failed to set direction for pin %d (%s)\n", pin, name); @@ -912,7 +914,7 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir, return ret; } - ret = gpio_export(pin, false); + ret = gpiod_export(desc, false); if (ret) { dev_err(dev, "Failed to export pin %d (%s)\n", pin, name); gpio_free(pin); @@ -932,8 +934,10 @@ static int vip_gpio_reserve(struct device *dev, int pin, int dir, static void vip_gpio_release(struct device *dev, int pin, const char *name) { if (gpio_is_valid(pin)) { + struct gpio_desc *desc = gpio_to_desc(pin); + dev_dbg(dev, "releasing pin %d (%s)\n", pin, name); - gpio_unexport(pin); + gpiod_unexport(desc); gpio_free(pin); } } diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 54fb6cbd2aa0..2388fb4d0121 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -329,7 +330,7 @@ static int add_children(struct i2c_client *client) gpio_request_one(gpio, GPIOF_IN, config_inputs[i].label); /* make it easy for userspace to see these */ - gpio_export(gpio, false); + gpiod_export(gpio_to_desc(gpio), false); } /* MMC/SD inputs -- right after the last config input */ diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index ece6ff6049f6..6252907b2c92 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -2895,7 +2896,7 @@ static int ca8210_interrupt_init(struct spi_device *spi) ); if (ret) { dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id); - gpio_unexport(pdata->gpio_irq); + gpiod_unexport(gpio_to_desc(pdata->gpio_irq)); gpio_free(pdata->gpio_irq); } diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 64cc8f09eba8..7ceb93678689 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -144,26 +144,6 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe extern int gpio_request_array(const struct gpio *array, size_t num); extern void gpio_free_array(const struct gpio *array, size_t num); -/* - * A sysfs interface can be exported by individual drivers if they want, - * but more typically is configured entirely from userspace. - */ -static inline int gpio_export(unsigned gpio, bool direction_may_change) -{ - return gpiod_export(gpio_to_desc(gpio), direction_may_change); -} - -static inline int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) -{ - return gpiod_export_link(dev, name, gpio_to_desc(gpio)); -} - -static inline void gpio_unexport(unsigned gpio) -{ - gpiod_unexport(gpio_to_desc(gpio)); -} - /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ struct device; @@ -253,27 +233,6 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value) WARN_ON(1); } -static inline int gpio_export(unsigned gpio, bool direction_may_change) -{ - /* GPIO can never have been requested or set as {in,out}put */ - WARN_ON(1); - return -EINVAL; -} - -static inline int gpio_export_link(struct device *dev, const char *name, - unsigned gpio) -{ - /* GPIO can never have been exported */ - WARN_ON(1); - return -EINVAL; -} - -static inline void gpio_unexport(unsigned gpio) -{ - /* GPIO can never have been exported */ - WARN_ON(1); -} - static inline int gpio_to_irq(unsigned gpio) { /* GPIO can never have been requested or set as input */ From patchwork Tue Nov 9 10:02:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610363 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00EAFC433EF for ; Tue, 9 Nov 2021 10:11:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BBA3E61027 for ; Tue, 9 Nov 2021 10:11:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BBA3E61027 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=Ex4vrLiTxVJU/12NYWoJ+InXJfIzPpRMPCNq1dhC10U=; b=r0EUA+kDo4hBvr DWnLrOQxviux+n00ILzsKLO3GUorFbg4Vc5QNCHm6WLs0x7aPkuidsVE0fE1lpEXK/FTL9OaKWnIH x0NAl5RRKkj311BGirQL2e4iOUn7TOaOWdn60GTVvNkYFdWQWyVJ4kmJqhM2CiYpNegyR5ba75We7 NPZzRajvEx0YhIFenifZk9jaZyE79USyBVePnPr9v2EElL0XbhrUjvjbRHmrz50NEvTx2lhwhd3PK ek8tWV9+oogVjEJASU3YJ4jVwCW0O4lMzBmqF5++IJBrhD6VumPxJXMLbQfylM9YsiiX+AxbJf2LU d0H6tLQjWjb32gjSCM3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO4f-001Qfa-Qu; Tue, 09 Nov 2021 10:09:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxX-001OVR-0P for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:32 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1264861167; Tue, 9 Nov 2021 10:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452150; bh=9vK0q1Gu9w0BTlhyMWFqQaJZ6ZTjcHavcORrzYvFfs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBkpmcqbZzTsG7gPPxtBtwQIv9etRQxlswIt3xjRKlFDCsOpB9JbcNNjZLSTMMf74 Hz+jUlvuu71bgO51fu7c+sPkbIrpiBDpA21iWTKqe10F+YdH99RfLIp6DSGkALko6E swrSNoy3bS5mw++lSfVVtTDv5KovUdr2tjPx6mPs2Pi16YmpOTLT6ehaTav4lmQVeW MCNX/9zxE8FBhCTjvV0xN/q5QHAUpVwXcrNiwAqXzHrwzcyTExrF42mFmFxImO0DZ8 ihYtv2Jo64EzMvLMuhTdKS3i+YTLZsaYYD/CzPD2pepbsvxpGJoDsF0qz8ei1smUhg tT8SyDgkLLkaQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] gpiolib: remove gpio_to_chip Date: Tue, 9 Nov 2021 11:02:06 +0100 Message-Id: <20211109100207.2474024-8-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020231_166710_D6A3EAEA X-CRM114-Status: GOOD ( 15.23 ) 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 From: Arnd Bergmann There are only two callers of this helper, remove them by open-coding the call to the gpiod version. Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko --- drivers/pinctrl/core.c | 5 ++--- drivers/soc/fsl/qe/gpio.c | 4 +--- include/linux/gpio.h | 7 ------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 976607758e98..8d3c00782178 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -28,7 +28,6 @@ #ifdef CONFIG_GPIOLIB #include "../gpio/gpiolib.h" -#include #endif #include "core.h" @@ -324,7 +323,7 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range = NULL; - struct gpio_chip *chip = gpio_to_chip(gpio); + struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio)); if (WARN(!chip, "no gpio_chip for gpio%i?", gpio)) return false; @@ -1657,7 +1656,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) } } if (gpio_num >= 0) - chip = gpio_to_chip(gpio_num); + chip = gpiod_to_chip(gpio_to_desc(gpio_num)); else chip = NULL; if (chip) diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c index 99f7de43c3c6..a6aa55055e9a 100644 --- a/drivers/soc/fsl/qe/gpio.c +++ b/drivers/soc/fsl/qe/gpio.c @@ -15,8 +15,6 @@ #include #include #include -/* FIXME: needed for gpio_to_chip() get rid of this */ -#include #include #include #include @@ -173,7 +171,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) err = of_get_gpio(np, index); if (err < 0) goto err0; - gc = gpio_to_chip(err); + gc = gpiod_to_chip(gpio_to_desc(err)); if (WARN_ON(!gc)) { err = -ENODEV; goto err0; diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 7ceb93678689..61fb427b4e70 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -96,12 +96,6 @@ static inline bool gpio_is_valid(int number) struct device; -/* caller holds gpio_lock *OR* gpio is marked as requested */ -static inline struct gpio_chip *gpio_to_chip(unsigned gpio) -{ - return gpiod_to_chip(gpio_to_desc(gpio)); -} - /* Always use the library code for GPIO management calls, * or when sleeping may be involved. */ @@ -158,7 +152,6 @@ int devm_gpio_request_one(struct device *dev, unsigned gpio, #include struct device; -struct gpio_chip; static inline bool gpio_is_valid(int number) { From patchwork Tue Nov 9 10:02:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 12610365 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B52CC433F5 for ; Tue, 9 Nov 2021 10:12:28 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 69C49604D7 for ; Tue, 9 Nov 2021 10:12:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 69C49604D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=yDu383B5bzE0G0OTgZomR+bM8qFZwTKP+IhJeJnJZI4=; b=BBldJ5AcnavR7O TF61vjF8RcYb1XP+X+Wb602RcfkO20kETEPQWsVJUCZyzv4uEamehZ1lViMLeJuRUU2H9+IjdFcd5 ePbkNJAuH1QsvGNgG8ejfCOSW7vFgiFL474uxRkK8/WQ/J2ic2bvR5HWvo3oRfFPEQ8XKvI9gAtDP olj2ZXrSKCRwm5ZkR9F+wPJWGhmQvJNEFAS3k8d6p+3p0vuXXzCa8ZGNWrs8IUnhyI5kHd5PsFoJU gzJ5eA4mTnBfVAscpvff3w740o7M4FqQZH2rrpmMhr7VkNqnwRKKqqpU2Yk+M51RdSyllKFrXw92B ZPKpfKLxsxPUVMAJ3Y6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkO5a-001R19-Ld; Tue, 09 Nov 2021 10:10:51 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkNxY-001OSk-ML for linux-arm-kernel@lists.infradead.org; Tue, 09 Nov 2021 10:02:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 060D86117A; Tue, 9 Nov 2021 10:02:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636452152; bh=fjfhpwVnN6BHfoLcuj4XM+fICatVkggoN+SpWDROPhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gqTj3CAQGwE5HpUBXwux4QqvrZ8oU4tHfPDwmnfZLdjTSKu4T7iDh/1kut6FiU/9y OEJSVFQBdp1EDlWw1lEhFyigbg1wywdtGkWp1cfrAQpCm4GaWrkYBiPnORTK634uHs R97keSIHUrDZRvvgiGz4znqs94v3uE9tEDlFfbSN7VFNJyQY11yRDLVdIbz4cv930H X2jvE4EE+0lfekXHcvszzvQqGw3HIJL0C2mRuPnwAYrRErEXrbRskllvXO3/h9sdST Tyg9SC9t1nRt0N9lq7nWsPZF8uIFWq2MFEq3tzxAO+URGOLSKuSk0h5eitlWwRXZiz 8VlKQ37MKa2tQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] gpiolib: split linux/gpio/driver.h out of linux/gpio.h Date: Tue, 9 Nov 2021 11:02:07 +0100 Message-Id: <20211109100207.2474024-9-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211109100207.2474024-1-arnd@kernel.org> References: <20211109100207.2474024-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_020232_833116_00BFFC48 X-CRM114-Status: GOOD ( 12.68 ) 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 From: Arnd Bergmann Almost all gpio drivers include linux/gpio/driver.h, and other files should not rely on includes from this header. Remove the indirect include from here and include the correct headers directly from where they are used. Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko --- arch/arm/mach-omap1/irq.c | 1 + arch/arm/mach-orion5x/board-rd88f5182.c | 1 + arch/arm/mach-pxa/lubbock.c | 2 +- arch/arm/mach-s3c/mach-h1940.c | 1 + arch/arm/mach-s3c/s3c64xx.c | 1 + arch/arm/mach-sa1100/assabet.c | 1 + arch/arm/plat-orion/gpio.c | 1 + drivers/gpio/gpio-ucb1400.c | 1 + drivers/mfd/dm355evm_msp.c | 1 + drivers/mfd/htc-i2cpld.c | 1 + drivers/mfd/ucb1400_core.c | 1 + drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 + include/linux/bcma/bcma_driver_chipcommon.h | 2 +- include/linux/gpio.h | 3 --- include/linux/mfd/ucb1x00.h | 1 + include/linux/ucb1400.h | 1 + 16 files changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c index ee6a93083154..d8c38270867f 100644 --- a/arch/arm/mach-omap1/irq.c +++ b/arch/arm/mach-omap1/irq.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/arch/arm/mach-orion5x/board-rd88f5182.c b/arch/arm/mach-orion5x/board-rd88f5182.c index b7b0f52f4c0a..99abf6daca77 100644 --- a/arch/arm/mach-orion5x/board-rd88f5182.c +++ b/arch/arm/mach-orion5x/board-rd88f5182.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c index 742d18a1f7dc..875b405d9fce 100644 --- a/arch/arm/mach-pxa/lubbock.c +++ b/arch/arm/mach-pxa/lubbock.c @@ -9,7 +9,7 @@ * Copyright: MontaVista Software Inc. */ #include -#include +#include #include #include #include diff --git a/arch/arm/mach-s3c/mach-h1940.c b/arch/arm/mach-s3c/mach-h1940.c index 8a43ed1c4c4d..0cc9f9d08c38 100644 --- a/arch/arm/mach-s3c/mach-h1940.c +++ b/arch/arm/mach-s3c/mach-h1940.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/mach-s3c/s3c64xx.c b/arch/arm/mach-s3c/s3c64xx.c index 4dfb648142f2..d098e28bd5dd 100644 --- a/arch/arm/mach-s3c/s3c64xx.c +++ b/arch/arm/mach-s3c/s3c64xx.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 9919e0f32c4b..4ba2d28c1fd3 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c index 734f0be4f14a..e21d589ec78a 100644 --- a/arch/arm/plat-orion/gpio.c +++ b/arch/arm/plat-orion/gpio.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index d2a8644864c3..aceac8bb12ff 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c @@ -6,6 +6,7 @@ */ #include +#include #include static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 2388fb4d0121..2c82907600f0 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 417b0355d904..d7d0a2e50746 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/drivers/mfd/ucb1400_core.c b/drivers/mfd/ucb1400_core.c index 8c3832a58ef6..f71ef41ac9dc 100644 --- a/drivers/mfd/ucb1400_core.c +++ b/drivers/mfd/ucb1400_core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel, diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c index c1b9ac692d26..2349fcce37dd 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include #include #include diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h index d35b9206096d..9ba1b6311681 100644 --- a/include/linux/bcma/bcma_driver_chipcommon.h +++ b/include/linux/bcma/bcma_driver_chipcommon.h @@ -3,7 +3,7 @@ #define LINUX_BCMA_DRIVER_CC_H_ #include -#include +#include /** ChipCommon core registers. **/ #define BCMA_CC_ID 0x0000 diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 61fb427b4e70..f25546e060e9 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -54,9 +54,6 @@ struct gpio { }; #ifdef CONFIG_GPIOLIB - -#include -#include #include /* Platforms may implement their GPIO interface with library code, diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h index 43bcf35afe27..7c0d40ddc674 100644 --- a/include/linux/mfd/ucb1x00.h +++ b/include/linux/mfd/ucb1x00.h @@ -9,6 +9,7 @@ #include #include +#include #include #include diff --git a/include/linux/ucb1400.h b/include/linux/ucb1400.h index 0968ef458447..199b1280fa26 100644 --- a/include/linux/ucb1400.h +++ b/include/linux/ucb1400.h @@ -23,6 +23,7 @@ #include #include #include +#include #include /*