{"id":2230972,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230972/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260430091202.2724109-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":"<20260430091202.2724109-1-arnd@kernel.org>","date":"2026-04-30T09:11:55","name":"[v2] leds: gpio: make legacy gpiolib interface optional","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"972f602471a20b275f373c0d46eac371990e9d1a","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/20260430091202.2724109-1-arnd@kernel.org/mbox/","series":[{"id":502247,"url":"http://patchwork.ozlabs.org/api/1.1/series/502247/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=502247","date":"2026-04-30T09:11:55","name":"[v2] leds: gpio: make legacy gpiolib interface optional","version":2,"mbox":"http://patchwork.ozlabs.org/series/502247/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230972/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2230972/checks/","tags":{},"headers":{"Return-Path":"\n <linux-gpio+bounces-35845-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=gJDqP5Ez;\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-35845-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=\"gJDqP5Ez\"","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 4g5pPK75MZz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 19:13:25 +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 D70D330103A4\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 09:12:14 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1FACC36C0CE;\n\tThu, 30 Apr 2026 09:12:14 +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 D76212BDC0F;\n\tThu, 30 Apr 2026 09:12:13 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 66B61C2BCB3;\n\tThu, 30 Apr 2026 09:12:11 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777540333; cv=none;\n b=EjOVPy25nFoieJIuIBC6dV4YMxdemeRgD+ILUZtnctHk+3mYnFWdNRGsnfBJ3/v/fgp9utUBJjgAsDqvUXtuwQl4sDj1qMwdA9ez1m+jCHHetVNuhQAnyJSWhPjfHMlYbTuLjclmM3h3TZjTTaLQv2oWs69p8W4OYpxNLIZss6E=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777540333; c=relaxed/simple;\n\tbh=k+ehhy6UXY0hbs75jHbwfvPYhqslla8Px/d6pa3bdxE=;\n\th=From:To:Cc:Subject:Date:Message-Id:MIME-Version;\n b=JE+9shGNARaf8Y9zuqLJ1w1md5iJ+uzGsKl9rvpMbfdcRQ/7FVcpvITS5i8jjGtFBT+wsRHGI4GWE/DcxlUsRS6qw40G4SzwDnwCDLlJfIXsfX0zUjcnTUH8Ttg1AnvVWMagL6vVEPifg/DpTHG2dneBHqZQG6uDfzAtswv7cqw=","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=gJDqP5Ez; 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=1777540333;\n\tbh=k+ehhy6UXY0hbs75jHbwfvPYhqslla8Px/d6pa3bdxE=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=gJDqP5Ezoc0GNmExXGQN5KiaOvcmKeUpwQA+MP5aEoMyUaYlbiFuevaEWAAY+Ymdj\n\t yDxweZ5UrZM9idNRoATJigU8PImOTf011wWwlD+lEA5rSg1hgYhFhrzyFQ6ML5KFpV\n\t HwyGgIWcgDMJCR9OX724tW/o2qgyzenXgT7pjb30EkmTRY7r3L/Ik3E0V6fUzfU2HZ\n\t tA4kAqLQwF8YhErcIwhp5Gp3KxSkGSd9XnWqyrDBDDqTHAxEsoiI08oVnDrHICHMUP\n\t GKAWMYICCu/FPBX+B6QhyLct+688mjmoE2PefkQggA6Fsz0u5DshfKeL2KAyqmW07g\n\t Byc6S9MjgJ2KA==","From":"Arnd Bergmann <arnd@kernel.org>","To":"Lee Jones <lee@kernel.org>,\n\tPavel Machek <pavel@kernel.org>,\n\tLinus Walleij <linusw@kernel.org>,\n\tBartosz Golaszewski <brgl@kernel.org>","Cc":"Dmitry Torokhov <dmitry.torokhov@gmail.com>,\n\tArnd Bergmann <arnd@arndb.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tlinux-leds@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-gpio@vger.kernel.org","Subject":"[PATCH] [v2] leds: gpio: make legacy gpiolib interface optional","Date":"Thu, 30 Apr 2026 11:11:55 +0200","Message-Id":"<20260430091202.2724109-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\nThere are still a handful of ancient mips/armv5/sh boards that use the\ngpio_led:gpio member to pass an old-style gpio number, but all modern\nusers have been converted to gpio descriptors.\n\nWhile the CONFIG_GPIOLIB_LEGACY option that guards devm_gpio_request_one()\nand related helpers is currently turned on in all kernel builds,\nthe plan is to only enable it on the few platforms that actually\npass gpio numbers in any platform_data.\n\nSplit out the legacy portion of the platform_data handling into a custom\nhelper function that is guarded with in #ifdef block, to allow the\nthe leds-gpio driver to compile cleanly when CONFIG_GPIOLIB_LEGACY\ngets turned off. Once the last user is converted, this function can\nbe removed.\n\nLink: https://lore.kernel.org/all/e9252384-a55c-4a91-9c61-06e05a0b2ce4@app.fastmail.com/\nSigned-off-by: Arnd Bergmann <arnd@arndb.de>\n---\nv2: rework a little bit to keep the legacy code path more separate,\n    extend changelog description\n\nRelated to this, we may also want to remove support for passing\na gpio descriptor in the ->gpiod flag. The only user doing this\nat the moment was introduced in commit 1892e87a3e91 (\"powerpc/warp:\nswitch to using gpiod API\").\n\nLinus Walleij previously gave a Reviewed-by tag, but I dropped\nit again during the rework.\n---\n drivers/leds/leds-gpio.c | 48 +++++++++++++++++++++++++++++-----------\n include/linux/leds.h     |  2 ++\n 2 files changed, 37 insertions(+), 13 deletions(-)","diff":"diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c\nindex 961acc18d0ac..788d9ef7720a 100644\n--- a/drivers/leds/leds-gpio.c\n+++ b/drivers/leds/leds-gpio.c\n@@ -212,7 +212,6 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,\n \t\t\t\t\t    const struct gpio_led *template)\n {\n \tstruct gpio_desc *gpiod;\n-\tint ret;\n \n \t/*\n \t * This means the LED does not come from the device tree\n@@ -228,11 +227,27 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,\n \t\treturn gpiod;\n \t}\n \n-\t/*\n-\t * This is the legacy code path for platform code that\n-\t * still uses GPIO numbers. Ultimately we would like to get\n-\t * rid of this block completely.\n-\t */\n+\treturn gpiod;\n+}\n+\n+#ifdef CONFIG_GPIOLIB_LEGACY\n+/*\n+ * This is the legacy code path for platform code that still uses\n+ * GPIO numbers, mainly MIPS and SuperH board files.\n+ * Ultimately we would like to get rid of this block completely.\n+ *\n+ * ppc44x-warp sets the template->gpiod directly instead of\n+ * adding a lookup table or device properties. This is not\n+ * much better.\n+ */\n+static struct gpio_desc *gpio_led_get_legacy_gpiod(struct device *dev, int idx,\n+\t\t\t\t\t\t   const struct gpio_led *template)\n+{\n+\tstruct gpio_desc *gpiod;\n+\tint ret;\n+\n+\tif (template->gpiod)\n+\t\treturn template->gpiod;\n \n \t/* skip leds that aren't available */\n \tif (!gpio_is_valid(template->gpio))\n@@ -252,6 +267,13 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,\n \n \treturn gpiod;\n }\n+#else\n+static struct gpio_desc *gpio_led_get_legacy_gpiod(struct device *dev, int idx,\n+\t\t\t\t\t\t   const struct gpio_led *template)\n+{\n+\treturn template->gpiod;\n+}\n+#endif\n \n static int gpio_led_probe(struct platform_device *pdev)\n {\n@@ -270,14 +292,14 @@ static int gpio_led_probe(struct platform_device *pdev)\n \t\t\tconst struct gpio_led *template = &pdata->leds[i];\n \t\t\tstruct gpio_led_data *led_dat = &priv->leds[i];\n \n-\t\t\tif (template->gpiod)\n-\t\t\t\tled_dat->gpiod = template->gpiod;\n-\t\t\telse\n-\t\t\t\tled_dat->gpiod =\n-\t\t\t\t\tgpio_led_get_gpiod(dev, i, template);\n+\t\t\tled_dat->gpiod = gpio_led_get_gpiod(dev, i, template);\n+\t\t\tif (!led_dat->gpiod)\n+\t\t\t\tled_dat->gpiod = gpio_led_get_legacy_gpiod(dev,\n+\t\t\t\t\t\t\t\t  i, template);\n+\n \t\t\tif (IS_ERR(led_dat->gpiod)) {\n-\t\t\t\tdev_info(dev, \"Skipping unavailable LED gpio %d (%s)\\n\",\n-\t\t\t\t\t template->gpio, template->name);\n+\t\t\t\tdev_info(dev, \"Skipping unavailable LED gpio %s\\n\",\n+\t\t\t\t\t template->name);\n \t\t\t\tcontinue;\n \t\t\t}\n \ndiff --git a/include/linux/leds.h b/include/linux/leds.h\nindex b16b803cc1ac..e646bffcd8e7 100644\n--- a/include/linux/leds.h\n+++ b/include/linux/leds.h\n@@ -676,8 +676,10 @@ typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,\n struct gpio_led {\n \tconst char *name;\n \tconst char *default_trigger;\n+#ifdef CONFIG_GPIOLIB_LEGACY\n \tunsigned \tgpio;\n \tunsigned\tactive_low : 1;\n+#endif\n \tunsigned\tretain_state_suspended : 1;\n \tunsigned\tpanic_indicator : 1;\n \tunsigned\tdefault_state : 2;\n","prefixes":["v2"]}