* [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
@ 2026-02-26 9:56 Bartosz Golaszewski
2026-02-26 10:40 ` Sakari Ailus
2026-02-27 8:58 ` Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-02-26 9:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
Len Brown
Cc: driver-core, linux-kernel, linux-gpio, brgl, linux-acpi,
Bartosz Golaszewski
In GPIOLIB, during fwnode lookup, after having resolved the consumer's
reference to a specific fwnode, we only match it against the primary
node of the controllers. Let's extend that to also the secondary node by
reworking gpio_chip_match_by_fwnode()
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Link: https://lore.kernel.org/all/aZUIFiOYt6GOlDQx@google.com/
---
Changes in v4:
- Drop redundant !IS_ERR(node->secondary) check
- Link to v3: https://patch.msgid.link/20260225-device-match-secondary-fwnode-v3-1-a7152054135a@oss.qualcomm.com
Changes in v3:
- Remove the controversial patch 1/2 in favor of hand-coding its
functionality in patch 2/2
- Link to v2: https://patch.msgid.link/20260223-device-match-secondary-fwnode-v2-0-966c00c9eeeb@oss.qualcomm.com
Changes in v2:
- Fold the code initially put into driver code into GPIOLIB as advised
by Rafael
- Rework the logic as suggested by Andy
- To that end: make fwnode_is_primary() public
- Link to v1: https://patch.msgid.link/20260219-device-match-secondary-fwnode-v1-0-a64e8d4754bc@oss.qualcomm.com
---
drivers/gpio/gpiolib.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c52200eaaaff82b12f22dd1ee8459bdd8ec10d81..780e30a033859578dabe3eda984e74db200507f7 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -11,6 +11,7 @@
#include <linux/errno.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/fwnode.h>
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
@@ -1395,7 +1396,16 @@ EXPORT_SYMBOL_GPL(gpio_device_find_by_label);
static int gpio_chip_match_by_fwnode(struct gpio_chip *gc, const void *fwnode)
{
- return device_match_fwnode(&gc->gpiodev->dev, fwnode);
+ struct device *dev = &gc->gpiodev->dev;
+ struct fwnode_handle *node = dev_fwnode(dev);
+
+ if (IS_ERR(fwnode))
+ return 0;
+
+ if (device_match_fwnode(dev, fwnode))
+ return 1;
+
+ return node && node->secondary == fwnode;
}
/**
---
base-commit: 50f68cc7be0a2cbf54d8f6aaf17df32fb01acc3f
change-id: 20260219-device-match-secondary-fwnode-4cc163ec47ee
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
2026-02-26 9:56 [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode() Bartosz Golaszewski
@ 2026-02-26 10:40 ` Sakari Ailus
2026-02-27 8:58 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2026-02-26 10:40 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
Andy Shevchenko, Daniel Scally, Heikki Krogerus, Len Brown,
driver-core, linux-kernel, linux-gpio, linux-acpi
Hi Bartosz,
Thanks for the update.
On Thu, Feb 26, 2026 at 10:56:36AM +0100, Bartosz Golaszewski wrote:
> In GPIOLIB, during fwnode lookup, after having resolved the consumer's
> reference to a specific fwnode, we only match it against the primary
> node of the controllers. Let's extend that to also the secondary node by
> reworking gpio_chip_match_by_fwnode()
>
> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Reviewed-by: Danilo Krummrich <dakr@kernel.org>
> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
2026-02-26 9:56 [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode() Bartosz Golaszewski
2026-02-26 10:40 ` Sakari Ailus
@ 2026-02-27 8:58 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-02-27 8:58 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Linus Walleij, Bartosz Golaszewski, Dmitry Torokhov,
Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
Len Brown, Bartosz Golaszewski
Cc: driver-core, linux-kernel, linux-gpio, linux-acpi
On Thu, 26 Feb 2026 10:56:36 +0100, Bartosz Golaszewski wrote:
> In GPIOLIB, during fwnode lookup, after having resolved the consumer's
> reference to a specific fwnode, we only match it against the primary
> node of the controllers. Let's extend that to also the secondary node by
> reworking gpio_chip_match_by_fwnode()
>
>
Applied, thanks!
[1/1] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode()
https://git.kernel.org/brgl/c/eb58f2b9bb0909ebce64e1a90b21b5cc2c9f17df
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-27 8:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 9:56 [PATCH v4] gpiolib: match secondary fwnode too in gpio_device_find_by_fwnode() Bartosz Golaszewski
2026-02-26 10:40 ` Sakari Ailus
2026-02-27 8:58 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®