From patchwork Fri Jan 27 10:11:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755186wrn; Fri, 27 Jan 2023 02:17:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxlMDaBUS9uSP4fD5lm61CcOk3LM1iPjJ0orR9yJCpVlInGgCbQdkSW5QtfgdVPFniSHzx X-Received: by 2002:a05:6a20:4407:b0:ac:16ae:f46 with SMTP id ce7-20020a056a20440700b000ac16ae0f46mr55385952pzb.15.1674814641654; Fri, 27 Jan 2023 02:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814641; cv=none; d=google.com; s=arc-20160816; b=n164LFLOZaFnLWVreqHxBB69zTs3EOZrjaJgt6PHQ4K8Ppv0tDcSjF7Tlq1P2pYYUy Bwy51NRFkDDdVGNqAOzM8pNUbYRCm5cxWAvI1oh0mxhcPKINjcRljnASBx+k8xuJh/Gg ik9yzj0Bka7sPmTYx8iGiHXG2MdEs8IO7RiT/xalOMf803n4Itb5y8coJOcWYEvEzgMW CvjgttHLD/ADr0Pc8+jDfR4KkvFcOC59DQon/QMtdyfszML88SJYBIEH+mW32KUilkvC JycKjEkc5+Qr5oQ+hiRRQP9FOUA7j83nHcLeRjoP+urdSbeKwEIx4BOVTAQVFCezUTdo DuVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ukdtxrN7+aWqEr8LCA/LxwFG3lxx6BnY7a35lM0jdps=; b=hLv4+HxWQRbsccx621LKD3Ueb7676C/A9nNUfUo9U+k6ez3eK+lJD7YOH17FqlSXRm wuP2HGkAK730Pb6FjnnsROPpDseZG5ahKI7a4b4L+6K/OfobSr21uYHhuPBxjZXzhYnD NbhRMMlcrAFHZQAfyu+d1r00B256wF3jTlw6Z3eMkvqCbiopvsBCdPvc/W6F/pI7Vdy2 H4vUrOY1XC6CP0Wqh1PYpg2zmzzICvhKLTHf70d7M68guocDeYjGiUeeRytDQp04NTr2 fb/l9P4aalWQ9bC3/ZJpmWiBuc96WHBxqqPrkcSdK1Baz9rGcVLT4l/ipEKJRyFrrpE5 8lXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l/lmYw3E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a63bf0f000000b004d0ef90d860si4158665pgf.297.2023.01.27.02.17.07; Fri, 27 Jan 2023 02:17:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l/lmYw3E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233379AbjA0KMO (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbjA0KMM (ORCPT ); Fri, 27 Jan 2023 05:12:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A07F4DBD6; Fri, 27 Jan 2023 02:12:11 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AC67161AAF; Fri, 27 Jan 2023 10:12:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65FAC4339B; Fri, 27 Jan 2023 10:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814330; bh=4dQ7nHYJ98q19ZMod1DMiWnCXOcE2qsLTAcpzyaMqNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l/lmYw3EZMVe5BhkZEN2SJuE3xNgUAmzb24vOBLmHt20I6lyZGaDuYjfnpTsgZR9e UIVHM0INLHukfZBRgs/B3hmXJANuQobI/Zu2PxzCip+Bh3u2gHWsLZis3gXJLMg8Rw bvCoK9THT0i3osELPS1r+7SnPLG51bLMieKQVQWjhHlU8ei0K+g76siil/Q8Co+tsW YP/cj/Lq4bbPmaFG3HEQSWLVl6BjvRP0wTqZdWR73D8vw7n4AJMgFYZyu3411+Imfz vePnibJEBhi/hXRm6gvM17ikEpIYwosYpJVq/cq9j94xEzBT7ZADU7FOkmx+sO3fdn 3ilv7QBPG/hrQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org, Geert Uytterhoeven , Bartosz Golaszewski Subject: [PATCH v2 1/7] gpiolib: remove empty asm/gpio.h files Date: Fri, 27 Jan 2023 11:11:43 +0100 Message-Id: <20230127101149.3475929-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170437425773822?= X-GMAIL-MSGID: =?utf-8?q?1756170437425773822?= 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 --- 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 5c8bab8d6009..b4447a055029 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_LDREX 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 c3434f0ffc7d..626c716c086c 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 Fri Jan 27 10:11:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp754980wrn; Fri, 27 Jan 2023 02:16:47 -0800 (PST) X-Google-Smtp-Source: AK7set9vnZmWhhlnX1KjeMIxhtuNOqxPjlSk2h9pA7T4pDYNOwufOeY4cGgCTxC3ELCBG1duvAD8 X-Received: by 2002:a17:903:22c5:b0:196:3a54:8b29 with SMTP id y5-20020a17090322c500b001963a548b29mr8880584plg.42.1674814607225; Fri, 27 Jan 2023 02:16:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814607; cv=none; d=google.com; s=arc-20160816; b=R8H0Be44TM41gU3ZErvX8AJO9lqresAo3FcYGoGbwtUVsiReaWZvP4LHCv07hiMcmP XAguDxXYtZSBEIldMdSCEqN19DwMtAA7ywZ5ZPk6r7ihbdGZPqFyeZdNvaucOg4l24OG RH+uV9uXtp11LpOMWjSmdfkT9rt/XjRZ0yXtzPhSehpqAiz84dj1hLl4sAjCjBegaM7u xUMnkzYoDr9D/QV1NT5pdEtSou3JLbrTPiGwuE4V0BiO5pcg8cqqSPy7sGbdcKi3o7qW +UKKPGRBedWAr5tR2TC2dtLrG3/oX0BPDiVziTJt1DsWhvRmUrbP37EK7F50mUDA3ERA R5fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rmfWR+TxlTbEaY/BU7YF7gijjBruREc7MZlOOy88vYg=; b=qMNh7tsPGw5uOoJaipNyY2fz0Dufamqj2bqOo4EyUa3D8N+ZPBR1SkzEJ3AWHDS6BT zUEETCPLf3R9BSfB5x1K9+oUnpx2KxcGC0BrVKqBXQwtIcdjRJBcD1j2H0o7HvRkvlcE +DBBV630N12eo3CMrmn5kgNb92ER589e/95yGrN8dFzHH/0GQ8y5dGc9ueU4orooI4UB JoVa88enzmvLsdD53KYL5uyJ7ykkXWLLSV9xzPILNLOGsPMMUcCVumVYZMmoafrdZjFp qejRe5nQR88px3oqiemqGCL/+Zt8yZMVgvPOMkdbV7IQQ+q8tueS7GAlu3oqbhX7h3Fa FtcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iXIPoorZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902d2c700b0019329cd26dcsi4406348plc.442.2023.01.27.02.16.35; Fri, 27 Jan 2023 02:16:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iXIPoorZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233435AbjA0KMS (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233421AbjA0KMP (ORCPT ); Fri, 27 Jan 2023 05:12:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD1605B58B; Fri, 27 Jan 2023 02:12:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 59D2461AAF; Fri, 27 Jan 2023 10:12:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E2A6C433D2; Fri, 27 Jan 2023 10:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814332; bh=RZ1fmdMVmu1ZL5T1WHPOBBM4KWGHMMX/CdeGvQ6/1fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iXIPoorZLArK1+POCT5OBBv55IBYs1WqBPwURlLb6My4OTF9Rls5g3g/+gzqNfTNd r2U6Cl06P60DG/aKbqmYbJMwOjwF5zGPdC1ctkWt8pqOluTitY+Ed03G+6w+TEqAUF yvbQoE5zASFGhRJydL3aslFWAMr4VTF8gNtzvZfpfstILV8hAdL68DS4I7AlMFyQRB npGiEJiu78vdHclzCFPGbXbu4+dIeAHp4zeijtQmADD9GQXgVuc+WMtkLcRZ/aCs5u hWYNJaroQjpCVfG9VykoAPuShBEw+9gML/VdnfNUUTo+h1/j6sFe9cRQUQ4zJj0TFi a5exwqny+ipbg== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org, Geert Uytterhoeven , Bartosz Golaszewski Subject: [PATCH v2 2/7] gpiolib: coldfire: remove custom asm/gpio.h Date: Fri, 27 Jan 2023 11:11:44 +0100 Message-Id: <20230127101149.3475929-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170401438024909?= X-GMAIL-MSGID: =?utf-8?q?1756170401438024909?= 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 Acked-by: Bartosz Golaszewski Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij --- 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 9380f6e3bb66..96a0fb4f1af5 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 218d7e4c27ff..06a268d56800 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 85beb236c925..2b75017b3aad 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 Fri Jan 27 10:11:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755339wrn; Fri, 27 Jan 2023 02:17:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXsfRtLmpOX3ojMRy5dIoG4HkaJP+SLGx5nrgCY+daehu3gBfPuUEcezL1MGNhLdOaOjq/Ao X-Received: by 2002:a17:90b:1d0f:b0:229:f975:9c90 with SMTP id on15-20020a17090b1d0f00b00229f9759c90mr28882959pjb.5.1674814665453; Fri, 27 Jan 2023 02:17:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814665; cv=none; d=google.com; s=arc-20160816; b=jkGM/0PB9fgbmcQvGJ7P23OxJfnre4Chi7vk4UWIqj5cC1YxGrOE7fKCOK3MPUP6YR xpFq6a5Q1Sqi08OpR0mlLmKfkfDqUJ45Iojcwd3koZrk6PovDWfSYaAUfhS3w3fg02BH 4cVQrVTa6cQ/bZ6Idi2v8DXLYgrnzGLX2a8m6PPeG//nv7jKlzYpXj9ZlYZ9/nVFMo2M IfW2IAfX2Fg3iTMjjFjchln7PcN4oRbYiFVmfVWZjBkJ98PZH3JjqEk+00/yYcF/2SIg RzcV+KMgmSNcE1sedOjXzzUZLby/JT0sc6+Tfu52siAEhP2fxgPCSTVCRNcOr5X4Cx58 cNuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+3iNfu1gjFZPrpVL/FubF3ldA2QqOchcc3h+Zp0qoLA=; b=H5PEUULAwxpB09Mi+RXGKF4wCoSOCM8N1gfKwHufWBFqUV0wAvXzU2yHNdpblE0Mz9 i2i3jucPt6eQK40xnbjH9JpxPg3OYL9uOK2Jk5OhKEbKytL5mpJkfYTBa2v++NpPlD/L WyTTx0AGv1vpvbeFeVNgK3fpZ5rKnRR/0TaTw69KdYxYrW24i6DeoTyluAxz4x/ru1t2 iViziANSY1dfv1eFD6iWrTJlM9nPQSxqx1ooffQGHrHSoMVPN8QucOttlnSCiwNFeH7G Ly4S0xioT7HzZkFusrgMmnRPEj9iPB3nMheCclVAaPJCgDiU6o34rxe5t+AW4rSmC5+q rjFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Del35osK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a637003000000b0047923e93e6esi3884529pgc.555.2023.01.27.02.17.32; Fri, 27 Jan 2023 02:17:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Del35osK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233443AbjA0KM2 (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233424AbjA0KMU (ORCPT ); Fri, 27 Jan 2023 05:12:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150054B75C; Fri, 27 Jan 2023 02:12:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 568CDB81FC7; Fri, 27 Jan 2023 10:12:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C583C433EF; Fri, 27 Jan 2023 10:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814335; bh=0YBdE3btLJ2tSRcQLbs5o3QlmOGeboxgMUsAgzinaCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Del35osK027VH9O0jWiWluhlUkbUEFsYzC7bxkigUMrFMA8Jjmrb06N7cICgNLvvg 6Z4gaWXk3Lw6E7FsZ6gam5111+hdWGgve77714yHCecBkmNlvEeUxSjMzrJKAY+Cya lX6Wj1HfmB6iVrcPlewAcVCn27qPEUAs2421hrjzIn5zQJoEQudTPB1ti3MU++pEOH FK1dkqcZyB89O6Bpaod/96iF/rfesXzx8zIJZQfBy/zMLwWQALoK+H09ZMMaz0II7a ec35f2n5BF8Jodj90qt0iV+Xp6GLvvxsVBQzccLUpzNxpp9MvSpel1VIgflCYI3YKD ejWo5bWD56tuA== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] gpiolib: remove asm-generic/gpio.h Date: Fri, 27 Jan 2023 11:11:45 +0100 Message-Id: <20230127101149.3475929-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170462838147156?= X-GMAIL-MSGID: =?utf-8?q?1756170462838147156?= 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 Reviewed-by: Linus Walleij --- 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 f64c8f15df4b..25f16f825427 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8731,7 +8731,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 Fri Jan 27 10:11:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755201wrn; Fri, 27 Jan 2023 02:17:23 -0800 (PST) X-Google-Smtp-Source: AK7set8boynnC+Y0qWWngtKqTYA6cfEdlZ19yyBFIjaEj7/lcnfgYAEpWnYiWnIIDCb2H+vImcM6 X-Received: by 2002:a17:903:230b:b0:196:11ad:8197 with SMTP id d11-20020a170903230b00b0019611ad8197mr5259694plh.66.1674814643361; Fri, 27 Jan 2023 02:17:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814643; cv=none; d=google.com; s=arc-20160816; b=NCp/gZDbsWF9lJQInElwT595OamfBYdka0eoDcMa3OSSRbyKlcfyzeLPvWbf+yuqOO bpUKO8eyMZztkIYGU1VzyLnyrpm8EwQZ7vdcMj7W9ErozM7KMwAO6wqY/Ml6L1g/8lVt UrAKpQNbWqPIA0C4yJFB9idm4F47W2QF4hgZPpQes3eFwG2aCujcSOtxxd8+OWtIvDI5 qKK1qZYdgUN5A4FpNPriHTVsMu94PPcUF3aYkDCcNKKMGcAqYj9kLMfoP+mzPPwuoVrF wz24BbKlrejVnvw8qLcBOdh5zL2Hu2x9vlYS1Wbn8l0Hb30uKfF3SHIpvIYfyNExdP7e s6OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pqhtvzbu1wnbdn/CwPHhGOjk/FiHQWM2mDT0DtSu72s=; b=lwVHgKLP06cckpjzXAXpzQtxZ1Tm63MoxrJ//+o940EzNyDDR/rMK6SVxSccbeHgk1 VLWUviNIReyckfa2QStM6w5PfjOdwSrxG6NhIPXJyallFuDCexMyQwieRymTspH4tlQH QRd9Y3V55gE0LBzhQ7AFbGp3v0lqPOtkwzwTwB6h8B/AMOXcI4xaZtDeN1wHm9MbopEm HBaAPPdXT8Zj20v6D7ZjfjIZearEYFJUtv3LB94qsE6ud6DstJ9rfjbg/Y1EOIve5mxb de/84YiaprcGVV/oY2R362O2Jm5aI30lRbe2N1e5xYQSPrFUtuKilUqetg4GsXsQlQQr GhPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZJhYa2f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bi12-20020a170902bf0c00b00194b7455ecasi3952481plb.415.2023.01.27.02.17.10; Fri, 27 Jan 2023 02:17:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OZJhYa2f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233462AbjA0KMh (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233460AbjA0KM0 (ORCPT ); Fri, 27 Jan 2023 05:12:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313F677DC0; Fri, 27 Jan 2023 02:12:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ABCE7B8200B; Fri, 27 Jan 2023 10:12:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80B6FC4339B; Fri, 27 Jan 2023 10:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814337; bh=6X11Bz5b7lMqNuxX3JeGI1QvkklF41RteWtCBQ9Y6ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZJhYa2fP6kxnOJmThRuT6aKaRPVTYHFq6S/utZHYIdb8myC2EE/rx/5B0gkIflfx nsoNM6JbvWWsA9k5rSSudC1YUfZQQnFm37r8RrNR2TvjRaHFtfIxOlCpwyJy3KcYEZ Ncaim1+F2kYHPJkyV8+scFbBvPzHHlqRUqRhoNglozFZk25dyADlo6CDTaWQI1JkK0 4gnt/d+dCtmKd8K0FHeC5PwFEN58pWjtqpAoaDAff2picVZqLJy3BI7qx8qpshvLCV WhCPo4JLLK415WfI/aopLDNKlnb2Rz3jNqEB0AXfWDnUw29UkfI3CIaw8UIWAx0Z+m UAjPu6fODXZ0Q== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] gpiolib: remove gpio_set_debounce Date: Fri, 27 Jan 2023 11:11:46 +0100 Message-Id: <20230127101149.3475929-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170439823272933?= X-GMAIL-MSGID: =?utf-8?q?1756170439823272933?= From: Arnd Bergmann gpio_set_debounce() only has a single user, which is trivially converted to gpiod_set_debounce(). Signed-off-by: Arnd Bergmann Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij --- Documentation/driver-api/gpio/legacy.rst | 2 -- .../zh_CN/driver-api/gpio/legacy.rst | 1 - Documentation/translations/zh_TW/gpio.txt | 1 - drivers/input/touchscreen/ads7846.c | 25 ++++++++++--------- include/linux/gpio.h | 10 -------- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst index a0559d93efd1..e0306e78e34b 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/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst index 74fa473bb504..dee2a0517c1c 100644 --- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst +++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst @@ -219,7 +219,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其 ## gpio_free_array() gpio_free() - gpio_set_debounce() diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt index 1b986bbb0909..dc608358d90a 100644 --- a/Documentation/translations/zh_TW/gpio.txt +++ b/Documentation/translations/zh_TW/gpio.txt @@ -226,7 +226,6 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其 ## gpio_free_array() gpio_free() - gpio_set_debounce() diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 4c3dd01902d0..da3c55d9cb98 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -139,7 +139,7 @@ struct ads7846 { int (*filter)(void *data, int data_idx, int *val); void *filter_data; int (*get_pendown_state)(void); - int gpio_pendown; + struct gpio_desc *gpio_pendown; void (*wait_for_sync)(void); }; @@ -222,7 +222,7 @@ static int get_pendown_state(struct ads7846 *ts) if (ts->get_pendown_state) return ts->get_pendown_state(); - return !gpio_get_value(ts->gpio_pendown); + return !gpiod_get_value(ts->gpio_pendown); } static void ads7846_report_pen_up(struct ads7846 *ts) @@ -1005,7 +1005,6 @@ static int ads7846_setup_pendown(struct spi_device *spi, if (pdata->get_pendown_state) { ts->get_pendown_state = pdata->get_pendown_state; } else if (gpio_is_valid(pdata->gpio_pendown)) { - err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown, GPIOF_IN, "ads7846_pendown"); if (err) { @@ -1015,15 +1014,17 @@ static int ads7846_setup_pendown(struct spi_device *spi, return err; } - ts->gpio_pendown = pdata->gpio_pendown; - - if (pdata->gpio_pendown_debounce) - gpio_set_debounce(pdata->gpio_pendown, - pdata->gpio_pendown_debounce); + ts->gpio_pendown = gpio_to_desc(pdata->gpio_pendown); } else { - dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); - return -EINVAL; + ts->gpio_pendown = gpiod_get(&spi->dev, "pendown-gpio", GPIOD_IN); + if (IS_ERR(ts->gpio_pendown)) { + dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); + return PTR_ERR(ts->gpio_pendown); + } } + if (pdata->gpio_pendown_debounce) + gpiod_set_debounce(ts->gpio_pendown, + pdata->gpio_pendown_debounce); return 0; } @@ -1192,7 +1193,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) pdata->wakeup = of_property_read_bool(node, "wakeup-source") || of_property_read_bool(node, "linux,wakeup"); - pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0); + pdata->gpio_pendown = -1; return pdata; } diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 6719a82eeec5..220e8656f2ab 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -100,11 +100,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)); @@ -215,11 +210,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 */ From patchwork Fri Jan 27 10:11:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755240wrn; Fri, 27 Jan 2023 02:17:28 -0800 (PST) X-Google-Smtp-Source: AK7set9//Vb1OO09YP/iQ0SSwXNN4dPNBzjTuQLPYMLIx+Gu/uolCkSchxOUusMXyUX77PqxjdyQ X-Received: by 2002:aa7:98c6:0:b0:590:7526:713f with SMTP id e6-20020aa798c6000000b005907526713fmr7078896pfm.25.1674814648684; Fri, 27 Jan 2023 02:17:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814648; cv=none; d=google.com; s=arc-20160816; b=Zi/A938wj7WMw8txy9/SnFZaOgac/z9qQzwtDpc3vZloJAslJIf+ryivNKme819BXB kjGmIQwUlrMzjN32JQcbpCmK+QMYPXRIXgRrPvDZJ9f4VFeeUTIP7U+LGaWl1e0769jW eRQ6aiIBLVdKudVKiWm0PfnzL6P5XxxUW8ab9NcGlUkKmMwzlPr3uCssoy1+xaIb7H9l 1PFWYqJw5Jbgv2w/WvkWncNbMIAigqxXzi5ki+8AzpJPH1f6ShVqQ5Lp6txYq3JOuyO+ zVOOv16j9Qm3d3ZATB3l97bWDsbJ+vKgjJIc0vufMD7BxqD34CEUBlBImi2M3yr6rVR5 EaTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nJnbvlvox+JNcJs5DZAo/r68t7IPEBKh+BJbB2JvGQE=; b=U+80++mvcQ97zlMAyA+efpSmJ5bRtszsFgaSXIV7+ooUdgEoQeyn3HArWUMqlTrHEK AsHW5qRE0hFEoKeBI21bgigLuj45f+h6Dp3VqQTzFKEI1AODm2t6k4JCLK9Q//N+we3L MYfapcX/1nfLAZfcRfGU7jAiIMdleuGrN8BUbyKrEQtunsal0anFMJIA1qLdKkpocz7q m0l4uDXl8CtZaSmZbTVKEh6o9i29j5jAw0RIwRiaankJInnvhkL9Kh2TRfZc2j36oF6r fiCugA1ivZJCSY3WxIJcNQ/KHVbT/W1YvAVjexiaMvOm8n381CBGPTresh1hdRGE74fQ 7h/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oYxUd3H6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x48-20020a056a000bf000b0058bc2e77660si4075118pfu.37.2023.01.27.02.17.10; Fri, 27 Jan 2023 02:17:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oYxUd3H6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233424AbjA0KMj (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233465AbjA0KM2 (ORCPT ); Fri, 27 Jan 2023 05:12:28 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C68E884B79; Fri, 27 Jan 2023 02:12:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3AD3361AAF; Fri, 27 Jan 2023 10:12:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C911BC433D2; Fri, 27 Jan 2023 10:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814339; bh=QeFp2NRj/Jr86u5lj0vaSnMtviZbvXfKG9iNV2OAJ5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYxUd3H6oe1OrQM66RTLPYQcLEvDt09Al4xunT00MVBbSV54Zqn/eM/cakkWEO2jF hcmDwi9tS/zwP/5KgmN193pyIQaKb/MywZ+T+m6k+fm9sXzYubsX/pB8wLJY1kVT7j sPWpLOL1r83is6172Gg1/rZ3xAmH55UwsvVrFyK7g+d3VttLtcP4CvIMlKNY7spnqk 6zVoZbV5MyYjaga/OQtLQdeM2modd4x4QSwO7zahjlCH9KZ+e1EX4UHBgI70gZJpsN 81OgpvbHW+nq1xO5Miy4sPA46z6lX3yd65TcWKOqZCb9fztNkIowQYZ8x/4vxVV+X4 grLSloFeDYy5A== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] gpiolib: remove legacy gpio_export Date: Fri, 27 Jan 2023 11:11:47 +0100 Message-Id: <20230127101149.3475929-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170444839707444?= X-GMAIL-MSGID: =?utf-8?q?1756170444839707444?= 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. Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann Reviewed-by: Linus Walleij --- Documentation/admin-guide/gpio/sysfs.rst | 2 +- Documentation/driver-api/gpio/legacy.rst | 21 --------------- .../zh_CN/driver-api/gpio/legacy.rst | 19 ------------- Documentation/translations/zh_TW/gpio.txt | 18 ------------- arch/arm/mach-omap2/pdata-quirks.c | 9 ++++--- arch/sh/boards/mach-ap325rxa/setup.c | 7 ++--- drivers/gpio/gpiolib-sysfs.c | 4 +-- drivers/media/pci/sta2x11/sta2x11_vip.c | 10 ++++--- drivers/net/ieee802154/ca8210.c | 3 ++- include/linux/gpio.h | 27 ------------------- 10 files changed, 21 insertions(+), 99 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 e0306e78e34b..78372853c6d4 100644 --- a/Documentation/driver-api/gpio/legacy.rst +++ b/Documentation/driver-api/gpio/legacy.rst @@ -714,27 +714,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(); - -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. - - API Reference ============= diff --git a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst index dee2a0517c1c..84ce2322fdba 100644 --- a/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst +++ b/Documentation/translations/zh_CN/driver-api/gpio/legacy.rst @@ -653,25 +653,6 @@ GPIO 控制器的路径类似 /sys/class/gpio/gpiochip42/ (对于从#42 GPIO 确定给定信号所用的 GPIO 编号。 -从内核代码中导出 ----------------- - -内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出:: - - /* 导出 GPIO 到用户空间 */ - int gpio_export(unsigned gpio, bool direction_may_change); - - /* gpio_export()的逆操作 */ - void gpio_unexport(); - -在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs -接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间 -破坏重要的系统状态。 - -这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口, -与文档配合作为板级支持包的一部分。 - - API参考 ======= diff --git a/Documentation/translations/zh_TW/gpio.txt b/Documentation/translations/zh_TW/gpio.txt index dc608358d90a..62e560ffe628 100644 --- a/Documentation/translations/zh_TW/gpio.txt +++ b/Documentation/translations/zh_TW/gpio.txt @@ -614,21 +614,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(); - -在一個內核驅動申請一個 GPIO 之後,它可以通過 gpio_export()使其在 sysfs -接口中可見。該驅動可以控制信號方向是否可修改。這有助於防止用戶空間代碼無意間 -破壞重要的系統狀態。 - -這個明確的導出有助於(通過使某些實驗更容易來)調試,也可以提供一個始終存在的接口, -與文檔配合作爲板級支持包的一部分。 diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c index 248478af5bfa..ee90fb42c955 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 @@ -108,7 +109,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; } @@ -123,7 +124,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); @@ -200,8 +201,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 6e66ac194f7d..48055991152c 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 cd27bf173dec..6e4267944f80 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -491,7 +491,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; @@ -790,7 +790,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/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 8535e49a4c4f..e4cf9d63e926 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 @@ -889,6 +890,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)) @@ -900,7 +902,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); @@ -908,7 +910,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); @@ -928,8 +930,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/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index e1a569b99e4a..5c0be6a3ec5e 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -2853,7 +2854,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 220e8656f2ab..a1271526e489 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -132,20 +132,6 @@ 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) -{ - gpiod_unexport(gpio_to_desc(gpio)); -} - /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ struct device; @@ -243,19 +229,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 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 Fri Jan 27 10:11:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755613wrn; Fri, 27 Jan 2023 02:18:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXtHZQ+KeXoPk/xxav3z00C0sKdPQ2CSOG1wkjOko4jSNk7vUnelgGnAFfzH/q+9v8E9ExFF X-Received: by 2002:a05:6a20:12d1:b0:b8:36a7:c5c5 with SMTP id v17-20020a056a2012d100b000b836a7c5c5mr50154608pzg.27.1674814711301; Fri, 27 Jan 2023 02:18:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814711; cv=none; d=google.com; s=arc-20160816; b=rnxpbSJ9cYrthIiionU4FPXNG4ZS4X+Lr05+//wbMBgT0REpM1B1iDRjf4RwkF9yhC QiiXcifG2F/2AUT5IRkQ/yM14Kp034HZxHlfoT8qfjeg19Lka/yKz56+HPeqtU8/duek FobCPu6J1wLPSRbrt/apgkg6Fy7ZqnDc/mWuBLiXHmGtKs4ZeafkbkvmpJvDgXde6Ygh XaYQyqZsiTkkvh9k6kGq7xXewzmjZrHW+o/2m6xpiltiJdTwjsLa/ycXtHYFXgBJCW1Y OCdBa5C6YwMrOC3cuHhHf1CmGmwYop9pESYUNVYUYuHI3Lr12zqVyUJoob4qoU/HZ8b3 +qaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=69obudiH0bTfAkqeZ2wOyxII8K2ncxe0hL/9tUtY3jk=; b=MXM2Y163Wly6L9bHOsbqyWZk5TntymT4xwy71GWheI8S6/C8CE5RecK3/1/Ud5LagO JOyMVtz39zy4F3xJW6ElwnN7anv9ejqdZ0By3ghK/Cp5MBjNKLzP6uyYTO6cqg3X5qYx Zfyqsm9HNNJ5r9LRDzea37yf7ROx4ePMj5+2e1U+V8qIhF1tMMDYaz3iqG32Ov1ZQgqc fqE88MKZqRb03KlNQlZBwhGgEY8SU8Sh6ciNej1RGq7SUhAe4Igi3WVzK4b1e0qTjEna BoOMNVkLYxUTM8GvA8iXHA8IR5pcKRFTFC0itJDLtV5n47QvU3KG9RWyeqSLzfxrT5d1 ziag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SNGCJlRq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z124-20020a633382000000b004daa13455ddsi3866342pgz.331.2023.01.27.02.18.18; Fri, 27 Jan 2023 02:18:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SNGCJlRq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233421AbjA0KMt (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233003AbjA0KMi (ORCPT ); Fri, 27 Jan 2023 05:12:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6DDA820D2; Fri, 27 Jan 2023 02:12:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36E0AB82008; Fri, 27 Jan 2023 10:12:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C5F5C4339B; Fri, 27 Jan 2023 10:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814341; bh=eaEqmjlD+Lv/FVOK9egayQf0KJ7RibJrGH3i8y4yudc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNGCJlRq+ynRHKaOuBfF4/yY0L/R36vtOqjmstVT0l/K+lm5+iZY9cmfPQrMyJl9i 2ZV+5qygFmwVphR8s3g/1Ko1Rr6ObqTignm4hKlXt3e5XKNvtpJzvTHyIaWPccZjHD h+SrOdmdgN7ujqOf3o0kRigcoOVM23zx65ZMBT+PgF6M7whCG9iuzsSCk2dTm4bgc7 rZ9hrXR72Pe2MznQDlidRwvv30Jwr+bkOXNAsyZlWtvrJ/f3dpaywNPz89vlqtz9q3 HTxuaPbB9gozwcOBDWQ0kklc0KXsMCkfN4I7+mab2oHpAP2l9SAS+rpYGKWCy+mGZn RqYJjvZmsAKpQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] gpiolib: split linux/gpio/driver.h out of linux/gpio.h Date: Fri, 27 Jan 2023 11:11:48 +0100 Message-Id: <20230127101149.3475929-7-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170510454493025?= X-GMAIL-MSGID: =?utf-8?q?1756170510454493025?= 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 --- 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 c20163e6a8b4..bfd97f1b6288 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 04f8a1680bc1..0c32b08a3a9c 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 9aed2797d3d5..3ebd7aa9227c 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 Fri Jan 27 10:11:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 49155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp755407wrn; Fri, 27 Jan 2023 02:17:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvWV8XxrvVsgIiMTNdxSJAersQvugEK6bltglBBBb3+BI8GspL3LMUBu0CPWhrC0IFZWxdu X-Received: by 2002:a05:6a20:4c1a:b0:a3:960e:7d0a with SMTP id fm26-20020a056a204c1a00b000a3960e7d0amr36939562pzb.58.1674814676527; Fri, 27 Jan 2023 02:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674814676; cv=none; d=google.com; s=arc-20160816; b=vUM3SwxxweYtU9+kl2dXU87Rsj7Pr8ponUsdQFWcohZya2TnOv/mWrGBafLV/o8IvX 6mZNhOK/oZ3MjU8gG5YoNdkFBxJIyNWns+Hfa9P4iWlaRjtrdWaKfh1grYAAJBKNoIi3 9vmODOj0ITcRpCQrr9mCPvM+PS7cxMUawzSFRvTlB64fQ9FzkMtHJZVhVhhjyy/7CZO1 QrSTuGdNoQm4OkbOESZX+OZVu5Xd0Upjjv9mEjDJrSQ7/tbC5RtGHFesHj9Hm0QN37JX rModwPoYJe1abaOPuFf67RZweW/7uQm3cZOh/VA/fwb655uG+u6sLXYWessbI11Y3Gbh BQJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M0xV6p7aUCkiYJHm3MC3nrTOegJoGuks+PoDKUe3wp4=; b=YlB3odjuasNpfMA9UVvT9CfAMslgvoGQAht1pWDHe+q2xKZIk3DRCeNUMSbYThXWjd luEunaM9+d0eQWj7WolAslrUxMI6gJQyFPBwDqfZfhwZyRuxcXWg+WmoNzl6Meb9Gnfy cFqImhkWD3OlcVAHniDoQh4z/JTVggIZwaY9A9ptk8wJ2GL8YS9yWTSuI2uKSE51XXLJ VsVQHoU01d+t/gie3HdBf3AaJN3WSIGCD473yzGakKQBjS7Ty/INy7PvfoX3dEvlDEFy 4uyddfDYIv+Z5Unxau3u/mTYf9fDFiGgT54hJ/AY/l1B1tldYj0uKtGcLRL3MTlK+x/W TepQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n0cOIZwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u185-20020a6385c2000000b004da814c8bbfsi4077178pgd.860.2023.01.27.02.17.19; Fri, 27 Jan 2023 02:17:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n0cOIZwl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233465AbjA0KMv (ORCPT + 99 others); Fri, 27 Jan 2023 05:12:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233446AbjA0KMk (ORCPT ); Fri, 27 Jan 2023 05:12:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A3674F361; Fri, 27 Jan 2023 02:12:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C4CA561AC0; Fri, 27 Jan 2023 10:12:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62DD9C4339C; Fri, 27 Jan 2023 10:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674814344; bh=8+jL/pc/kEgjyYK2IPop8mBZAygoG33RDbv3MKqpv0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0cOIZwlonEzEPAo25k5B+KtWK15MvQWAv1uqVXO86s9V9sSX5ER4yESdrbcnBIYh lcBYDOXiRsK+lyz01yyj4RuT2MM0xpK8MZNpd+O8yNPE/0sqBMolc87XVDJX1kXUAu MefGnFYe9wWmPGW6u3ViaZhP2kuvAS4AnEyGZk7FB3whi6y1Z3cjvH4nksXctn+uuE ouGVCB0zfQ0j2FELkTtSXJ7+mFZnxH09gJ3Czs2Sl61xNl/dFq+qSb9AvRbd0uqzJ8 3uzmqNG6KhZkPnW7NPQLxAlGJ0nIjZ/asA+qlivEGkCKfBDOORAiyIibUgZSbVmCSD 59r+iE6Xu2ilQ== From: Arnd Bergmann To: linux-gpio@vger.kernel.org Cc: Arnd Bergmann , Andy Shevchenko , Bartosz Golaszewski , Christophe Leroy , Dmitry Torokhov , Linus Walleij , linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h Date: Fri, 27 Jan 2023 11:11:49 +0100 Message-Id: <20230127101149.3475929-8-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230127101149.3475929-1-arnd@kernel.org> References: <20230127101149.3475929-1-arnd@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756170474328309511?= X-GMAIL-MSGID: =?utf-8?q?1756170474328309511?= 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 --- 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 +- include/linux/gpio/legacy-of-mm-gpiochip.h | 36 ++++++++++++++++++++++ include/linux/of_gpio.h | 21 ------------- 15 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 include/linux/gpio/legacy-of-mm-gpiochip.h 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/gpio/legacy-of-mm-gpiochip.h b/include/linux/gpio/legacy-of-mm-gpiochip.h new file mode 100644 index 000000000000..2e2bd3b19cc3 --- /dev/null +++ b/include/linux/gpio/legacy-of-mm-gpiochip.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * 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_GPIO_LEGACY_OF_MM_GPIO_CHIP_H +#define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H + +#include +#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_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); + +#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