{"id":2229674,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229674/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260428154522.2861492-1-arnd@kernel.org/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.1/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260428154522.2861492-1-arnd@kernel.org>","date":"2026-04-28T15:45:07","name":"gpiolib: move legacy interface into linux/gpio/legacy.h","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"859e9099d2098c2eae29d415b812d007a9da3699","submitter":{"id":80402,"url":"http://patchwork.ozlabs.org/api/1.1/people/80402/?format=json","name":"Arnd Bergmann","email":"arnd@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260428154522.2861492-1-arnd@kernel.org/mbox/","series":[{"id":501880,"url":"http://patchwork.ozlabs.org/api/1.1/series/501880/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=501880","date":"2026-04-28T15:45:07","name":"gpiolib: move legacy interface into linux/gpio/legacy.h","version":1,"mbox":"http://patchwork.ozlabs.org/series/501880/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229674/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229674/checks/","tags":{},"headers":{"Return-Path":"\n <linux-gpio+bounces-35712-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=rwnq/MNQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-35712-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"rwnq/MNQ\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4lCY2wRgz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 01:46:17 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 17E943011BCB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 15:45:29 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 4AEA83BED23;\n\tTue, 28 Apr 2026 15:45:28 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E0B43A759E;\n\tTue, 28 Apr 2026 15:45:27 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 0C014C2BCAF;\n\tTue, 28 Apr 2026 15:45:25 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777391128; cv=none;\n b=o4ie4IjkVcraBbfrihnpE4twbKQ7KSsGglpWOUJT7VfTXlzNJtRT0ZluiYTR1/NFpqEe7sdbG+jrElJEbTss4BlAmwzTNkB8cVSFaFCFrq2ngpA6P4ZjNh+IK6i4qdQSZ+HriZHGlpszrTuNiAAyu3mfJbkM/SfpDOM4NMXGxHA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777391128; c=relaxed/simple;\n\tbh=hmPJ64Sd/SEqVAqAVmJmhdxdN1kRSfmYPQdUQLgLAW8=;\n\th=From:To:Cc:Subject:Date:Message-Id:MIME-Version;\n b=h6K4g3DEXWqmMNlXP/Hr5TrkEzfCWsC1DnmoJPifp8q/8YNX/rtRbcVffw/KH5B6m/M75mm/cFrBtBKTqS+NhdbFvCJ7elrl3gB0n6sIJwlsuN9CHsEFuXQkzj0m6LujsLGLTBR83I5MZlj8Pbln5eGv2lmEJO9Ap2rQEpG0rxA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=rwnq/MNQ; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777391127;\n\tbh=hmPJ64Sd/SEqVAqAVmJmhdxdN1kRSfmYPQdUQLgLAW8=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=rwnq/MNQ1EUUvbPYk8rnxL2v3zppQJV2y66Id+glSD3RZjd2EiwtoWftI6693rJCl\n\t szd9RvztimgtPjrBm66fL+PPogkRw9O14lLXem4OFlTBGBOdhfsbvz+crFzQr9I7pc\n\t ErjVNkl+zvCK3qdx9fbL7O5cZD4FRBiWW0vjOxMqyrW9Ro3Vud4v3b+p1DW5E3bdfW\n\t K3U6/5IMZAr9egzS6th64z3pzfBnHBUFrhm/mw0Tkmskvx88tDX/HYXRO/BjoRrqqY\n\t QFIxZH3isYC4egKEEaJ1RvD4cmwxCmJuDXN64dF24uYcoYPfHWGtwdH1t2FQbfRyDU\n\t nH93nrR3bGyUw==","From":"Arnd Bergmann <arnd@kernel.org>","To":"Linus Walleij <linusw@kernel.org>,\n\tBartosz Golaszewski <brgl@kernel.org>","Cc":"Arnd Bergmann <arnd@arndb.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tAlexander Sverdlin <alexander.sverdlin@gmail.com>,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-gpio@vger.kernel.org","Subject":"[PATCH] gpiolib: move legacy interface into linux/gpio/legacy.h","Date":"Tue, 28 Apr 2026 17:45:07 +0200","Message-Id":"<20260428154522.2861492-1-arnd@kernel.org>","X-Mailer":"git-send-email 2.39.5","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"From: Arnd Bergmann <arnd@arndb.de>\n\nSplit the old contents from gpio.h for clarity. Ideally any driver\nthat still includes linux/gpio.h can now be ported over to use\neither linux/gpio/legacy.h or linux/gpio/consumer.h, with the\noriginal file getting removed once that is complete.\n\nNo functional changes intended for now.\n\nSigned-off-by: Arnd Bergmann <arnd@arndb.de>\n---\n include/linux/gpio.h        | 161 +--------------------------------\n include/linux/gpio/legacy.h | 172 ++++++++++++++++++++++++++++++++++++\n 2 files changed, 175 insertions(+), 158 deletions(-)\n create mode 100644 include/linux/gpio/legacy.h","diff":"diff --git a/include/linux/gpio.h b/include/linux/gpio.h\nindex 8f85ddb26429..149cf580d20b 100644\n--- a/include/linux/gpio.h\n+++ b/include/linux/gpio.h\n@@ -2,12 +2,9 @@\n /*\n  * NOTE: This header *must not* be included.\n  *\n- * This is the LEGACY GPIO bulk include file, including legacy APIs. It is\n- * used for GPIO drivers still referencing the global GPIO numberspace,\n- * and should not be included in new code.\n- *\n  * If you're implementing a GPIO driver, only include <linux/gpio/driver.h>\n  * If you're implementing a GPIO consumer, only include <linux/gpio/consumer.h>\n+ * If you're using the legacy interfaces, include <linux/gpio/legacy.h>\n  */\n #ifndef __LINUX_GPIO_H\n #define __LINUX_GPIO_H\n@@ -18,159 +15,7 @@\n #endif\n \n #ifdef CONFIG_GPIOLIB_LEGACY\n-\n-struct device;\n-\n-/* make these flag values available regardless of GPIO kconfig options */\n-#define GPIOF_IN\t\t((1 << 0))\n-#define GPIOF_OUT_INIT_LOW\t((0 << 0) | (0 << 1))\n-#define GPIOF_OUT_INIT_HIGH\t((0 << 0) | (1 << 1))\n-\n-#ifdef CONFIG_GPIOLIB\n-/*\n- * \"valid\" GPIO numbers are nonnegative and may be passed to\n- * setup routines like gpio_request().  Only some valid numbers\n- * can successfully be requested and used.\n- *\n- * Invalid GPIO numbers are useful for indicating no-such-GPIO in\n- * platform data and other tables.\n- */\n-static inline bool gpio_is_valid(int number)\n-{\n-\t/* only non-negative numbers are valid */\n-\treturn number >= 0;\n-}\n-\n-/*\n- * Platforms may implement their GPIO interface with library code,\n- * at a small performance cost for non-inlined operations and some\n- * extra memory (for code and for per-GPIO table entries).\n- */\n-\n-/* Always use the library code for GPIO management calls,\n- * or when sleeping may be involved.\n- */\n-int gpio_request(unsigned gpio, const char *label);\n-void gpio_free(unsigned gpio);\n-\n-static inline int gpio_direction_input(unsigned gpio)\n-{\n-\treturn gpiod_direction_input(gpio_to_desc(gpio));\n-}\n-static inline int gpio_direction_output(unsigned gpio, int value)\n-{\n-\treturn gpiod_direction_output_raw(gpio_to_desc(gpio), value);\n-}\n-\n-static inline int gpio_get_value_cansleep(unsigned gpio)\n-{\n-\treturn gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));\n-}\n-static inline void gpio_set_value_cansleep(unsigned gpio, int value)\n-{\n-\tgpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);\n-}\n-\n-static inline int gpio_get_value(unsigned gpio)\n-{\n-\treturn gpiod_get_raw_value(gpio_to_desc(gpio));\n-}\n-static inline void gpio_set_value(unsigned gpio, int value)\n-{\n-\tgpiod_set_raw_value(gpio_to_desc(gpio), value);\n-}\n-\n-static inline int gpio_to_irq(unsigned gpio)\n-{\n-\treturn gpiod_to_irq(gpio_to_desc(gpio));\n-}\n-\n-int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);\n-\n-int devm_gpio_request_one(struct device *dev, unsigned gpio,\n-\t\t\t  unsigned long flags, const char *label);\n-\n-#else /* ! CONFIG_GPIOLIB */\n-\n-#include <linux/kernel.h>\n-\n-#include <asm/bug.h>\n-#include <asm/errno.h>\n-\n-static inline bool gpio_is_valid(int number)\n-{\n-\treturn false;\n-}\n-\n-static inline int gpio_request(unsigned gpio, const char *label)\n-{\n-\treturn -ENOSYS;\n-}\n-\n-static inline int gpio_request_one(unsigned gpio,\n-\t\t\t\t\tunsigned long flags, const char *label)\n-{\n-\treturn -ENOSYS;\n-}\n-\n-static inline void gpio_free(unsigned gpio)\n-{\n-\tmight_sleep();\n-\n-\t/* GPIO can never have been requested */\n-\tWARN_ON(1);\n-}\n-\n-static inline int gpio_direction_input(unsigned gpio)\n-{\n-\treturn -ENOSYS;\n-}\n-\n-static inline int gpio_direction_output(unsigned gpio, int value)\n-{\n-\treturn -ENOSYS;\n-}\n-\n-static inline int gpio_get_value(unsigned gpio)\n-{\n-\t/* GPIO can never have been requested or set as {in,out}put */\n-\tWARN_ON(1);\n-\treturn 0;\n-}\n-\n-static inline void gpio_set_value(unsigned gpio, int value)\n-{\n-\t/* GPIO can never have been requested or set as output */\n-\tWARN_ON(1);\n-}\n-\n-static inline int gpio_get_value_cansleep(unsigned gpio)\n-{\n-\t/* GPIO can never have been requested or set as {in,out}put */\n-\tWARN_ON(1);\n-\treturn 0;\n-}\n-\n-static inline void gpio_set_value_cansleep(unsigned gpio, int value)\n-{\n-\t/* GPIO can never have been requested or set as output */\n-\tWARN_ON(1);\n-}\n-\n-static inline int gpio_to_irq(unsigned gpio)\n-{\n-\t/* GPIO can never have been requested or set as input */\n-\tWARN_ON(1);\n-\treturn -EINVAL;\n-}\n-\n-static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,\n-\t\t\t\t\tunsigned long flags, const char *label)\n-{\n-\tWARN_ON(1);\n-\treturn -EINVAL;\n-}\n-\n-#endif /* ! CONFIG_GPIOLIB */\n+#include <linux/gpio/legacy.h>\n #endif /* CONFIG_GPIOLIB_LEGACY */\n+\n #endif /* __LINUX_GPIO_H */\ndiff --git a/include/linux/gpio/legacy.h b/include/linux/gpio/legacy.h\nnew file mode 100644\nindex 000000000000..da7308a69e8b\n--- /dev/null\n+++ b/include/linux/gpio/legacy.h\n@@ -0,0 +1,172 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/*\n+ * This is the LEGACY GPIO include file, used only for legacy APIs.\n+ *\n+ * No new code should use this, but instead use the linux/gpio/consumer.h\n+ * interfaces directly.\n+ */\n+#ifndef __LINUX_GPIO_LEGACY_H\n+#define __LINUX_GPIO_LEGACY_H\n+\n+#include <linux/types.h>\n+\n+#ifdef CONFIG_GPIOLIB_LEGACY\n+\n+struct device;\n+\n+/* make these flag values available regardless of GPIO kconfig options */\n+#define GPIOF_IN\t\t((1 << 0))\n+#define GPIOF_OUT_INIT_LOW\t((0 << 0) | (0 << 1))\n+#define GPIOF_OUT_INIT_HIGH\t((0 << 0) | (1 << 1))\n+\n+#ifdef CONFIG_GPIOLIB\n+\n+#include <linux/gpio/consumer.h>\n+\n+/*\n+ * \"valid\" GPIO numbers are nonnegative and may be passed to\n+ * setup routines like gpio_request().  Only some valid numbers\n+ * can successfully be requested and used.\n+ *\n+ * Invalid GPIO numbers are useful for indicating no-such-GPIO in\n+ * platform data and other tables.\n+ */\n+static inline bool gpio_is_valid(int number)\n+{\n+\t/* only non-negative numbers are valid */\n+\treturn number >= 0;\n+}\n+\n+/*\n+ * Platforms may implement their GPIO interface with library code,\n+ * at a small performance cost for non-inlined operations and some\n+ * extra memory (for code and for per-GPIO table entries).\n+ */\n+\n+/* Always use the library code for GPIO management calls,\n+ * or when sleeping may be involved.\n+ */\n+int gpio_request(unsigned gpio, const char *label);\n+void gpio_free(unsigned gpio);\n+\n+static inline int gpio_direction_input(unsigned gpio)\n+{\n+\treturn gpiod_direction_input(gpio_to_desc(gpio));\n+}\n+static inline int gpio_direction_output(unsigned gpio, int value)\n+{\n+\treturn gpiod_direction_output_raw(gpio_to_desc(gpio), value);\n+}\n+\n+static inline int gpio_get_value_cansleep(unsigned gpio)\n+{\n+\treturn gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));\n+}\n+static inline void gpio_set_value_cansleep(unsigned gpio, int value)\n+{\n+\tgpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);\n+}\n+\n+static inline int gpio_get_value(unsigned gpio)\n+{\n+\treturn gpiod_get_raw_value(gpio_to_desc(gpio));\n+}\n+static inline void gpio_set_value(unsigned gpio, int value)\n+{\n+\tgpiod_set_raw_value(gpio_to_desc(gpio), value);\n+}\n+\n+static inline int gpio_to_irq(unsigned gpio)\n+{\n+\treturn gpiod_to_irq(gpio_to_desc(gpio));\n+}\n+\n+int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);\n+\n+int devm_gpio_request_one(struct device *dev, unsigned gpio,\n+\t\t\t  unsigned long flags, const char *label);\n+\n+#else /* ! CONFIG_GPIOLIB */\n+\n+#include <linux/kernel.h>\n+\n+#include <asm/bug.h>\n+#include <asm/errno.h>\n+\n+static inline bool gpio_is_valid(int number)\n+{\n+\treturn false;\n+}\n+\n+static inline int gpio_request(unsigned gpio, const char *label)\n+{\n+\treturn -ENOSYS;\n+}\n+\n+static inline int gpio_request_one(unsigned gpio,\n+\t\t\t\t\tunsigned long flags, const char *label)\n+{\n+\treturn -ENOSYS;\n+}\n+\n+static inline void gpio_free(unsigned gpio)\n+{\n+\tmight_sleep();\n+\n+\t/* GPIO can never have been requested */\n+\tWARN_ON(1);\n+}\n+\n+static inline int gpio_direction_input(unsigned gpio)\n+{\n+\treturn -ENOSYS;\n+}\n+\n+static inline int gpio_direction_output(unsigned gpio, int value)\n+{\n+\treturn -ENOSYS;\n+}\n+\n+static inline int gpio_get_value(unsigned gpio)\n+{\n+\t/* GPIO can never have been requested or set as {in,out}put */\n+\tWARN_ON(1);\n+\treturn 0;\n+}\n+\n+static inline void gpio_set_value(unsigned gpio, int value)\n+{\n+\t/* GPIO can never have been requested or set as output */\n+\tWARN_ON(1);\n+}\n+\n+static inline int gpio_get_value_cansleep(unsigned gpio)\n+{\n+\t/* GPIO can never have been requested or set as {in,out}put */\n+\tWARN_ON(1);\n+\treturn 0;\n+}\n+\n+static inline void gpio_set_value_cansleep(unsigned gpio, int value)\n+{\n+\t/* GPIO can never have been requested or set as output */\n+\tWARN_ON(1);\n+}\n+\n+static inline int gpio_to_irq(unsigned gpio)\n+{\n+\t/* GPIO can never have been requested or set as input */\n+\tWARN_ON(1);\n+\treturn -EINVAL;\n+}\n+\n+static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,\n+\t\t\t\t\tunsigned long flags, const char *label)\n+{\n+\tWARN_ON(1);\n+\treturn -EINVAL;\n+}\n+\n+#endif /* ! CONFIG_GPIOLIB */\n+#endif /* CONFIG_GPIOLIB_LEGACY */\n+#endif /* __LINUX_GPIO_LEGAGY_H */\n","prefixes":[]}