From patchwork Tue Feb 7 14:29:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E15AC636CD for ; Tue, 7 Feb 2023 14:29:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232666AbjBGO3c (ORCPT ); Tue, 7 Feb 2023 09:29:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbjBGO3b (ORCPT ); Tue, 7 Feb 2023 09:29:31 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBF2D190; Tue, 7 Feb 2023 06:29:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780169; x=1707316169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7VgWr2VPj8L1NsfjGJ63Vno2YkqOebd37sMf+dqhyeo=; b=jscZB0N2UJN/Pc0tXopZRvaT2D3XAhPMfD6oaW4L5byZnnNVyWNCxxub IdHtHoQn0vOxJ7lFwzg5kbJegPaGh8leViE2X2/ElmJJeW3JejJboHfhb uVp+fWDik0JBd7CBMNdBIFR8+MNTyHNuhTHewhwvJLxQmmgpP3nKgqDcT MAmITuzyPvCSveL+lDTbiISrMFloCRf+k+bPpGLuTOTg4l0YoyFpnelhM 2yWj0R3Xq10GTQ3dXSe0UCNHRxTfG76EoI63ec5WgcJGV6+BCDn1kwm84 t51yfBmzvkHXx9DnlJr+kOGgvPvrAlTFOdkWON+iw1BKsF+Poga/O/lr1 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="329537331" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="329537331" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="790811310" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="790811310" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 07 Feb 2023 06:29:23 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2D031210; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand , Geert Uytterhoeven Subject: [PATCH v3 01/12] gpiolib: remove empty asm/gpio.h files Date: Tue, 7 Feb 2023 16:29:41 +0200 Message-Id: <20230207142952.51844-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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 Acked-by: Bartosz Golaszewski Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- arch/arm/Kconfig | 1 - arch/arm/include/asm/gpio.h | 21 -------------- arch/sh/Kconfig | 1 - arch/sh/boards/board-magicpanelr2.c | 1 + arch/sh/include/asm/gpio.h | 45 ----------------------------- 5 files changed, 1 insertion(+), 68 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 e24a9820e12f..1d1a603d964d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -24,7 +24,6 @@ config ARM select ARCH_HAS_SYNC_DMA_FOR_CPU 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 4ebbb58f06ea..000000000000 --- a/arch/arm/include/asm/gpio.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ARCH_ARM_GPIO_H -#define _ARCH_ARM_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 0665ac0add0b..ccb866750a88 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_CURRENT_STACK_POINTER 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 Feb 7 14:29:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20DDDC64EC7 for ; Tue, 7 Feb 2023 14:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232956AbjBGOae (ORCPT ); Tue, 7 Feb 2023 09:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231203AbjBGO3m (ORCPT ); Tue, 7 Feb 2023 09:29:42 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EADF15CAE; Tue, 7 Feb 2023 06:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780175; x=1707316175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/KblTEhL3YpOqTWHe101UZEkEjtX7tVjnWOHZilZZaw=; b=KcWgvhV5KNzMa1t9Y6gyOACgkXwOMjjhEz/PG8dxkZyFgqTErBnjCxNm 4dU/ZZC7bz+p62kBGUdCyX86V3Zi2C7AG3mPHi1G5nf4CqYEXipbBYVd6 RwfwKns/h69b7ady1xzCXjBUMagpaalP7XyehZ5KgP0zoPZBEH4V6T54B nnwqn2fKvxMYjFCn1NHk/UxuV/cp0MvSTCCW+VWw6VgfFPiqvJnjPqexl zOq4VoDzo7tjfo7XS+mGZEOLRCSxR/eEHELG5n0U109TXbc3JC4zOBF+3 9NRfsfZtJax9dVGesWXEORBztc7ZmfUpWFQBKUdcDMES63eeuIhpFq0Su A==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="391915608" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="391915608" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="912355032" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="912355032" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2023 06:29:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 528AA269; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand Subject: [PATCH v3 03/12] gpiolib: remove asm-generic/gpio.h Date: Tue, 7 Feb 2023 16:29:43 +0200 Message-Id: <20230207142952.51844-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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: Linus Walleij Reviewed-by: Andy Shevchenko Signed-off-by: Andy Shevchenko --- MAINTAINERS | 1 - arch/m68k/include/asm/mcfgpio.h | 2 +- drivers/gpio/gpio-davinci.c | 2 - drivers/pinctrl/core.c | 1 - include/asm-generic/gpio.h | 147 -------------------------------- include/linux/gpio.h | 93 ++++++++++++++++++-- 6 files changed, 85 insertions(+), 161 deletions(-) delete mode 100644 include/asm-generic/gpio.h diff --git a/MAINTAINERS b/MAINTAINERS index 4d6aa8076868..0469de4e5000 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8730,7 +8730,6 @@ F: Documentation/admin-guide/gpio/ F: Documentation/devicetree/bindings/gpio/ F: Documentation/driver-api/gpio/ F: drivers/gpio/ -F: include/asm-generic/gpio.h F: include/dt-bindings/gpio/ F: include/linux/gpio.h F: include/linux/gpio/ 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 26b1f7465e09..7fc83057990a 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -24,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 d6e6c751255f..401886c81344 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -30,7 +30,6 @@ #ifdef CONFIG_GPIOLIB #include "../gpio/gpiolib.h" -#include #endif #include "core.h" diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h deleted file mode 100644 index 22cb8c9efc1d..000000000000 --- a/include/asm-generic/gpio.h +++ /dev/null @@ -1,147 +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). - */ - -/* - * At the end we want all GPIOs to be dynamically allocated from 0. - * However, some legacy drivers still perform fixed allocation. - * Until they are all fixed, leave 0-512 space for them. - */ -#define GPIO_DYNAMIC_BASE 512 - -struct device; -struct gpio; -struct seq_file; -struct module; -struct device_node; -struct gpio_desc; - -/* 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 void gpio_unexport(unsigned gpio) -{ - gpiod_unexport(gpio_to_desc(gpio)); -} - -#else /* !CONFIG_GPIOLIB */ - -#include - -/* 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 */ - -/* - * "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) -{ - /* only non-negative numbers are valid */ - return number >= 0; -} - -#endif /* _ASM_GENERIC_GPIO_H */ diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 2b75017b3aad..6719a82eeec5 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -54,26 +54,101 @@ struct gpio { }; #ifdef CONFIG_GPIOLIB -#include +#include +#include +#include -static inline int gpio_get_value(unsigned int gpio) +/* + * "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) +{ + /* only non-negative numbers are valid */ + return number >= 0; +} + +/* + * 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). + */ + +/* + * At the end we want all GPIOs to be dynamically allocated from 0. + * However, some legacy drivers still perform fixed allocation. + * Until they are all fixed, leave 0-512 space for them. + */ +#define GPIO_DYNAMIC_BASE 512 + +/* Always use the library code for GPIO management calls, + * or when sleeping may be involved. + */ +int gpio_request(unsigned gpio, const char *label); +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 __gpio_get_value(gpio); + return gpiod_direction_output_raw(gpio_to_desc(gpio), value); } -static inline void gpio_set_value(unsigned int gpio, int value) +static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) { - __gpio_set_value(gpio, value); + return gpiod_set_debounce(gpio_to_desc(gpio), debounce); } -static inline int gpio_cansleep(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 __gpio_cansleep(gpio); + return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); } -static inline int gpio_to_irq(unsigned int gpio) +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)); +} + +int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); +int gpio_request_array(const struct gpio *array, size_t num); +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 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 Feb 7 14:29:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2EE5C64EC5 for ; Tue, 7 Feb 2023 14:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232944AbjBGOac (ORCPT ); Tue, 7 Feb 2023 09:30:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232858AbjBGOaU (ORCPT ); Tue, 7 Feb 2023 09:30:20 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 618A51E5F7; Tue, 7 Feb 2023 06:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780180; x=1707316180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e84O/JP0nsYApruNgGahzcXA9L7vfDArZR+8C/DBBxM=; b=MGC3dTJfgIDdzyauJs5ow+ewaeXICsbhZl1CF6cGg6AxMrGHXctKEsHa h04g/kvGXfo6XDp6AJy6Rk/ral86pgY0xUdyaPstbrWFw7OmfdXPUfNu8 /cNmTeVdFk8/7Ob3VvngIM+8l1tjILjGyffN7ozn7iuUZDHarhttRDpKx JXt9k2u3XLf3R1DENwV3hgKLRdJtHaTF4FZ9Ziruf2nMJ7YmOVJUEiivv L8MXLoCihTrK6+38f40REOJeIb1SQxs+wxuSSYlC1v93QIQPPZsdsSeZD /AOH20h7BdzEVHmIyuGUgPIrEovs6DgU8omNPFfCf/FxFVCiPUej11Jgy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="391915628" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="391915628" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="912355045" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="912355045" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2023 06:29:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 851C137D; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand Subject: [PATCH v3 06/12] gpiolib: split linux/gpio/driver.h out of linux/gpio.h Date: Tue, 7 Feb 2023 16:29:46 +0200 Message-Id: <20230207142952.51844-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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. Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- arch/arm/mach-omap1/irq.c | 1 + arch/arm/mach-orion5x/board-rd88f5182.c | 1 + arch/arm/mach-s3c/s3c64xx.c | 1 + arch/arm/mach-sa1100/assabet.c | 1 + arch/arm/plat-orion/gpio.c | 1 + drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c | 1 + include/linux/gpio.h | 2 -- include/linux/mfd/ucb1x00.h | 1 + 8 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c index 9ccc784fd614..bfc7ab010ae2 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 596601367989..1c14e49a90a6 100644 --- a/arch/arm/mach-orion5x/board-rd88f5182.c +++ b/arch/arm/mach-orion5x/board-rd88f5182.c @@ -9,6 +9,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 e97bd59083a8..48fd5b0a3927 100644 --- a/arch/arm/mach-s3c/s3c64xx.c +++ b/arch/arm/mach-s3c/s3c64xx.c @@ -21,6 +21,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 2eba112f2ad8..d000c678b439 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -10,6 +10,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 3ef9ecdd6343..4946d8066f6a 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/net/wireless/broadcom/brcm80211/brcmsmac/led.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c index 9540a05247c2..89c8829528c2 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/gpio.h b/include/linux/gpio.h index a1271526e489..84bb49939d6e 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -54,9 +54,7 @@ struct gpio { }; #ifdef CONFIG_GPIOLIB -#include #include -#include /* * "valid" GPIO numbers are nonnegative and may be passed to diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h index 43bcf35afe27..ede237384723 100644 --- a/include/linux/mfd/ucb1x00.h +++ b/include/linux/mfd/ucb1x00.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #define UCB_IO_DATA 0x00 From patchwork Tue Feb 7 14:29:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D02B8C64EC5 for ; Tue, 7 Feb 2023 14:31:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233011AbjBGObH (ORCPT ); Tue, 7 Feb 2023 09:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbjBGOaX (ORCPT ); Tue, 7 Feb 2023 09:30:23 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A775D900B; Tue, 7 Feb 2023 06:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780183; x=1707316183; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kEzy7E5g++11ZfX8PhOrp7wyzba5U4Amo9sCg/uj/Rc=; b=c6Uj10hmRQwq4u9b0/L4BMIFMzGAbbZ8sIyk3NkwFEporJJD5EOVlOpX 35N5wibZoGoXW66Vy2Wnlhb1l/6pdG5FjCisReLksZr84R3VoiKhPvcdG kvfzdt8+44Lmqxcp6859WjJk31dWTU88r8+oRKhmvixj/csaVEzjfjvPo jW0R4eJPodbPtHCoCNmsSKD4mA6PqmtdDXNLzUOQGSgeazbzAX79/e9AC 5Dxfog35ny+Y5vR8a3sX1Z/sgQ0adKD+M2XKZb0f8+N7MwAIccQ0QkFyD WH3dHdJv5BtZV9zahL564dM3akH2QN18zhtPfSRPPOMakpjlwLZk2IUMs g==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="313163944" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="313163944" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="644465276" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="644465276" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 07 Feb 2023 06:29:36 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 94945380; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand Subject: [PATCH v3 07/12] gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h Date: Tue, 7 Feb 2023 16:29:47 +0200 Message-Id: <20230207142952.51844-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Arnd Bergmann This is a rarely used feature that has nothing to do with the client-side of_gpio.h. Split it out with a separate header file and Kconfig option so it can be removed on its own timeline aside from removing the of_gpio consumer interfaces. Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- arch/powerpc/platforms/44x/Kconfig | 1 + arch/powerpc/platforms/4xx/gpio.c | 2 +- arch/powerpc/platforms/8xx/Kconfig | 1 + arch/powerpc/platforms/8xx/cpm1.c | 2 +- arch/powerpc/platforms/Kconfig | 2 ++ arch/powerpc/sysdev/cpm_common.c | 2 +- drivers/gpio/Kconfig | 11 +++++++ drivers/gpio/TODO | 15 ++++++--- drivers/gpio/gpio-altera.c | 2 +- drivers/gpio/gpio-mm-lantiq.c | 2 +- drivers/gpio/gpio-mpc5200.c | 2 +- drivers/gpio/gpiolib-of.c | 3 ++ drivers/soc/fsl/qe/gpio.c | 2 +- .../legacy-of-mm-gpiochip.h} | 33 +++---------------- include/linux/of_gpio.h | 21 ------------ 15 files changed, 40 insertions(+), 61 deletions(-) copy include/linux/{of_gpio.h => gpio/legacy-of-mm-gpiochip.h} (50%) diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index 25b80cd558f8..1624ebf95497 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -230,6 +230,7 @@ config PPC4xx_GPIO bool "PPC4xx GPIO support" depends on 44x select GPIOLIB + select OF_GPIO_MM_GPIOCHIP help Enable gpiolib support for ppc440 based boards diff --git a/arch/powerpc/platforms/4xx/gpio.c b/arch/powerpc/platforms/4xx/gpio.c index 49ee8d365852..e5f2319e5cbe 100644 --- a/arch/powerpc/platforms/4xx/gpio.c +++ b/arch/powerpc/platforms/4xx/gpio.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/powerpc/platforms/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig index 60cc5b537a98..a14d9d8997a4 100644 --- a/arch/powerpc/platforms/8xx/Kconfig +++ b/arch/powerpc/platforms/8xx/Kconfig @@ -101,6 +101,7 @@ comment "Generic MPC8xx Options" config 8xx_GPIO bool "GPIO API Support" select GPIOLIB + select OF_GPIO_MM_GPIOCHIP help Saying Y here will cause the ports on an MPC8xx processor to be used with the GPIO API. If you say N here, the kernel needs less memory. diff --git a/arch/powerpc/platforms/8xx/cpm1.c b/arch/powerpc/platforms/8xx/cpm1.c index bb38c8d8f8de..56ca14f77543 100644 --- a/arch/powerpc/platforms/8xx/cpm1.c +++ b/arch/powerpc/platforms/8xx/cpm1.c @@ -44,7 +44,7 @@ #include #ifdef CONFIG_8xx_GPIO -#include +#include #endif #define CPM_MAP_SIZE (0x4000) diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index d41dad227de8..8e4bbd19dec5 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig @@ -244,6 +244,7 @@ config QE_GPIO bool "QE GPIO support" depends on QUICC_ENGINE select GPIOLIB + select OF_GPIO_MM_GPIOCHIP help Say Y here if you're going to use hardware that connects to the QE GPIOs. @@ -254,6 +255,7 @@ config CPM2 select CPM select HAVE_PCI select GPIOLIB + select OF_GPIO_MM_GPIOCHIP help The CPM2 (Communications Processor Module) is a coprocessor on embedded CPUs made by Freescale. Selecting this option means that diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c index 7dc1960f8bdb..8234013a8772 100644 --- a/arch/powerpc/sysdev/cpm_common.c +++ b/arch/powerpc/sysdev/cpm_common.c @@ -31,7 +31,7 @@ #include #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO) -#include +#include #endif static int __init cpm_init(void) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 06a268d56800..178025ca3b34 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -39,6 +39,14 @@ config GPIOLIB_IRQCHIP select IRQ_DOMAIN bool +config OF_GPIO_MM_GPIOCHIP + bool + help + This adds support for the legacy 'struct of_mm_gpio_chip' interface + from PowerPC. Existing drivers using this interface need to select + this symbol, but new drivers should use the generic gpio-regmap + infrastructure instead. + config DEBUG_GPIO bool "Debug GPIO calls" depends on DEBUG_KERNEL @@ -131,6 +139,7 @@ config GPIO_ALTERA tristate "Altera GPIO" depends on OF_GPIO select GPIOLIB_IRQCHIP + select OF_GPIO_MM_GPIOCHIP help Say Y or M here to build support for the Altera PIO device. @@ -403,6 +412,7 @@ config GPIO_MENZ127 config GPIO_MM_LANTIQ bool "Lantiq Memory mapped GPIOs" depends on LANTIQ && SOC_XWAY + select OF_GPIO_MM_GPIOCHIP help This enables support for memory mapped GPIOs on the External Bus Unit (EBU) found on Lantiq SoCs. The GPIOs are output only as they are @@ -411,6 +421,7 @@ config GPIO_MM_LANTIQ config GPIO_MPC5200 def_bool y depends on PPC_MPC52xx + select OF_GPIO_MM_GPIOCHIP config GPIO_MPC8XXX bool "MPC512x/MPC8xxx/QorIQ GPIO support" diff --git a/drivers/gpio/TODO b/drivers/gpio/TODO index 68ada1066941..189c3abe7e79 100644 --- a/drivers/gpio/TODO +++ b/drivers/gpio/TODO @@ -59,11 +59,6 @@ the device tree back-end. It is legacy and should not be used in new code. Work items: -- Get rid of struct of_mm_gpio_chip altogether: use the generic MMIO - GPIO for all current users (see below). Delete struct of_mm_gpio_chip, - to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove() - from the kernel. - - Change all consumer drivers that #include to #include and stop doing custom parsing of the GPIO lines from the device tree. This can be tricky and often ivolves @@ -81,6 +76,16 @@ Work items: uses or instead. +Get rid of + +Work items: + +- Get rid of struct of_mm_gpio_chip altogether: use the generic MMIO + GPIO for all current users (see below). Delete struct of_mm_gpio_chip, + to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(), + CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel. + + Get rid of This legacy header is a one stop shop for anything GPIO is closely tied diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index b59fae993626..99e137f8097e 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -7,7 +7,7 @@ #include #include #include -#include /* For of_mm_gpio_chip */ +#include #include #define ALTERA_GPIO_MAX_NGPIO 32 diff --git a/drivers/gpio/gpio-mm-lantiq.c b/drivers/gpio/gpio-mm-lantiq.c index 538e31fe8903..27ff84c5d162 100644 --- a/drivers/gpio/gpio-mm-lantiq.c +++ b/drivers/gpio/gpio-mm-lantiq.c @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/drivers/gpio/gpio-mpc5200.c b/drivers/gpio/gpio-mpc5200.c index 000494e0c533..3b0bfff8c778 100644 --- a/drivers/gpio/gpio-mpc5200.c +++ b/drivers/gpio/gpio-mpc5200.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 266352b1a966..0f699af438b0 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -892,6 +892,8 @@ static int of_gpio_simple_xlate(struct gpio_chip *gc, return gpiospec->args[0]; } +#if IS_ENABLED(CONFIG_OF_GPIO_MM_GPIOCHIP) +#include /** * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank) * @np: device node of the GPIO chip @@ -964,6 +966,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc) kfree(gc->label); } EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove); +#endif #ifdef CONFIG_PINCTRL static int of_gpiochip_add_pin_range(struct gpio_chip *chip) diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c index 1c41eb49d5a7..3ef24ba0245b 100644 --- a/drivers/soc/fsl/qe/gpio.c +++ b/drivers/soc/fsl/qe/gpio.c @@ -13,7 +13,7 @@ #include #include #include -#include /* for of_mm_gpio_chip */ +#include #include #include #include diff --git a/include/linux/of_gpio.h b/include/linux/gpio/legacy-of-mm-gpiochip.h similarity index 50% copy from include/linux/of_gpio.h copy to include/linux/gpio/legacy-of-mm-gpiochip.h index 5d58b3b0a97e..2e2bd3b19cc3 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/gpio/legacy-of-mm-gpiochip.h @@ -1,26 +1,19 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * OF helpers for the GPIO API + * OF helpers for the old of_mm_gpio_chip, used on ppc32 and nios2, + * do not use in new code. * * Copyright (c) 2007-2008 MontaVista Software, Inc. * * Author: Anton Vorontsov */ -#ifndef __LINUX_OF_GPIO_H -#define __LINUX_OF_GPIO_H +#ifndef __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H +#define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H -#include #include -#include /* FIXME: Shouldn't be here */ #include -struct device_node; - -#ifdef CONFIG_OF_GPIO - -#include - /* * OF GPIO chip for memory mapped banks */ @@ -35,25 +28,9 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) return container_of(gc, struct of_mm_gpio_chip, gc); } -extern int of_get_named_gpio(const struct device_node *np, - const char *list_name, int index); - extern int of_mm_gpiochip_add_data(struct device_node *np, struct of_mm_gpio_chip *mm_gc, void *data); extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); -#else /* CONFIG_OF_GPIO */ - -#include - -/* Drivers may not strictly depend on the GPIO support, so let them link. */ -static inline int of_get_named_gpio(const struct device_node *np, - const char *propname, int index) -{ - return -ENOSYS; -} - -#endif /* CONFIG_OF_GPIO */ - -#endif /* __LINUX_OF_GPIO_H */ +#endif /* __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H */ diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index 5d58b3b0a97e..d0f66a5e1b2a 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -19,30 +19,9 @@ struct device_node; #ifdef CONFIG_OF_GPIO -#include - -/* - * OF GPIO chip for memory mapped banks - */ -struct of_mm_gpio_chip { - struct gpio_chip gc; - void (*save_regs)(struct of_mm_gpio_chip *mm_gc); - void __iomem *regs; -}; - -static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) -{ - return container_of(gc, struct of_mm_gpio_chip, gc); -} - extern int of_get_named_gpio(const struct device_node *np, const char *list_name, int index); -extern int of_mm_gpiochip_add_data(struct device_node *np, - struct of_mm_gpio_chip *mm_gc, - void *data); -extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); - #else /* CONFIG_OF_GPIO */ #include From patchwork Tue Feb 7 14:29:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EBABC636CC for ; Tue, 7 Feb 2023 14:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbjBGObl (ORCPT ); Tue, 7 Feb 2023 09:31:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232931AbjBGOaY (ORCPT ); Tue, 7 Feb 2023 09:30:24 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AC1E3E0A5; Tue, 7 Feb 2023 06:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780185; x=1707316185; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e2HL48VZL68iHiIHMOw3KrWX1/vewPFZgcuY53UtAyY=; b=hPtQVyeN9rWFWKLKduGREGWWOdQGgLgwNbnVbzYVIgw1xnFeiLX6jex6 Q36xLJjc/YM9OL36yFDhadsy2sKxxtLMmSbksqgHstOe0t4+FiBq0blPT VuVWPLqMR6PIEeuUAF7hgrznypq01jUCrBVpmGvnm3f4izZKaLV+edxhG h/c/Kd9HVLW8EK8fm8dibsSt8/bQBCBeA2yLM9L+Z0wKHk75hjEfZTh4y 2rOBDedKsG8IzM36Wn9FNQSDU3aVmWMX1k16G2RqzsUvG/v54OHDvh6h0 nAqYjB0BmwCctw1+ip7nfojfbrx9Dkmzxsr7VIi40g6Lgldj3fhsD0WMx g==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="391915676" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="391915676" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="912355055" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="912355055" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2023 06:29:40 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CEAE14C9; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand Subject: [PATCH v3 11/12] gpiolib: Group forward declarations in consumer.h Date: Tue, 7 Feb 2023 16:29:51 +0200 Message-Id: <20230207142952.51844-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For better maintenance group the forward declarations together. Signed-off-by: Andy Shevchenko --- include/linux/gpio/consumer.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index a7eb8aa1e54c..5432e5d5fbfb 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -7,6 +7,7 @@ #include #include +struct acpi_device; struct device; struct fwnode_handle; struct gpio_desc; @@ -602,8 +603,6 @@ struct acpi_gpio_mapping { unsigned int quirks; }; -struct acpi_device; - #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI) int acpi_dev_add_driver_gpios(struct acpi_device *adev, From patchwork Tue Feb 7 14:29:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 651587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 692BAC64EC7 for ; Tue, 7 Feb 2023 14:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233105AbjBGOcc (ORCPT ); Tue, 7 Feb 2023 09:32:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232853AbjBGOac (ORCPT ); Tue, 7 Feb 2023 09:30:32 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 245213E0B7; Tue, 7 Feb 2023 06:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675780187; x=1707316187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A4CXaCS1V5YYLH/ZOzB/EoGrp/Od1buKWHTb7RvcWAk=; b=ZCHQ22qDErP4hNS/reIPHR8VZjEiIaorzIFb9JnR0ZLXSGhY6LMpwBf5 jJfJjX1ZIzwSBDv6Jfof5q4WcBP+g49q+P33KqSS6ToXJ2nIvCbC42N0U JUOyMzNogKUO4pNvjSjN/Yq1sUZeLA3tiUAR9lK+ZAMjEcdwS6CLqXPTE zbExXLHHk1wkaNzn+MeO//PBuOfvxcChkyIt1JXToQeB+4ACyaEGe2X12 WEDTG1CzWAjwcEO7XBn1EbAGrTTUAfZO6owG6+/GS9H3QMRuJPj5UQDTI RiSrW2rDbSFy8xTrlp0qSSvj0Q3m19XV/BtgbKsiYiLtaDbUlD31hmJKh w==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="391915711" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="391915711" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2023 06:29:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="912355058" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="912355058" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2023 06:29:41 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DD3DF556; Tue, 7 Feb 2023 16:30:02 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Arnd Bergmann , Bartosz Golaszewski , Tony Lindgren , Thomas Gleixner , Krzysztof Kozlowski , Geert Uytterhoeven , Christophe Leroy , Michael Ellerman , Devarsh Thakkar , Dmitry Torokhov , Stefan Schmidt , Miquel Raynal , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc-tw-discuss@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-arch@vger.kernel.org, devicetree@vger.kernel.org Cc: Bartosz Golaszewski , Jonathan Corbet , Alex Shi , Yanteng Si , Hu Haowen , Russell King , Aaro Koskinen , Janusz Krzysztofik , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Alim Akhtar , Nicholas Piggin , Yoshinori Sato , Rich Felker , Mun Yew Tham , Keerthy , Mika Westerberg , Mauro Carvalho Chehab , Alexander Aring , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , Qiang Zhao , Li Yang , Lee Jones , Rob Herring , Frank Rowand Subject: [PATCH v3 12/12] gpiolib: Clean up headers Date: Tue, 7 Feb 2023 16:29:52 +0200 Message-Id: <20230207142952.51844-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> References: <20230207142952.51844-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is a few things done: - include only the headers we are direct user of - when pointer is in use, provide a forward declaration - add missing headers - group generic headers and subsystem headers - sort each group alphabetically Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 10 ++++++---- drivers/gpio/gpiolib-acpi.h | 1 - drivers/gpio/gpiolib-of.c | 6 ++++-- drivers/gpio/gpiolib-of.h | 1 - drivers/gpio/gpiolib-swnode.c | 5 +++-- drivers/gpio/gpiolib-sysfs.c | 21 ++++++++++++++++----- drivers/gpio/gpiolib.c | 9 ++++++--- include/linux/gpio.h | 9 +++------ include/linux/gpio/consumer.h | 14 ++++++++++---- include/linux/gpio/driver.h | 30 +++++++++++++++++++++++------- 10 files changed, 71 insertions(+), 35 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bb583cea366c..3871dade186a 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -7,17 +7,19 @@ * Mika Westerberg */ +#include #include #include -#include -#include -#include #include -#include #include +#include #include #include +#include +#include +#include + #include "gpiolib.h" #include "gpiolib-acpi.h" diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 5fa315b3c912..a6f3be0bb921 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -9,7 +9,6 @@ #define GPIOLIB_ACPI_H #include -#include #include #include diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 0f699af438b0..1436cdb5fa26 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -10,14 +10,16 @@ #include #include #include -#include #include -#include +#include #include #include #include #include #include +#include + +#include #include #include "gpiolib.h" diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h index e5bb065d82ef..6b3a5347c5d9 100644 --- a/drivers/gpio/gpiolib-of.h +++ b/drivers/gpio/gpiolib-of.h @@ -4,7 +4,6 @@ #define GPIOLIB_OF_H #include -#include #include #include diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c index dd9ccac214d1..b5a6eaf3729b 100644 --- a/drivers/gpio/gpiolib-swnode.c +++ b/drivers/gpio/gpiolib-swnode.c @@ -6,13 +6,14 @@ */ #include #include -#include -#include #include #include #include #include +#include +#include + #include "gpiolib.h" #include "gpiolib-swnode.h" diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 6e4267944f80..c1cbf71329f0 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -1,18 +1,29 @@ // SPDX-License-Identifier: GPL-2.0 + +#include +#include #include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include #include +#include + #include #include -#include -#include -#include -#include #include "gpiolib.h" #include "gpiolib-sysfs.h" +struct kernfs_node; + #define GPIO_IRQF_TRIGGER_NONE 0 #define GPIO_IRQF_TRIGGER_FALLING BIT(0) #define GPIO_IRQF_TRIGGER_RISING BIT(1) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 99a2c77c3711..900f6573c070 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -6,22 +6,25 @@ #include #include #include +#include #include #include -#include -#include -#include #include #include #include #include #include #include +#include #include #include #include #include +#include +#include +#include + #include #include "gpiolib-acpi.h" diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 84bb49939d6e..574c45be924b 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -12,7 +12,7 @@ #ifndef __LINUX_GPIO_H #define __LINUX_GPIO_H -#include +struct device; /* see Documentation/driver-api/gpio/legacy.rst */ @@ -132,20 +132,17 @@ void gpio_free_array(const struct gpio *array, size_t num); /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ -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); #else /* ! CONFIG_GPIOLIB */ -#include #include #include -struct device; -struct gpio_chip; +#include +#include static inline bool gpio_is_valid(int number) { diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 5432e5d5fbfb..1c4385a00f88 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -3,15 +3,14 @@ #define __LINUX_GPIO_CONSUMER_H #include -#include -#include -#include +#include struct acpi_device; struct device; struct fwnode_handle; -struct gpio_desc; + struct gpio_array; +struct gpio_desc; /** * struct gpio_descs - Struct containing an array of descriptors that can be @@ -185,8 +184,11 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev, #else /* CONFIG_GPIOLIB */ +#include #include +#include + static inline int gpiod_count(struct device *dev, const char *con_id) { return 0; @@ -616,6 +618,8 @@ struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char #else /* CONFIG_GPIOLIB && CONFIG_ACPI */ +#include + static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev, const struct acpi_gpio_mapping *gpios) { @@ -647,6 +651,8 @@ void gpiod_unexport(struct gpio_desc *desc); #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ +#include + static inline int gpiod_export(struct gpio_desc *desc, bool direction_may_change) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 262a84ce9bcb..5c6db5533be6 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -2,27 +2,35 @@ #ifndef __LINUX_GPIO_DRIVER_H #define __LINUX_GPIO_DRIVER_H -#include -#include +#include #include #include +#include #include #include #include #include +#include #include +#ifdef CONFIG_GENERIC_MSI_IRQ #include +#endif -struct gpio_desc; +struct device; +struct irq_chip; +struct irq_data; +struct module; struct of_phandle_args; +struct pinctrl_dev; struct seq_file; -struct gpio_device; -struct module; -enum gpiod_flags; -enum gpio_lookup_flags; struct gpio_chip; +struct gpio_desc; +struct gpio_device; + +enum gpio_lookup_flags; +enum gpiod_flags; union gpio_irq_fwspec { struct irq_fwspec fwspec; @@ -679,6 +687,10 @@ bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gc, int gpiochip_irqchip_add_domain(struct gpio_chip *gc, struct irq_domain *domain); #else + +#include +#include + static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc, struct irq_domain *domain) { @@ -756,6 +768,10 @@ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); #else /* CONFIG_GPIOLIB */ +#include + +#include + static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) { /* GPIO can never have been requested */