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;