From patchwork Thu Jan 26 13:27:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 48646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp273128wrn; Thu, 26 Jan 2023 05:37:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtrK3C7u4RVotj934jLha9btmDFt6me45u4/RZ9L7wJGvhnUhmC6tlj+Z+T0AZdPqGpVc2b X-Received: by 2002:a17:906:6843:b0:86c:a3ed:1442 with SMTP id a3-20020a170906684300b0086ca3ed1442mr38325209ejs.4.1674740246433; Thu, 26 Jan 2023 05:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674740246; cv=none; d=google.com; s=arc-20160816; b=fVye8yyjV1CmNOCmd9KZM3Tb/DDawL3cq8Q9Cg3NlReG7oXB9NXEdP+BW6S59fVAr/ LNrmwsSKrX0XjCQ/R6ACcPtlztydsbiwjYXSYhaUUg1mscdAWbVmwd3YW9/Bpjw0njzo 1l1qAano0DED3L/kafQx7oYaik+bRgErVI7jjW4lvyCu2ZNfgQljuDWx4YA9RLtaCCf/ Er0o/ftCk4z+0mrPdK4jHhdbrPRxbqq4c9+2C8pUL/R3fug4xZo4nZxEyAfExzoDhlPg axCTcpaq+7z/73PJQulW/Bj0l2SsPyAvqdwnDQnMTuY3AxrhxBszZo1SFhKjTK8/wPrn pOOA== 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=PnhG5RzcD63yqHxUfqnVEhvZ9XELPYVyj393rflm3cw=; b=Sq16Zbx6o0qNck0091Qk5aCmx/tceAgQB5j7qp/QDRdkWHK/BrHGhd++fXNbGQX871 c4kVp4CQAnHR2+4lDS/Nrz7NL5YinmaaPViGkkhZ2DxoyQ5CpCAcTK0qs3UAv48k+COc fecTn6d5HLt5yY89GMS0kPz4XYWH6tvUtbur0vvWKlBAAVcrEVarpYeW58jNdSQPiUdh a9nFwy1cFNVZfrT+Y6qqUNNyYWtZwBrefz5eCgE7qzgEhCzD5SabmExiYDws5ayJWXWx rJkTOjiQYfoDUrsbWv6kuH91F11GYckEgdvTCM2fLCdBKfXjs3Ox8FBMPaw1dSx04LEA qwJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EuFeV5AH; 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 d22-20020a17090692d600b0087863e88674si1240067ejx.979.2023.01.26.05.37.02; Thu, 26 Jan 2023 05:37:26 -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=EuFeV5AH; 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 S236879AbjAZN2l (ORCPT + 99 others); Thu, 26 Jan 2023 08:28:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236668AbjAZN2h (ORCPT ); Thu, 26 Jan 2023 08:28:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CEA7282; Thu, 26 Jan 2023 05:28:16 -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 95FFDB81D98; Thu, 26 Jan 2023 13:28:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41CB0C433D2; Thu, 26 Jan 2023 13:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674739693; bh=aS6kylYmn924ux3OlisnQEqp3LCBWw+fYnrGBZdDFrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EuFeV5AHTIK6Z2L9ygsgp22bb1tWwKzkJNvx06VKrQIk02SWdiUIMsyH5HdbIaCjN deNsVlnrd9iw0MuxY9gzFssXEUYyyyIc1ZksZgmHAWEF4Ha4Sn2tMc0FNhgVmvrG6L B2VZ7mKHGl4RZDZ64dkkPHvdu/dGcRtbstfn3cKb0tla0pHA+424f6ZnyGqsjyDZxj 3Oz9cVzBNniGZpGJvXq4D74XItYC8W1Q3F9Hx1KdcPOdlvlM/HMIv0LQTGlVx/A/YU 70d7DfcRrclL09kVkXvFew6LIVSy/sn2koEavdN213NVYB7H+WLQHOksMJRHXo+Kmt 1N0P2+KQm0TJw== 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 Subject: [PATCH 2/8] gpiolib: coldfire: remove custom asm/gpio.h Date: Thu, 26 Jan 2023 14:27:55 +0100 Message-Id: <20230126132801.2042371-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230126132801.2042371-1-arnd@kernel.org> References: <20230126132801.2042371-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?1756092428443736483?= X-GMAIL-MSGID: =?utf-8?q?1756092428443736483?= From: Arnd Bergmann Now that coldfire is the only user of a custom asm/gpio.h, it seems better to remove this as well, and have the same interface everywhere. For the gpio_get_value()/gpio_set_value()/gpio_to_irq(), gpio_cansleep() functions, the custom version is only a micro-optimization to inline the function for constant GPIO numbers. However, in the coldfire defconfigs, I was unable to find a single instance where this micro-optimization was even used, and according to Geert the only user appears to be the QSPI chip that is disabled everywhere. The custom gpio_request_one() function is even less useful, as it is guarded by an #ifdef that is never true. Reviewed-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann Acked-by: Bartosz Golaszewski 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;