Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: swnode: remove deprecated lookup mechanism
@ 2026-06-29 10:54 Bartosz Golaszewski
  2026-06-29 13:10 ` Andy Shevchenko
  2026-06-29 14:23 ` kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-06-29 10:54 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Andy Shevchenko
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski

GPIO software node lookup should rely exclusively on matching the
addresses of the referenced firmware nodes. Commit e5d527be7e69 ("gpio:
swnode: don't use the swnode's name as the key for GPIO lookup") tried to
enforce this but had to be reverted: it broke existing users who abused
the software node mechanism by creating "dummy" software nodes named
after the device they want to get GPIOs from, without ever attaching them
to the actual GPIO devices. Those users relied on GPIOLIB matching the
label of the GPIO controller against the name of the software node rather
than on a real firmware node link.

All such users have now been coverted to using attached software nodes
via the fwnode address lookup path and the kernel documentation has been
updated to recommend it as the correct approach. This allows us to remove
the old behavior.

This will allow us to leverage the upcoming support for fw_devlink for
software nodes in GPIO core.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/gpio/gpiolib-swnode.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/gpio/gpiolib-swnode.c b/drivers/gpio/gpiolib-swnode.c
index 8d9591aa9304d1eac931d1cb19597ae4b99c40a2..4aa3f3406caaf7e049aa1da153d790e65de3008c 100644
--- a/drivers/gpio/gpiolib-swnode.c
+++ b/drivers/gpio/gpiolib-swnode.c
@@ -41,27 +41,7 @@ static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
 		return ERR_PTR(-ENOENT);
 
 fwnode_lookup:
-	gdev = gpio_device_find_by_fwnode(fwnode);
-	if (!gdev && gdev_node && gdev_node->name)
-		/*
-		 * FIXME: We shouldn't need to compare the GPIO controller's
-		 * label against the software node that is supposedly attached
-		 * to it. However there are currently GPIO users that - knowing
-		 * the expected label of the GPIO chip whose pins they want to
-		 * control - set up dummy software nodes named after those GPIO
-		 * controllers, which aren't actually attached to them. In this
-		 * case gpio_device_find_by_fwnode() will fail as no device on
-		 * the GPIO bus is actually associated with the fwnode we're
-		 * looking for.
-		 *
-		 * As a fallback: continue checking the label if we have no
-		 * match. However, the situation described above is an abuse
-		 * of the software node API and should be phased out and the
-		 * following line - eventually removed.
-		 */
-		gdev = gpio_device_find_by_label(gdev_node->name);
-
-	return gdev ?: ERR_PTR(-EPROBE_DEFER);
+	return gpio_device_find_by_fwnode(fwnode) ?: ERR_PTR(-EPROBE_DEFER);
 }
 
 static int swnode_gpio_get_reference(const struct fwnode_handle *fwnode,

---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260625-gpio-swnode-drop-label-matching-a975ad5f0e40

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpio: swnode: remove deprecated lookup mechanism
  2026-06-29 10:54 [PATCH] gpio: swnode: remove deprecated lookup mechanism Bartosz Golaszewski
@ 2026-06-29 13:10 ` Andy Shevchenko
  2026-06-29 14:04   ` Bartosz Golaszewski
  2026-06-29 14:23 ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-06-29 13:10 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Andy Shevchenko, linux-gpio, linux-kernel

On Mon, Jun 29, 2026 at 12:54:58PM +0200, Bartosz Golaszewski wrote:
> GPIO software node lookup should rely exclusively on matching the
> addresses of the referenced firmware nodes. Commit e5d527be7e69 ("gpio:
> swnode: don't use the swnode's name as the key for GPIO lookup") tried to
> enforce this but had to be reverted: it broke existing users who abused
> the software node mechanism by creating "dummy" software nodes named
> after the device they want to get GPIOs from, without ever attaching them
> to the actual GPIO devices. Those users relied on GPIOLIB matching the
> label of the GPIO controller against the name of the software node rather
> than on a real firmware node link.
> 
> All such users have now been coverted to using attached software nodes
> via the fwnode address lookup path and the kernel documentation has been
> updated to recommend it as the correct approach. This allows us to remove
> the old behavior.
> 
> This will allow us to leverage the upcoming support for fw_devlink for
> software nodes in GPIO core.

I am in favour of this,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
(but I prefer cleaner diff, see below).

...

>  fwnode_lookup:
> -	gdev = gpio_device_find_by_fwnode(fwnode);

> -	return gdev ?: ERR_PTR(-EPROBE_DEFER);


Can we simply leave these two instead?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpio: swnode: remove deprecated lookup mechanism
  2026-06-29 13:10 ` Andy Shevchenko
@ 2026-06-29 14:04   ` Bartosz Golaszewski
  2026-06-29 14:35     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-06-29 14:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
	Andy Shevchenko, linux-gpio, linux-kernel, Bartosz Golaszewski

On Mon, 29 Jun 2026 15:10:40 +0200, Andy Shevchenko
<andriy.shevchenko@intel.com> said:
> On Mon, Jun 29, 2026 at 12:54:58PM +0200, Bartosz Golaszewski wrote:
>> GPIO software node lookup should rely exclusively on matching the
>> addresses of the referenced firmware nodes. Commit e5d527be7e69 ("gpio:
>> swnode: don't use the swnode's name as the key for GPIO lookup") tried to
>> enforce this but had to be reverted: it broke existing users who abused
>> the software node mechanism by creating "dummy" software nodes named
>> after the device they want to get GPIOs from, without ever attaching them
>> to the actual GPIO devices. Those users relied on GPIOLIB matching the
>> label of the GPIO controller against the name of the software node rather
>> than on a real firmware node link.
>>
>> All such users have now been coverted to using attached software nodes
>> via the fwnode address lookup path and the kernel documentation has been
>> updated to recommend it as the correct approach. This allows us to remove
>> the old behavior.
>>
>> This will allow us to leverage the upcoming support for fw_devlink for
>> software nodes in GPIO core.
>
> I am in favour of this,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> (but I prefer cleaner diff, see below).
>
> ...
>
>>  fwnode_lookup:
>> -	gdev = gpio_device_find_by_fwnode(fwnode);
>
>> -	return gdev ?: ERR_PTR(-EPROBE_DEFER);
>
>
> Can we simply leave these two instead?
>

Honestly, that's just personal preference. I prefer the oneliner.

Bart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpio: swnode: remove deprecated lookup mechanism
  2026-06-29 10:54 [PATCH] gpio: swnode: remove deprecated lookup mechanism Bartosz Golaszewski
  2026-06-29 13:10 ` Andy Shevchenko
@ 2026-06-29 14:23 ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-06-29 14:23 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Bartosz Golaszewski,
	Dmitry Torokhov, Andy Shevchenko
  Cc: oe-kbuild-all, linux-gpio, linux-kernel

Hi Bartosz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on dc59e4fea9d83f03bad6bddf3fa2e52491777482]

url:    https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/gpio-swnode-remove-deprecated-lookup-mechanism/20260629-185811
base:   dc59e4fea9d83f03bad6bddf3fa2e52491777482
patch link:    https://lore.kernel.org/r/20260629-gpio-swnode-drop-label-matching-v1-1-db1af36cf883%40oss.qualcomm.com
patch subject: [PATCH] gpio: swnode: remove deprecated lookup mechanism
config: m68k-allnoconfig (https://download.01.org/0day-ci/archive/20260629/202606292234.A3QghcWA-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260629/202606292234.A3QghcWA-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202606292234.A3QghcWA-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/gpio/gpiolib-swnode.c: In function 'swnode_get_gpio_device':
>> drivers/gpio/gpiolib-swnode.c:29:29: warning: unused variable 'gdev' [-Wunused-variable]
      29 |         struct gpio_device *gdev;
         |                             ^~~~


vim +/gdev +29 drivers/gpio/gpiolib-swnode.c

e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  25  
b7b56e64a345e7 Bartosz Golaszewski 2023-09-27  26  static struct gpio_device *swnode_get_gpio_device(struct fwnode_handle *fwnode)
e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  27  {
b7b56e64a345e7 Bartosz Golaszewski 2023-09-27  28  	const struct software_node *gdev_node;
b7b56e64a345e7 Bartosz Golaszewski 2023-09-27 @29  	struct gpio_device *gdev;
e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  30  
b7b56e64a345e7 Bartosz Golaszewski 2023-09-27  31  	gdev_node = to_software_node(fwnode);
6774a66d0e103d Bartosz Golaszewski 2025-12-15  32  	if (!gdev_node)
216c1204757190 Bartosz Golaszewski 2025-11-20  33  		goto fwnode_lookup;
e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  34  
9d50f95bc0d5df Charles Keepax      2024-04-16  35  	/*
9d50f95bc0d5df Charles Keepax      2024-04-16  36  	 * Check for a special node that identifies undefined GPIOs, this is
9d50f95bc0d5df Charles Keepax      2024-04-16  37  	 * primarily used as a key for internal chip selects in SPI bindings.
9d50f95bc0d5df Charles Keepax      2024-04-16  38  	 */
9d50f95bc0d5df Charles Keepax      2024-04-16  39  	if (IS_ENABLED(CONFIG_GPIO_SWNODE_UNDEFINED) &&
6774a66d0e103d Bartosz Golaszewski 2025-12-15  40  	    gdev_node == &swnode_gpio_undefined)
9d50f95bc0d5df Charles Keepax      2024-04-16  41  		return ERR_PTR(-ENOENT);
9d50f95bc0d5df Charles Keepax      2024-04-16  42  
216c1204757190 Bartosz Golaszewski 2025-11-20  43  fwnode_lookup:
ff373b244a4cbb Bartosz Golaszewski 2026-06-29  44  	return gpio_device_find_by_fwnode(fwnode) ?: ERR_PTR(-EPROBE_DEFER);
e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  45  }
e7f9ff5dc90c38 Dmitry Torokhov     2022-11-11  46  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gpio: swnode: remove deprecated lookup mechanism
  2026-06-29 14:04   ` Bartosz Golaszewski
@ 2026-06-29 14:35     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-06-29 14:35 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Dmitry Torokhov, Andy Shevchenko, linux-gpio,
	linux-kernel, Bartosz Golaszewski

On Mon, Jun 29, 2026 at 07:04:43AM -0700, Bartosz Golaszewski wrote:
> On Mon, 29 Jun 2026 15:10:40 +0200, Andy Shevchenko
> <andriy.shevchenko@intel.com> said:
> > On Mon, Jun 29, 2026 at 12:54:58PM +0200, Bartosz Golaszewski wrote:

...

> >>  fwnode_lookup:
> >> -	gdev = gpio_device_find_by_fwnode(fwnode);
> >
> >> -	return gdev ?: ERR_PTR(-EPROBE_DEFER);
> >
> > Can we simply leave these two instead?
> 
> Honestly, that's just personal preference. I prefer the oneliner.

I was under impression that gdev variable has use after this, but LKP showed
that you missed its removal. With that in mind, I have no objections against
oneliner.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-29 14:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 10:54 [PATCH] gpio: swnode: remove deprecated lookup mechanism Bartosz Golaszewski
2026-06-29 13:10 ` Andy Shevchenko
2026-06-29 14:04   ` Bartosz Golaszewski
2026-06-29 14:35     ` Andy Shevchenko
2026-06-29 14:23 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox