drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-)
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
In all cases in which a struct acpi_driver is used for binding a driver
to an ACPI device object, a corresponding platform device is created by
the ACPI core and that device is regarded as a proper representation of
underlying hardware. Accordingly, a struct platform_driver should be
used by driver code to bind to that device. There are multiple reasons
why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their
ACPI companions, so convert the Asus laptop ACPI driver to a platform
one.
While this is not expected to alter functionality, it changes sysfs
layout and so it will be visible to user space.
Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index c927665dfa96..dbbb6292cd11 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
static bool asus_device_present;
-static int asus_acpi_add(struct acpi_device *device)
+static int asus_acpi_probe(struct platform_device *pdev)
{
+ struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct asus_laptop *asus;
int result;
@@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
asus->handle = device->handle;
strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
- device->driver_data = asus;
asus->device = device;
asus_dmi_check();
@@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
if (result)
goto fail_platform;
+ platform_set_drvdata(pdev, asus);
+
/*
* Need platform type detection first, then the platform
* device. It is used as a parent for the sub-devices below.
@@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
return result;
}
-static void asus_acpi_remove(struct acpi_device *device)
+static void asus_acpi_remove(struct platform_device *pdev)
{
- struct asus_laptop *asus = acpi_driver_data(device);
+ struct asus_laptop *asus = platform_get_drvdata(pdev);
- acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
+ acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
+ asus_acpi_notify);
asus_backlight_exit(asus);
asus_rfkill_exit(asus);
asus_led_exit(asus);
@@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
};
MODULE_DEVICE_TABLE(acpi, asus_device_ids);
-static struct acpi_driver asus_acpi_driver = {
- .name = ASUS_LAPTOP_NAME,
- .class = ASUS_LAPTOP_CLASS,
- .ids = asus_device_ids,
- .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
- .ops = {
- .add = asus_acpi_add,
- .remove = asus_acpi_remove,
- },
+static struct platform_driver asus_acpi_driver = {
+ .probe = asus_acpi_probe,
+ .remove = asus_acpi_remove,
+ .driver = {
+ .name = ASUS_LAPTOP_NAME,
+ .acpi_match_table = asus_device_ids,
+ },
};
static int __init asus_laptop_init(void)
@@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
if (result < 0)
return result;
- result = acpi_bus_register_driver(&asus_acpi_driver);
+ result = platform_driver_register(&asus_acpi_driver);
if (result < 0)
goto fail_acpi_driver;
if (!asus_device_present) {
@@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
return 0;
fail_no_device:
- acpi_bus_unregister_driver(&asus_acpi_driver);
+ platform_driver_unregister(&asus_acpi_driver);
fail_acpi_driver:
platform_driver_unregister(&platform_driver);
return result;
@@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
static void __exit asus_laptop_exit(void)
{
- acpi_bus_unregister_driver(&asus_acpi_driver);
+ platform_driver_unregister(&asus_acpi_driver);
platform_driver_unregister(&platform_driver);
}
--
2.51.0
On 2/28/26 16:11, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> In all cases in which a struct acpi_driver is used for binding a driver
> to an ACPI device object, a corresponding platform device is created by
> the ACPI core and that device is regarded as a proper representation of
> underlying hardware. Accordingly, a struct platform_driver should be
> used by driver code to bind to that device. There are multiple reasons
> why drivers should not bind directly to ACPI device objects [1].
>
> Overall, it is better to bind drivers to platform devices than to their
> ACPI companions, so convert the Asus laptop ACPI driver to a platform
> one.
>
> While this is not expected to alter functionality, it changes sysfs
> layout and so it will be visible to user space.
Alright I will take a look if asus-linux software is affected and act accordingly.
How much time do I have?
Thanks.
> Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Denis Benato <denis.benato@linux.dev>
> ---
> drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
> 1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index c927665dfa96..dbbb6292cd11 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
>
> static bool asus_device_present;
>
> -static int asus_acpi_add(struct acpi_device *device)
> +static int asus_acpi_probe(struct platform_device *pdev)
> {
> + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> struct asus_laptop *asus;
> int result;
>
> @@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
> asus->handle = device->handle;
> strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> - device->driver_data = asus;
> asus->device = device;
>
> asus_dmi_check();
> @@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
> if (result)
> goto fail_platform;
>
> + platform_set_drvdata(pdev, asus);
> +
> /*
> * Need platform type detection first, then the platform
> * device. It is used as a parent for the sub-devices below.
> @@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
> return result;
> }
>
> -static void asus_acpi_remove(struct acpi_device *device)
> +static void asus_acpi_remove(struct platform_device *pdev)
> {
> - struct asus_laptop *asus = acpi_driver_data(device);
> + struct asus_laptop *asus = platform_get_drvdata(pdev);
>
> - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
> + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
> + asus_acpi_notify);
> asus_backlight_exit(asus);
> asus_rfkill_exit(asus);
> asus_led_exit(asus);
> @@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
> };
> MODULE_DEVICE_TABLE(acpi, asus_device_ids);
>
> -static struct acpi_driver asus_acpi_driver = {
> - .name = ASUS_LAPTOP_NAME,
> - .class = ASUS_LAPTOP_CLASS,
> - .ids = asus_device_ids,
> - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
> - .ops = {
> - .add = asus_acpi_add,
> - .remove = asus_acpi_remove,
> - },
> +static struct platform_driver asus_acpi_driver = {
> + .probe = asus_acpi_probe,
> + .remove = asus_acpi_remove,
> + .driver = {
> + .name = ASUS_LAPTOP_NAME,
> + .acpi_match_table = asus_device_ids,
> + },
> };
>
> static int __init asus_laptop_init(void)
> @@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
> if (result < 0)
> return result;
>
> - result = acpi_bus_register_driver(&asus_acpi_driver);
> + result = platform_driver_register(&asus_acpi_driver);
> if (result < 0)
> goto fail_acpi_driver;
> if (!asus_device_present) {
> @@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
> return 0;
>
> fail_no_device:
> - acpi_bus_unregister_driver(&asus_acpi_driver);
> + platform_driver_unregister(&asus_acpi_driver);
> fail_acpi_driver:
> platform_driver_unregister(&platform_driver);
> return result;
> @@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
>
> static void __exit asus_laptop_exit(void)
> {
> - acpi_bus_unregister_driver(&asus_acpi_driver);
> + platform_driver_unregister(&asus_acpi_driver);
> platform_driver_unregister(&platform_driver);
> }
>
On Sat, 28 Feb 2026, Denis Benato wrote:
> On 2/28/26 16:11, Rafael J. Wysocki wrote:
> > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> >
> > In all cases in which a struct acpi_driver is used for binding a driver
> > to an ACPI device object, a corresponding platform device is created by
> > the ACPI core and that device is regarded as a proper representation of
> > underlying hardware. Accordingly, a struct platform_driver should be
> > used by driver code to bind to that device. There are multiple reasons
> > why drivers should not bind directly to ACPI device objects [1].
> >
> > Overall, it is better to bind drivers to platform devices than to their
> > ACPI companions, so convert the Asus laptop ACPI driver to a platform
> > one.
> >
> > While this is not expected to alter functionality, it changes sysfs
> > layout and so it will be visible to user space.
>
> Alright I will take a look if asus-linux software is affected and act accordingly.
> How much time do I have?
>
> Thanks.
Hi Denis,
Has there been some progress with this check?
--
i.
> > Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Denis Benato <denis.benato@linux.dev>
> > ---
> > drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
> > 1 file changed, 18 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> > index c927665dfa96..dbbb6292cd11 100644
> > --- a/drivers/platform/x86/asus-laptop.c
> > +++ b/drivers/platform/x86/asus-laptop.c
> > @@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
> >
> > static bool asus_device_present;
> >
> > -static int asus_acpi_add(struct acpi_device *device)
> > +static int asus_acpi_probe(struct platform_device *pdev)
> > {
> > + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> > struct asus_laptop *asus;
> > int result;
> >
> > @@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
> > asus->handle = device->handle;
> > strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> > strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> > - device->driver_data = asus;
> > asus->device = device;
> >
> > asus_dmi_check();
> > @@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
> > if (result)
> > goto fail_platform;
> >
> > + platform_set_drvdata(pdev, asus);
> > +
> > /*
> > * Need platform type detection first, then the platform
> > * device. It is used as a parent for the sub-devices below.
> > @@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
> > return result;
> > }
> >
> > -static void asus_acpi_remove(struct acpi_device *device)
> > +static void asus_acpi_remove(struct platform_device *pdev)
> > {
> > - struct asus_laptop *asus = acpi_driver_data(device);
> > + struct asus_laptop *asus = platform_get_drvdata(pdev);
> >
> > - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
> > + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
> > + asus_acpi_notify);
> > asus_backlight_exit(asus);
> > asus_rfkill_exit(asus);
> > asus_led_exit(asus);
> > @@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
> > };
> > MODULE_DEVICE_TABLE(acpi, asus_device_ids);
> >
> > -static struct acpi_driver asus_acpi_driver = {
> > - .name = ASUS_LAPTOP_NAME,
> > - .class = ASUS_LAPTOP_CLASS,
> > - .ids = asus_device_ids,
> > - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
> > - .ops = {
> > - .add = asus_acpi_add,
> > - .remove = asus_acpi_remove,
> > - },
> > +static struct platform_driver asus_acpi_driver = {
> > + .probe = asus_acpi_probe,
> > + .remove = asus_acpi_remove,
> > + .driver = {
> > + .name = ASUS_LAPTOP_NAME,
> > + .acpi_match_table = asus_device_ids,
> > + },
> > };
> >
> > static int __init asus_laptop_init(void)
> > @@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
> > if (result < 0)
> > return result;
> >
> > - result = acpi_bus_register_driver(&asus_acpi_driver);
> > + result = platform_driver_register(&asus_acpi_driver);
> > if (result < 0)
> > goto fail_acpi_driver;
> > if (!asus_device_present) {
> > @@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
> > return 0;
> >
> > fail_no_device:
> > - acpi_bus_unregister_driver(&asus_acpi_driver);
> > + platform_driver_unregister(&asus_acpi_driver);
> > fail_acpi_driver:
> > platform_driver_unregister(&platform_driver);
> > return result;
> > @@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
> >
> > static void __exit asus_laptop_exit(void)
> > {
> > - acpi_bus_unregister_driver(&asus_acpi_driver);
> > + platform_driver_unregister(&asus_acpi_driver);
> > platform_driver_unregister(&platform_driver);
> > }
> >
>
On 3/31/26 10:14, Ilpo Järvinen wrote:
> On Sat, 28 Feb 2026, Denis Benato wrote:
>> On 2/28/26 16:11, Rafael J. Wysocki wrote:
>>> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>>>
>>> In all cases in which a struct acpi_driver is used for binding a driver
>>> to an ACPI device object, a corresponding platform device is created by
>>> the ACPI core and that device is regarded as a proper representation of
>>> underlying hardware. Accordingly, a struct platform_driver should be
>>> used by driver code to bind to that device. There are multiple reasons
>>> why drivers should not bind directly to ACPI device objects [1].
>>>
>>> Overall, it is better to bind drivers to platform devices than to their
>>> ACPI companions, so convert the Asus laptop ACPI driver to a platform
>>> one.
>>>
>>> While this is not expected to alter functionality, it changes sysfs
>>> layout and so it will be visible to user space.
>> Alright I will take a look if asus-linux software is affected and act accordingly.
>> How much time do I have?
>>
>> Thanks.
> Hi Denis,
>
> Has there been some progress with this check?
Hi!
I quickly looked at it and I think there shouldn't be any problem.
Worst case scenario I update the criteria udev uses to find certain
things but it shouldn't be necessary (or at least I can't find a problematic spot).
Thanks,
Denis
> --
> i.
>
>>> Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
>>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> Reviewed-by: Denis Benato <denis.benato@linux.dev>
>>> ---
>>> drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
>>> 1 file changed, 18 insertions(+), 17 deletions(-)
>>>
>>> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
>>> index c927665dfa96..dbbb6292cd11 100644
>>> --- a/drivers/platform/x86/asus-laptop.c
>>> +++ b/drivers/platform/x86/asus-laptop.c
>>> @@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
>>>
>>> static bool asus_device_present;
>>>
>>> -static int asus_acpi_add(struct acpi_device *device)
>>> +static int asus_acpi_probe(struct platform_device *pdev)
>>> {
>>> + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
>>> struct asus_laptop *asus;
>>> int result;
>>>
>>> @@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
>>> asus->handle = device->handle;
>>> strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
>>> strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
>>> - device->driver_data = asus;
>>> asus->device = device;
>>>
>>> asus_dmi_check();
>>> @@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
>>> if (result)
>>> goto fail_platform;
>>>
>>> + platform_set_drvdata(pdev, asus);
>>> +
>>> /*
>>> * Need platform type detection first, then the platform
>>> * device. It is used as a parent for the sub-devices below.
>>> @@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
>>> return result;
>>> }
>>>
>>> -static void asus_acpi_remove(struct acpi_device *device)
>>> +static void asus_acpi_remove(struct platform_device *pdev)
>>> {
>>> - struct asus_laptop *asus = acpi_driver_data(device);
>>> + struct asus_laptop *asus = platform_get_drvdata(pdev);
>>>
>>> - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
>>> + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
>>> + asus_acpi_notify);
>>> asus_backlight_exit(asus);
>>> asus_rfkill_exit(asus);
>>> asus_led_exit(asus);
>>> @@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
>>> };
>>> MODULE_DEVICE_TABLE(acpi, asus_device_ids);
>>>
>>> -static struct acpi_driver asus_acpi_driver = {
>>> - .name = ASUS_LAPTOP_NAME,
>>> - .class = ASUS_LAPTOP_CLASS,
>>> - .ids = asus_device_ids,
>>> - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
>>> - .ops = {
>>> - .add = asus_acpi_add,
>>> - .remove = asus_acpi_remove,
>>> - },
>>> +static struct platform_driver asus_acpi_driver = {
>>> + .probe = asus_acpi_probe,
>>> + .remove = asus_acpi_remove,
>>> + .driver = {
>>> + .name = ASUS_LAPTOP_NAME,
>>> + .acpi_match_table = asus_device_ids,
>>> + },
>>> };
>>>
>>> static int __init asus_laptop_init(void)
>>> @@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
>>> if (result < 0)
>>> return result;
>>>
>>> - result = acpi_bus_register_driver(&asus_acpi_driver);
>>> + result = platform_driver_register(&asus_acpi_driver);
>>> if (result < 0)
>>> goto fail_acpi_driver;
>>> if (!asus_device_present) {
>>> @@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
>>> return 0;
>>>
>>> fail_no_device:
>>> - acpi_bus_unregister_driver(&asus_acpi_driver);
>>> + platform_driver_unregister(&asus_acpi_driver);
>>> fail_acpi_driver:
>>> platform_driver_unregister(&platform_driver);
>>> return result;
>>> @@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
>>>
>>> static void __exit asus_laptop_exit(void)
>>> {
>>> - acpi_bus_unregister_driver(&asus_acpi_driver);
>>> + platform_driver_unregister(&asus_acpi_driver);
>>> platform_driver_unregister(&platform_driver);
>>> }
>>>
On Sat, 28 Feb 2026, Denis Benato wrote: > On 2/28/26 16:11, Rafael J. Wysocki wrote: > > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> > > > > In all cases in which a struct acpi_driver is used for binding a driver > > to an ACPI device object, a corresponding platform device is created by > > the ACPI core and that device is regarded as a proper representation of > > underlying hardware. Accordingly, a struct platform_driver should be > > used by driver code to bind to that device. There are multiple reasons > > why drivers should not bind directly to ACPI device objects [1]. > > > > Overall, it is better to bind drivers to platform devices than to their > > ACPI companions, so convert the Asus laptop ACPI driver to a platform > > one. > > > > While this is not expected to alter functionality, it changes sysfs > > layout and so it will be visible to user space. > > Alright I will take a look if asus-linux software is affected and act accordingly. > How much time do I have? Please take your time, we don't need to rush things, especially refactoring when there are open questions to answer. > Thanks. > > Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1] > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > Reviewed-by: Denis Benato <denis.benato@linux.dev> -- i.
On Sat, Feb 28, 2026 at 6:02 PM Denis Benato <denis.benato@linux.dev> wrote:
>
>
> On 2/28/26 16:11, Rafael J. Wysocki wrote:
> > From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> >
> > In all cases in which a struct acpi_driver is used for binding a driver
> > to an ACPI device object, a corresponding platform device is created by
> > the ACPI core and that device is regarded as a proper representation of
> > underlying hardware. Accordingly, a struct platform_driver should be
> > used by driver code to bind to that device. There are multiple reasons
> > why drivers should not bind directly to ACPI device objects [1].
> >
> > Overall, it is better to bind drivers to platform devices than to their
> > ACPI companions, so convert the Asus laptop ACPI driver to a platform
> > one.
> >
> > While this is not expected to alter functionality, it changes sysfs
> > layout and so it will be visible to user space.
>
> Alright I will take a look if asus-linux software is affected and act accordingly.
> How much time do I have?
It really depends on Ilpo, but there's no rush as far as I'm concerned.
> Thanks.
> > Link: https://lore.kernel.org/all/2396510.ElGaqSPkdT@rafael.j.wysocki/ [1]
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Reviewed-by: Denis Benato <denis.benato@linux.dev>
Thanks for all of the reviews!
> > ---
> > drivers/platform/x86/asus-laptop.c | 35 +++++++++++++++---------------
> > 1 file changed, 18 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> > index c927665dfa96..dbbb6292cd11 100644
> > --- a/drivers/platform/x86/asus-laptop.c
> > +++ b/drivers/platform/x86/asus-laptop.c
> > @@ -1824,8 +1824,9 @@ static void asus_dmi_check(void)
> >
> > static bool asus_device_present;
> >
> > -static int asus_acpi_add(struct acpi_device *device)
> > +static int asus_acpi_probe(struct platform_device *pdev)
> > {
> > + struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
> > struct asus_laptop *asus;
> > int result;
> >
> > @@ -1837,7 +1838,6 @@ static int asus_acpi_add(struct acpi_device *device)
> > asus->handle = device->handle;
> > strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> > strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> > - device->driver_data = asus;
> > asus->device = device;
> >
> > asus_dmi_check();
> > @@ -1846,6 +1846,8 @@ static int asus_acpi_add(struct acpi_device *device)
> > if (result)
> > goto fail_platform;
> >
> > + platform_set_drvdata(pdev, asus);
> > +
> > /*
> > * Need platform type detection first, then the platform
> > * device. It is used as a parent for the sub-devices below.
> > @@ -1907,11 +1909,12 @@ static int asus_acpi_add(struct acpi_device *device)
> > return result;
> > }
> >
> > -static void asus_acpi_remove(struct acpi_device *device)
> > +static void asus_acpi_remove(struct platform_device *pdev)
> > {
> > - struct asus_laptop *asus = acpi_driver_data(device);
> > + struct asus_laptop *asus = platform_get_drvdata(pdev);
> >
> > - acpi_dev_remove_notify_handler(device, ACPI_DEVICE_NOTIFY, asus_acpi_notify);
> > + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
> > + asus_acpi_notify);
> > asus_backlight_exit(asus);
> > asus_rfkill_exit(asus);
> > asus_led_exit(asus);
> > @@ -1930,15 +1933,13 @@ static const struct acpi_device_id asus_device_ids[] = {
> > };
> > MODULE_DEVICE_TABLE(acpi, asus_device_ids);
> >
> > -static struct acpi_driver asus_acpi_driver = {
> > - .name = ASUS_LAPTOP_NAME,
> > - .class = ASUS_LAPTOP_CLASS,
> > - .ids = asus_device_ids,
> > - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
> > - .ops = {
> > - .add = asus_acpi_add,
> > - .remove = asus_acpi_remove,
> > - },
> > +static struct platform_driver asus_acpi_driver = {
> > + .probe = asus_acpi_probe,
> > + .remove = asus_acpi_remove,
> > + .driver = {
> > + .name = ASUS_LAPTOP_NAME,
> > + .acpi_match_table = asus_device_ids,
> > + },
> > };
> >
> > static int __init asus_laptop_init(void)
> > @@ -1949,7 +1950,7 @@ static int __init asus_laptop_init(void)
> > if (result < 0)
> > return result;
> >
> > - result = acpi_bus_register_driver(&asus_acpi_driver);
> > + result = platform_driver_register(&asus_acpi_driver);
> > if (result < 0)
> > goto fail_acpi_driver;
> > if (!asus_device_present) {
> > @@ -1959,7 +1960,7 @@ static int __init asus_laptop_init(void)
> > return 0;
> >
> > fail_no_device:
> > - acpi_bus_unregister_driver(&asus_acpi_driver);
> > + platform_driver_unregister(&asus_acpi_driver);
> > fail_acpi_driver:
> > platform_driver_unregister(&platform_driver);
> > return result;
> > @@ -1967,7 +1968,7 @@ static int __init asus_laptop_init(void)
> >
> > static void __exit asus_laptop_exit(void)
> > {
> > - acpi_bus_unregister_driver(&asus_acpi_driver);
> > + platform_driver_unregister(&asus_acpi_driver);
> > platform_driver_unregister(&platform_driver);
> > }
> >
© 2016 - 2026 Red Hat, Inc.