* [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
@ 2026-08-31 20:11 Hans de Goede
2026-08-31 20:22 ` Dmitry Torokhov
[not found] ` <apcRAvoHkh9blDwK@black.igk.intel.com>
0 siblings, 2 replies; 8+ messages in thread
From: Hans de Goede @ 2026-08-31 20:11 UTC (permalink / raw)
To: Ilpo Järvinen, Andy Shevchenko, Dmitry Torokhov,
Bartosz Golaszewski, Linus Walleij, Rafael J . Wysocki
Cc: Hans de Goede, platform-driver-x86
acpi_bus_find_device_by_name() call returns a pointer to the device object
on the ACPI bus, aka the ACPI companion device.
gpio_secondary_fwnode_init() then continues with setting the secondary
fwnode on this device. But this is not the actual physical device for
the GPIO controller (e.g. the GPIO controller platform bus device).
This mismatch is causing GPIO lookups by secondary fwnode to not work.
Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
of the first physical device associated with the ACPI companion device.
This fixes the GPIO lookups not working.
Fixes: 1448c2d2ca5c ("platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips")
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
drivers/platform/x86/x86-android-tablets/core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c
index b028af1c9942..1706287fd136 100644
--- a/drivers/platform/x86/x86-android-tablets/core.c
+++ b/drivers/platform/x86/x86-android-tablets/core.c
@@ -417,9 +417,15 @@ static int gpio_secondary_fwnode_init(struct device *parent,
if (WARN_ON(!fwnode))
return -ENOENT;
- set_secondary_fwnode(dev, fwnode);
+ struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
+ if (!phys_dev)
+ return dev_err_probe(parent,
+ -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
+ (*swnode)->name);
- ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(dev));
+ set_secondary_fwnode(phys_dev, fwnode);
+
+ ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev));
if (ret)
return ret;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-08-31 20:11 [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working Hans de Goede
@ 2026-08-31 20:22 ` Dmitry Torokhov
2026-08-31 20:28 ` Hans de Goede
[not found] ` <apcRAvoHkh9blDwK@black.igk.intel.com>
1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2026-08-31 20:22 UTC (permalink / raw)
To: Hans de Goede
Cc: Ilpo Järvinen, Andy Shevchenko, Bartosz Golaszewski,
Linus Walleij, Rafael J . Wysocki, platform-driver-x86
On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
> acpi_bus_find_device_by_name() call returns a pointer to the device object
> on the ACPI bus, aka the ACPI companion device.
>
> gpio_secondary_fwnode_init() then continues with setting the secondary
> fwnode on this device. But this is not the actual physical device for
> the GPIO controller (e.g. the GPIO controller platform bus device).
>
> This mismatch is causing GPIO lookups by secondary fwnode to not work.
>
> Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
> of the first physical device associated with the ACPI companion device.
>
> This fixes the GPIO lookups not working.
Nice find, thank you!
>
> Fixes: 1448c2d2ca5c ("platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips")
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
> drivers/platform/x86/x86-android-tablets/core.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c
> index b028af1c9942..1706287fd136 100644
> --- a/drivers/platform/x86/x86-android-tablets/core.c
> +++ b/drivers/platform/x86/x86-android-tablets/core.c
> @@ -417,9 +417,15 @@ static int gpio_secondary_fwnode_init(struct device *parent,
> if (WARN_ON(!fwnode))
> return -ENOENT;
>
> - set_secondary_fwnode(dev, fwnode);
> + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
> + if (!phys_dev)
> + return dev_err_probe(parent,
> + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
> + (*swnode)->name);
>
> - ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(dev));
> + set_secondary_fwnode(phys_dev, fwnode);
> +
> + ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev));
I am surprised that acpi_get_first_physical_node() does not bump up
refcount of the device...
> if (ret)
> return ret;
This leaks refcount on error though...
> }
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-08-31 20:22 ` Dmitry Torokhov
@ 2026-08-31 20:28 ` Hans de Goede
2026-08-31 20:34 ` Dmitry Torokhov
0 siblings, 1 reply; 8+ messages in thread
From: Hans de Goede @ 2026-08-31 20:28 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Ilpo Järvinen, Andy Shevchenko, Bartosz Golaszewski,
Linus Walleij, Rafael J . Wysocki, platform-driver-x86
Hi,
On 31-Aug-26 22:22, Dmitry Torokhov wrote:
> On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
>> acpi_bus_find_device_by_name() call returns a pointer to the device object
>> on the ACPI bus, aka the ACPI companion device.
>>
>> gpio_secondary_fwnode_init() then continues with setting the secondary
>> fwnode on this device. But this is not the actual physical device for
>> the GPIO controller (e.g. the GPIO controller platform bus device).
>>
>> This mismatch is causing GPIO lookups by secondary fwnode to not work.
>>
>> Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
>> of the first physical device associated with the ACPI companion device.
>>
>> This fixes the GPIO lookups not working.
>
> Nice find, thank you!
>
>>
>> Fixes: 1448c2d2ca5c ("platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips")
>> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
>> ---
>> drivers/platform/x86/x86-android-tablets/core.c | 10 ++++++++--
>> 1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c
>> index b028af1c9942..1706287fd136 100644
>> --- a/drivers/platform/x86/x86-android-tablets/core.c
>> +++ b/drivers/platform/x86/x86-android-tablets/core.c
>> @@ -417,9 +417,15 @@ static int gpio_secondary_fwnode_init(struct device *parent,
>> if (WARN_ON(!fwnode))
>> return -ENOENT;
>>
>> - set_secondary_fwnode(dev, fwnode);
>> + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
>> + if (!phys_dev)
>> + return dev_err_probe(parent,
>> + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
>> + (*swnode)->name);
>>
>> - ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(dev));
>> + set_secondary_fwnode(phys_dev, fwnode);
>> +
>> + ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev));
>
> I am surprised that acpi_get_first_physical_node() does not bump up
> refcount of the device...
> >> if (ret)
>> return ret;
>
> This leaks refcount on error though...
The or_reset part of devm_add_action_or_reset() will call gpio_secondary_unset
on failure which puts the ref we take here on phys_dev.
And the original reference on the ACPI bus device returned by
acpi_bus_find_device_by_name() us auto-free-ed since dev is declared as:
struct device *dev __free(put_device) = ...
or am I missing something here ?
(also note the refcounting is not changed, this just exchanges dev with
phys_dev)
Regards,
Hans
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-08-31 20:28 ` Hans de Goede
@ 2026-08-31 20:34 ` Dmitry Torokhov
0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2026-08-31 20:34 UTC (permalink / raw)
To: Hans de Goede
Cc: Ilpo Järvinen, Andy Shevchenko, Bartosz Golaszewski,
Linus Walleij, Rafael J . Wysocki, platform-driver-x86
On Mon, Aug 31, 2026 at 10:28:33PM +0200, Hans de Goede wrote:
> Hi,
>
> On 31-Aug-26 22:22, Dmitry Torokhov wrote:
> > On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
> >> acpi_bus_find_device_by_name() call returns a pointer to the device object
> >> on the ACPI bus, aka the ACPI companion device.
> >>
> >> gpio_secondary_fwnode_init() then continues with setting the secondary
> >> fwnode on this device. But this is not the actual physical device for
> >> the GPIO controller (e.g. the GPIO controller platform bus device).
> >>
> >> This mismatch is causing GPIO lookups by secondary fwnode to not work.
> >>
> >> Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
> >> of the first physical device associated with the ACPI companion device.
> >>
> >> This fixes the GPIO lookups not working.
> >
> > Nice find, thank you!
> >
> >>
> >> Fixes: 1448c2d2ca5c ("platform/x86: x86-android-tablets: enable fwnode matching of GPIO chips")
> >> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> >> ---
> >> drivers/platform/x86/x86-android-tablets/core.c | 10 ++++++++--
> >> 1 file changed, 8 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/platform/x86/x86-android-tablets/core.c b/drivers/platform/x86/x86-android-tablets/core.c
> >> index b028af1c9942..1706287fd136 100644
> >> --- a/drivers/platform/x86/x86-android-tablets/core.c
> >> +++ b/drivers/platform/x86/x86-android-tablets/core.c
> >> @@ -417,9 +417,15 @@ static int gpio_secondary_fwnode_init(struct device *parent,
> >> if (WARN_ON(!fwnode))
> >> return -ENOENT;
> >>
> >> - set_secondary_fwnode(dev, fwnode);
> >> + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
> >> + if (!phys_dev)
> >> + return dev_err_probe(parent,
> >> + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
> >> + (*swnode)->name);
> >>
> >> - ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(dev));
> >> + set_secondary_fwnode(phys_dev, fwnode);
> >> +
> >> + ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev));
> >
> > I am surprised that acpi_get_first_physical_node() does not bump up
> > refcount of the device...
> > >> if (ret)
> >> return ret;
> >
> > This leaks refcount on error though...
>
> The or_reset part of devm_add_action_or_reset() will call gpio_secondary_unset
> on failure which puts the ref we take here on phys_dev.
Ah, yes, you are right. Sorry for the noise.
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
[not found] ` <apcRAvoHkh9blDwK@black.igk.intel.com>
@ 2026-09-03 11:54 ` Ilpo Järvinen
2026-09-08 17:51 ` Hans de Goede
0 siblings, 1 reply; 8+ messages in thread
From: Ilpo Järvinen @ 2026-09-03 11:54 UTC (permalink / raw)
To: Andy Shevchenko, Hans de Goede
Cc: Dmitry Torokhov, Bartosz Golaszewski, Linus Walleij,
Rafael J . Wysocki, platform-driver-x86
On Tue, 1 Sep 2026, Andy Shevchenko wrote:
> On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
> > acpi_bus_find_device_by_name() call returns a pointer to the device object
> > on the ACPI bus, aka the ACPI companion device.
> >
> > gpio_secondary_fwnode_init() then continues with setting the secondary
> > fwnode on this device. But this is not the actual physical device for
> > the GPIO controller (e.g. the GPIO controller platform bus device).
> >
> > This mismatch is causing GPIO lookups by secondary fwnode to not work.
> >
> > Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
> > of the first physical device associated with the ACPI companion device.
> >
> > This fixes the GPIO lookups not working.
>
> ...
>
> > static int gpio_secondary_fwnode_init(struct device *parent,
>
> > if (WARN_ON(!fwnode))
> > return -ENOENT;
> >
> > - set_secondary_fwnode(dev, fwnode);
> > + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
>
> It doesn't look like an auto cleaning pointer, so let's make a declaration
> outside of the code?
>
> > + if (!phys_dev)
> > + return dev_err_probe(parent,
> > + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
> > + (*swnode)->name);
>
> Hmm... Why not %pfwP?
Hi Hans,
I'm waiting for v2.
--
i.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-09-03 11:54 ` Ilpo Järvinen
@ 2026-09-08 17:51 ` Hans de Goede
2026-09-08 19:04 ` Ilpo Järvinen
2026-09-09 14:11 ` Andy Shevchenko
0 siblings, 2 replies; 8+ messages in thread
From: Hans de Goede @ 2026-09-08 17:51 UTC (permalink / raw)
To: Ilpo Järvinen, Andy Shevchenko
Cc: Dmitry Torokhov, Bartosz Golaszewski, Linus Walleij,
Rafael J . Wysocki, platform-driver-x86
Hi Ilpo,
On 3-Sep-26 13:54, Ilpo Järvinen wrote:
> On Tue, 1 Sep 2026, Andy Shevchenko wrote:
>
>> On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
>>> acpi_bus_find_device_by_name() call returns a pointer to the device object
>>> on the ACPI bus, aka the ACPI companion device.
>>>
>>> gpio_secondary_fwnode_init() then continues with setting the secondary
>>> fwnode on this device. But this is not the actual physical device for
>>> the GPIO controller (e.g. the GPIO controller platform bus device).
>>>
>>> This mismatch is causing GPIO lookups by secondary fwnode to not work.
>>>
>>> Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
>>> of the first physical device associated with the ACPI companion device.
>>>
>>> This fixes the GPIO lookups not working.
>>
>> ...
>>
>>> static int gpio_secondary_fwnode_init(struct device *parent,
>>
>>> if (WARN_ON(!fwnode))
>>> return -ENOENT;
>>>
>>> - set_secondary_fwnode(dev, fwnode);
>>> + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
>>
>> It doesn't look like an auto cleaning pointer, so let's make a declaration
>> outside of the code?
>>
>>> + if (!phys_dev)
>>> + return dev_err_probe(parent,
>>> + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
>>> + (*swnode)->name);
>>
>> Hmm... Why not %pfwP?
>
> Hi Hans,
>
> I'm waiting for v2.
I see, thank you for quoting Andy's email since it never made the list (1),
nor did it reach me.
I'll prepare a v2 addressing Andy's remarks.
Regards,
Hans
1) If you go to:
https://lore.kernel.org/platform-driver-x86/20260831201157.36397-1-johannes.goede@oss.qualcomm.com/#r
it shows a "not found" <apcRAvoHkh9blDwK@black.igk.intel.com> entry, which it
only knows about because of this reply to it by you (Ilpo).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-09-08 17:51 ` Hans de Goede
@ 2026-09-08 19:04 ` Ilpo Järvinen
2026-09-09 14:11 ` Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2026-09-08 19:04 UTC (permalink / raw)
To: Hans de Goede
Cc: Andy Shevchenko, Dmitry Torokhov, Bartosz Golaszewski,
Linus Walleij, Rafael J . Wysocki, platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 2250 bytes --]
On Tue, 8 Sep 2026, Hans de Goede wrote:
> Hi Ilpo,
>
> On 3-Sep-26 13:54, Ilpo Järvinen wrote:
> > On Tue, 1 Sep 2026, Andy Shevchenko wrote:
> >
> >> On Mon, Aug 31, 2026 at 10:11:57PM +0200, Hans de Goede wrote:
> >>> acpi_bus_find_device_by_name() call returns a pointer to the device object
> >>> on the ACPI bus, aka the ACPI companion device.
> >>>
> >>> gpio_secondary_fwnode_init() then continues with setting the secondary
> >>> fwnode on this device. But this is not the actual physical device for
> >>> the GPIO controller (e.g. the GPIO controller platform bus device).
> >>>
> >>> This mismatch is causing GPIO lookups by secondary fwnode to not work.
> >>>
> >>> Modify gpio_secondary_fwnode_init() to instead set the secondary fwnode
> >>> of the first physical device associated with the ACPI companion device.
> >>>
> >>> This fixes the GPIO lookups not working.
> >>
> >> ...
> >>
> >>> static int gpio_secondary_fwnode_init(struct device *parent,
> >>
> >>> if (WARN_ON(!fwnode))
> >>> return -ENOENT;
> >>>
> >>> - set_secondary_fwnode(dev, fwnode);
> >>> + struct device *phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
> >>
> >> It doesn't look like an auto cleaning pointer, so let's make a declaration
> >> outside of the code?
> >>
> >>> + if (!phys_dev)
> >>> + return dev_err_probe(parent,
> >>> + -ENODEV, "No physical device for ACPI GPIO dev: %s\n",
> >>> + (*swnode)->name);
> >>
> >> Hmm... Why not %pfwP?
> >
> > Hi Hans,
> >
> > I'm waiting for v2.
>
> I see, thank you for quoting Andy's email since it never made the list (1),
> nor did it reach me.
>
> I'll prepare a v2 addressing Andy's remarks.
>
> Regards,
>
>
> Hans
>
>
> 1) If you go to:
>
> https://lore.kernel.org/platform-driver-x86/20260831201157.36397-1-johannes.goede@oss.qualcomm.com/#r
>
> it shows a "not found" <apcRAvoHkh9blDwK@black.igk.intel.com> entry, which it
> only knows about because of this reply to it by you (Ilpo).
Yeah, I noticed it didn't end up into patchwork either but figured you'd
see the content from my reply if the original had failed to reach you.
I've applied v2 now, thanks.
--
i.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working
2026-09-08 17:51 ` Hans de Goede
2026-09-08 19:04 ` Ilpo Järvinen
@ 2026-09-09 14:11 ` Andy Shevchenko
1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-09-09 14:11 UTC (permalink / raw)
To: Hans de Goede
Cc: Ilpo Järvinen, Andy Shevchenko, Dmitry Torokhov,
Bartosz Golaszewski, Linus Walleij, Rafael J . Wysocki,
platform-driver-x86
On Tue, Sep 08, 2026 at 07:51:55PM +0200, Hans de Goede wrote:
> On 3-Sep-26 13:54, Ilpo Järvinen wrote:
...
> I see, thank you for quoting Andy's email since it never made the list (1),
> nor did it reach me.
Oh, it was not intended to be not public. Thanks, Ilpo, for sharing the content.
> I'll prepare a v2 addressing Andy's remarks.
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-09 14:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 20:11 [PATCH] platform/x86: x86-android-tablets: fix gpio_secondary_fwnode_init() not working Hans de Goede
2026-08-31 20:22 ` Dmitry Torokhov
2026-08-31 20:28 ` Hans de Goede
2026-08-31 20:34 ` Dmitry Torokhov
[not found] ` <apcRAvoHkh9blDwK@black.igk.intel.com>
2026-09-03 11:54 ` Ilpo Järvinen
2026-09-08 17:51 ` Hans de Goede
2026-09-08 19:04 ` Ilpo Järvinen
2026-09-09 14:11 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.