* [PATCH v4 0/2] platform/x86: x86-android-tablets: use real firmware node references with intel drivers
@ 2026-04-30 7:34 Bartosz Golaszewski
2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski
2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski
0 siblings, 2 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-04-30 7:34 UTC (permalink / raw)
To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede,
Ilpo Järvinen, Dmitry Torokhov, Len Brown
Cc: linux-acpi, driver-core, linux-kernel, linux-gpio,
platform-driver-x86, brgl, Bartosz Golaszewski
First let me repeat the problem statement:
==
GPIO software node lookup should rely exclusively on matching the
addresses of the referenced firmware nodes. I tried to enforce it with
commit e5d527be7e69 ("gpio: swnode: don't use the swnode's name as the
key for GPIO lookup") but it broke existing users who abuse the software
node mechanism by creating "dummy" software nodes named after the device
they want to get GPIOs from but never attaching them to the actual GPIO
devices. They rely on the current behavior of GPIOLIB where it will match
the label of the GPIO controller against the name of the software node
and does not require a true link.
x86-android-tablets driver is one of the abusers in that it creates
dummy software nodes for baytrail and cherryview GPIO controllers but
they don't really reference these devices. Before we can reapply
e5d527be7e69 and support matching by fwnode address exclusively, we need
to convert all the users to using actual fwnode references.
==
Now for the new approach:
Now with the recent patches I sent or plan to send out, it turns out
that almost all existing users of software node lookup can easily have
the software node's representing the GPIO controllers attached to their
target devices as their primary firmware node. The remaining complex
cases are: pcengines-apuv2 and geode-common but in the first case we
have control over the creation of the GPIO device - we can assign it a
firmware node - and in the second case, we deal with an MFD driver so
can export the cell's software node in a header.
The only remaining use-case where we need to reference a GPIO controller
described in ACPI from a software node is the x86-android-tablets
driver. In this case, I think it no longer makes sense to propose a new
generic interface. Instead, I'd like to propose to keep it as a
driver-specific quirk.
This series proposes the following changes:
1. Provide acpi_bus_find_device_by_name() for looking up ACPI devices.
2. Implement support for dynamic assignment of secondary firmware nodes
in the x86-android-tablets driver. More details on how it's approached
are in the relevant commit message.
The dependencies in driver core and GPIOLIB are already upstream.
Merging strategy: Both patches should go through the X86 platform tree
with an Ack from Rafael.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v4:
- As pointed out by Hans: we don't need the notifier logic so replace
patch 1/2 with another, providing an ACPI helper for locating devices
by name and simplify patch 2/2
- Link to v3: https://patch.msgid.link/20260427-baytrail-real-swnode-v3-0-0003e4c1708c@oss.qualcomm.com
Changes in v3:
- Drop dependencies that got upstream for v7.1
- Rebase on top of v7.1-rc1
- Link to v2: https://patch.msgid.link/20260402-baytrail-real-swnode-v2-0-6f5054a4cc07@oss.qualcomm.com
Changes in v2:
- Completely new approach
- Keep the cherryview and baytrail secondary fwnode handling as a
driver-specific quirk for x86 tablets and don't introduce any new API
- Change the return value when resolving a reference to an unregistered
software node and defer probe in GPIOLIB in that situation
- Export acpi_bus_type for use in x86-android-tablets
- Link to v1: https://patch.msgid.link/20260319-baytrail-real-swnode-v1-0-75f2264ae49f@oss.qualcomm.com
---
Bartosz Golaszewski (2):
ACPI: provide acpi_bus_find_device_by_name()
platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips
drivers/acpi/bus.c | 13 +++++
drivers/platform/x86/x86-android-tablets/core.c | 78 ++++++++++++++++++++++++-
include/linux/acpi.h | 7 +++
3 files changed, 95 insertions(+), 3 deletions(-)
---
base-commit: 085f14acda1c46ab815605ecf2341afe5a691eb9
change-id: 20260319-baytrail-real-swnode-7de7a3870f78
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() 2026-04-30 7:34 [PATCH v4 0/2] platform/x86: x86-android-tablets: use real firmware node references with intel drivers Bartosz Golaszewski @ 2026-04-30 7:34 ` Bartosz Golaszewski 2026-04-30 9:57 ` Rafael J. Wysocki 2026-04-30 12:45 ` Andy Shevchenko 2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski 1 sibling, 2 replies; 8+ messages in thread From: Bartosz Golaszewski @ 2026-04-30 7:34 UTC (permalink / raw) To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown Cc: linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl, Bartosz Golaszewski Provide a helper allowing to locate an ACPI device by its name. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> --- drivers/acpi/bus.c | 13 +++++++++++++ include/linux/acpi.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 2ec095e2009e40b0645f654fb051429e5679dc7c..5dd8459be03db4165bcb59943b94ea7db273ad7b 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -1181,6 +1181,19 @@ int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data) } EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev); +/** + * acpi_bus_find_device_by_name() - Locate an ACPI device by its name + * @name: Name of the device to match + * + * Returns: + * New reference to the matched device or NULL if the device can't be found. + */ +struct device *acpi_bus_find_device_by_name(const char *name) +{ + return bus_find_device_by_name(&acpi_bus_type, NULL, name); +} +EXPORT_SYMBOL_GPL(acpi_bus_find_device_by_name); + struct acpi_dev_walk_context { int (*fn)(struct acpi_device *, void *); void *data; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 67effb91fa98373d7bf19be5ae3d8baa9328d6e1..10d6c6c11bdffcad14100601e104520366dfc30b 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -798,6 +798,8 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr); int acpi_get_local_address(acpi_handle handle, u32 *addr); const char *acpi_get_subsystem_id(acpi_handle handle); +struct device *acpi_bus_find_device_by_name(const char *name); + #ifdef CONFIG_ACPI_MRRM int acpi_mrrm_max_mem_region(void); #endif @@ -1106,6 +1108,11 @@ static inline const char *acpi_get_subsystem_id(acpi_handle handle) return ERR_PTR(-ENODEV); } +static inline struct device *acpi_bus_find_device_by_name(const char *name) +{ + return NULL; +} + static inline int acpi_register_wakeup_handler(int wake_irq, bool (*wakeup)(void *context), void *context) { -- 2.47.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() 2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski @ 2026-04-30 9:57 ` Rafael J. Wysocki 2026-04-30 12:45 ` Andy Shevchenko 1 sibling, 0 replies; 8+ messages in thread From: Rafael J. Wysocki @ 2026-04-30 9:57 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown, linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl On Thu, Apr 30, 2026 at 9:34 AM Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> wrote: > > Provide a helper allowing to locate an ACPI device by its name. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> > --- > drivers/acpi/bus.c | 13 +++++++++++++ > include/linux/acpi.h | 7 +++++++ > 2 files changed, 20 insertions(+) > > diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c > index 2ec095e2009e40b0645f654fb051429e5679dc7c..5dd8459be03db4165bcb59943b94ea7db273ad7b 100644 > --- a/drivers/acpi/bus.c > +++ b/drivers/acpi/bus.c > @@ -1181,6 +1181,19 @@ int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data) > } > EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev); > > +/** > + * acpi_bus_find_device_by_name() - Locate an ACPI device by its name > + * @name: Name of the device to match > + * > + * Returns: > + * New reference to the matched device or NULL if the device can't be found. > + */ > +struct device *acpi_bus_find_device_by_name(const char *name) > +{ > + return bus_find_device_by_name(&acpi_bus_type, NULL, name); > +} > +EXPORT_SYMBOL_GPL(acpi_bus_find_device_by_name); > + > struct acpi_dev_walk_context { > int (*fn)(struct acpi_device *, void *); > void *data; > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 67effb91fa98373d7bf19be5ae3d8baa9328d6e1..10d6c6c11bdffcad14100601e104520366dfc30b 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -798,6 +798,8 @@ int acpi_get_local_u64_address(acpi_handle handle, u64 *addr); > int acpi_get_local_address(acpi_handle handle, u32 *addr); > const char *acpi_get_subsystem_id(acpi_handle handle); > > +struct device *acpi_bus_find_device_by_name(const char *name); > + > #ifdef CONFIG_ACPI_MRRM > int acpi_mrrm_max_mem_region(void); > #endif > @@ -1106,6 +1108,11 @@ static inline const char *acpi_get_subsystem_id(acpi_handle handle) > return ERR_PTR(-ENODEV); > } > > +static inline struct device *acpi_bus_find_device_by_name(const char *name) > +{ > + return NULL; > +} > + > static inline int acpi_register_wakeup_handler(int wake_irq, > bool (*wakeup)(void *context), void *context) > { > > -- > 2.47.3 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() 2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski 2026-04-30 9:57 ` Rafael J. Wysocki @ 2026-04-30 12:45 ` Andy Shevchenko 1 sibling, 0 replies; 8+ messages in thread From: Andy Shevchenko @ 2026-04-30 12:45 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown, linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl On Thu, Apr 30, 2026 at 09:34:05AM +0200, Bartosz Golaszewski wrote: > Provide a helper allowing to locate an ACPI device by its name. ... > +/** > + * acpi_bus_find_device_by_name() - Locate an ACPI device by its name > + * @name: Name of the device to match * * Caller is responsible to put_device() on the returned object * when it is no more needed. Or use whatever wording that is already present nearby and around similar cases there. > + * > + * Returns: > + * New reference to the matched device or NULL if the device can't be found. > + */ -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips 2026-04-30 7:34 [PATCH v4 0/2] platform/x86: x86-android-tablets: use real firmware node references with intel drivers Bartosz Golaszewski 2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski @ 2026-04-30 7:34 ` Bartosz Golaszewski 2026-04-30 10:03 ` Rafael J. Wysocki 2026-04-30 12:51 ` Andy Shevchenko 1 sibling, 2 replies; 8+ messages in thread From: Bartosz Golaszewski @ 2026-04-30 7:34 UTC (permalink / raw) To: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown Cc: linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl, Bartosz Golaszewski In order to allow GPIOLIB to match cherryview and baytrail GPIO controllers by their firmware nodes instead of their names, we need to attach the - currently "dangling" - existing software nodes to their target devices dynamically. The driver uses platform_create_bundle() and expects all required providers to be present before it itself is probed. We know the name of the device we're waiting for so look them up and assign the appropriate software node as the secondary firmware node of the underlying ACPI node. Scheduling fine-grained devres actions allows for proper teardown and unsetting of the secondary firmware nodes. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> --- drivers/platform/x86/x86-android-tablets/core.c | 78 ++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c index 021009e9085bec3db9c4daa1f6235600210a6099..8fd0cffe351577182f31c90c104b616cec78c481 100644 --- a/drivers/platform/x86/x86-android-tablets/core.c +++ b/drivers/platform/x86/x86-android-tablets/core.c @@ -13,6 +13,7 @@ #include <linux/acpi.h> #include <linux/device.h> #include <linux/dmi.h> +#include <linux/fwnode.h> #include <linux/gpio/consumer.h> #include <linux/gpio/machine.h> #include <linux/irq.h> @@ -360,6 +361,76 @@ static const struct software_node *cherryview_gpiochip_node_group[] = { NULL }; +static void auto_secondary_unset(void *data) +{ + struct fwnode_handle *fwnode = data; + + fwnode->secondary = NULL; +} + +static int acpi_set_secondary_fwnode(struct device *parent, struct device *dev, + const struct software_node *const swnode) +{ + struct acpi_device *device = to_acpi_device(dev); + struct fwnode_handle *fwnode; + int ret; + + fwnode = software_node_fwnode(swnode); + if (WARN_ON(!fwnode)) + return -ENOENT; + + fwnode->secondary = ERR_PTR(-ENODEV); + device->fwnode.secondary = fwnode; + + ret = devm_add_action_or_reset(parent, auto_secondary_unset, &device->fwnode); + if (ret) + dev_err(parent, "Failed to schedule the unset action for secondary fwnode\n"); + + return ret; +} + +static void auto_secondary_unregister_node_group(void *data) +{ + const struct software_node **nodes = data; + + software_node_unregister_node_group(nodes); +} + +static int auto_secondary_fwnode_init(struct device *parent) +{ + const struct software_node *const *swnode; + int ret; + + if (!gpiochip_node_group) + return 0; + + ret = software_node_register_node_group(gpiochip_node_group); + if (ret) + return ret; + + ret = devm_add_action_or_reset(parent, + auto_secondary_unregister_node_group, + gpiochip_node_group); + if (ret) + return ret; + + for (swnode = gpiochip_node_group; *swnode; swnode++) { + struct device *dev __free(put_device) = + acpi_bus_find_device_by_name((*swnode)->name); + if (!dev) { + dev_err(parent, "Failed to find the required GPIO controller: %s\n", + (*swnode)->name); + return -ENODEV; + } + + ret = acpi_set_secondary_fwnode(parent, dev, *swnode); + if (ret) + return ret; + } + + return 0; +} + static void x86_android_tablet_remove(struct platform_device *pdev) { int i; @@ -391,7 +462,6 @@ static void x86_android_tablet_remove(struct platform_device *pdev) software_node_unregister_node_group(gpio_button_swnodes); software_node_unregister_node_group(swnode_group); - software_node_unregister_node_group(gpiochip_node_group); } static __init int x86_android_tablet_probe(struct platform_device *pdev) @@ -427,9 +497,11 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) break; } - ret = software_node_register_node_group(gpiochip_node_group); - if (ret) + ret = auto_secondary_fwnode_init(&pdev->dev); + if (ret) { + x86_android_tablet_remove(pdev); return ret; + } ret = software_node_register_node_group(dev_info->swnode_group); if (ret) { -- 2.47.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips 2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski @ 2026-04-30 10:03 ` Rafael J. Wysocki 2026-04-30 12:51 ` Andy Shevchenko 1 sibling, 0 replies; 8+ messages in thread From: Rafael J. Wysocki @ 2026-04-30 10:03 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown, linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl On Thu, Apr 30, 2026 at 9:34 AM Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> wrote: > > In order to allow GPIOLIB to match cherryview and baytrail GPIO > controllers by their firmware nodes instead of their names, we need to > attach the - currently "dangling" - existing software nodes to their > target devices dynamically. > > The driver uses platform_create_bundle() and expects all required > providers to be present before it itself is probed. We know the name of > the device we're waiting for so look them up and assign the appropriate > software node as the secondary firmware node of the underlying ACPI node. > > Scheduling fine-grained devres actions allows for proper teardown and > unsetting of the secondary firmware nodes. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> I may have missed something subtle, but overall it looks reasonable to me, so Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> > --- > drivers/platform/x86/x86-android-tablets/core.c | 78 ++++++++++++++++++++++++- > 1 file changed, 75 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c > index 021009e9085bec3db9c4daa1f6235600210a6099..8fd0cffe351577182f31c90c104b616cec78c481 100644 > --- a/drivers/platform/x86/x86-android-tablets/core.c > +++ b/drivers/platform/x86/x86-android-tablets/core.c > @@ -13,6 +13,7 @@ > #include <linux/acpi.h> > #include <linux/device.h> > #include <linux/dmi.h> > +#include <linux/fwnode.h> > #include <linux/gpio/consumer.h> > #include <linux/gpio/machine.h> > #include <linux/irq.h> > @@ -360,6 +361,76 @@ static const struct software_node *cherryview_gpiochip_node_group[] = { > NULL > }; > > +static void auto_secondary_unset(void *data) > +{ > + struct fwnode_handle *fwnode = data; > + > + fwnode->secondary = NULL; > +} > + > +static int acpi_set_secondary_fwnode(struct device *parent, struct device *dev, > + const struct software_node *const swnode) > +{ > + struct acpi_device *device = to_acpi_device(dev); > + struct fwnode_handle *fwnode; > + int ret; > + > + fwnode = software_node_fwnode(swnode); > + if (WARN_ON(!fwnode)) > + return -ENOENT; > + > + fwnode->secondary = ERR_PTR(-ENODEV); > + device->fwnode.secondary = fwnode; > + > + ret = devm_add_action_or_reset(parent, auto_secondary_unset, &device->fwnode); > + if (ret) > + dev_err(parent, "Failed to schedule the unset action for secondary fwnode\n"); > + > + return ret; > +} > + > +static void auto_secondary_unregister_node_group(void *data) > +{ > + const struct software_node **nodes = data; > + > + software_node_unregister_node_group(nodes); > +} > + > +static int auto_secondary_fwnode_init(struct device *parent) > +{ > + const struct software_node *const *swnode; > + int ret; > + > + if (!gpiochip_node_group) > + return 0; > + > + ret = software_node_register_node_group(gpiochip_node_group); > + if (ret) > + return ret; > + > + ret = devm_add_action_or_reset(parent, > + auto_secondary_unregister_node_group, > + gpiochip_node_group); > + if (ret) > + return ret; > + > + for (swnode = gpiochip_node_group; *swnode; swnode++) { > + struct device *dev __free(put_device) = > + acpi_bus_find_device_by_name((*swnode)->name); > + if (!dev) { > + dev_err(parent, "Failed to find the required GPIO controller: %s\n", > + (*swnode)->name); > + return -ENODEV; > + } > + > + ret = acpi_set_secondary_fwnode(parent, dev, *swnode); > + if (ret) > + return ret; > + } > + > + return 0; > +} > + > static void x86_android_tablet_remove(struct platform_device *pdev) > { > int i; > @@ -391,7 +462,6 @@ static void x86_android_tablet_remove(struct platform_device *pdev) > > software_node_unregister_node_group(gpio_button_swnodes); > software_node_unregister_node_group(swnode_group); > - software_node_unregister_node_group(gpiochip_node_group); > } > > static __init int x86_android_tablet_probe(struct platform_device *pdev) > @@ -427,9 +497,11 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev) > break; > } > > - ret = software_node_register_node_group(gpiochip_node_group); > - if (ret) > + ret = auto_secondary_fwnode_init(&pdev->dev); > + if (ret) { > + x86_android_tablet_remove(pdev); > return ret; > + } > > ret = software_node_register_node_group(dev_info->swnode_group); > if (ret) { > > -- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips 2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski 2026-04-30 10:03 ` Rafael J. Wysocki @ 2026-04-30 12:51 ` Andy Shevchenko 2026-04-30 13:01 ` Andy Shevchenko 1 sibling, 1 reply; 8+ messages in thread From: Andy Shevchenko @ 2026-04-30 12:51 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown, linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl On Thu, Apr 30, 2026 at 09:34:06AM +0200, Bartosz Golaszewski wrote: > In order to allow GPIOLIB to match cherryview and baytrail GPIO > controllers by their firmware nodes instead of their names, we need to > attach the - currently "dangling" - existing software nodes to their > target devices dynamically. > > The driver uses platform_create_bundle() and expects all required > providers to be present before it itself is probed. We know the name of > the device we're waiting for so look them up and assign the appropriate > software node as the secondary firmware node of the underlying ACPI node. > > Scheduling fine-grained devres actions allows for proper teardown and > unsetting of the secondary firmware nodes. ... > +static void auto_secondary_unset(void *data) > +{ > + struct fwnode_handle *fwnode = data; > + > + fwnode->secondary = NULL; > +} > + > +static int acpi_set_secondary_fwnode(struct device *parent, struct device *dev, > + const struct software_node *const swnode) > +{ > + struct acpi_device *device = to_acpi_device(dev); > + struct fwnode_handle *fwnode; > + int ret; > + > + fwnode = software_node_fwnode(swnode); > + if (WARN_ON(!fwnode)) > + return -ENOENT; > + > + fwnode->secondary = ERR_PTR(-ENODEV); > + device->fwnode.secondary = fwnode; > + > + ret = devm_add_action_or_reset(parent, auto_secondary_unset, &device->fwnode); > + if (ret) > + dev_err(parent, "Failed to schedule the unset action for secondary fwnode\n"); > + > + return ret; > +} Why don't we use set_secondary_fwnode() in the above functions? Drivers are not supposed to know the guts of the fwnode implementation. ... > +static int auto_secondary_fwnode_init(struct device *parent) > +{ > + const struct software_node *const *swnode; > + int ret; > + > + if (!gpiochip_node_group) > + return 0; > + > + ret = software_node_register_node_group(gpiochip_node_group); > + if (ret) > + return ret; > + > + ret = devm_add_action_or_reset(parent, > + auto_secondary_unregister_node_group, > + gpiochip_node_group); > + if (ret) > + return ret; > + > + for (swnode = gpiochip_node_group; *swnode; swnode++) { > + struct device *dev __free(put_device) = > + acpi_bus_find_device_by_name((*swnode)->name); > + if (!dev) { > + dev_err(parent, "Failed to find the required GPIO controller: %s\n", > + (*swnode)->name); swnode at this point is registered, meaning we have an associated fwnode handle, hence why not use %pfwP here? > + return -ENODEV; > + } > + > + ret = acpi_set_secondary_fwnode(parent, dev, *swnode); > + if (ret) > + return ret; > + } > + > + return 0; > +} -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips 2026-04-30 12:51 ` Andy Shevchenko @ 2026-04-30 13:01 ` Andy Shevchenko 0 siblings, 0 replies; 8+ messages in thread From: Andy Shevchenko @ 2026-04-30 13:01 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Mika Westerberg, Andy Shevchenko, Linus Walleij, Hans de Goede, Ilpo Järvinen, Dmitry Torokhov, Len Brown, linux-acpi, driver-core, linux-kernel, linux-gpio, platform-driver-x86, brgl On Thu, Apr 30, 2026 at 03:51:58PM +0300, Andy Shevchenko wrote: > On Thu, Apr 30, 2026 at 09:34:06AM +0200, Bartosz Golaszewski wrote: ... > > + for (swnode = gpiochip_node_group; *swnode; swnode++) { > > + struct device *dev __free(put_device) = > > + acpi_bus_find_device_by_name((*swnode)->name); > > + if (!dev) { > > + dev_err(parent, "Failed to find the required GPIO controller: %s\n", > > + (*swnode)->name); > > swnode at this point is registered, meaning we have an associated fwnode > handle, hence why not use %pfwP here? After reading the code again I think your version is KISS, no need for over engineering :-) > > + return -ENODEV; > > + } -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-04-30 13:01 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-04-30 7:34 [PATCH v4 0/2] platform/x86: x86-android-tablets: use real firmware node references with intel drivers Bartosz Golaszewski 2026-04-30 7:34 ` [PATCH v4 1/2] ACPI: provide acpi_bus_find_device_by_name() Bartosz Golaszewski 2026-04-30 9:57 ` Rafael J. Wysocki 2026-04-30 12:45 ` Andy Shevchenko 2026-04-30 7:34 ` [PATCH v4 2/2] platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips Bartosz Golaszewski 2026-04-30 10:03 ` Rafael J. Wysocki 2026-04-30 12:51 ` Andy Shevchenko 2026-04-30 13:01 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox