[PATCH v1 1/2] platform/x86: eeepc-laptop: Register ACPI notify handler directly

Rafael J. Wysocki posted 1 patch 1 month, 2 weeks ago
drivers/platform/x86/eeepc-laptop.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
[PATCH v1 1/2] platform/x86: eeepc-laptop: Register ACPI notify handler directly
Posted by Rafael J. Wysocki 1 month, 2 weeks ago
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

To facilitate subsequent conversion of the driver to a platform one,
make it install an ACPI notify handler directly instead of using
a .notify() callback in struct acpi_driver.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/platform/x86/eeepc-laptop.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 974f55e0b36f..626a99a71fce 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1204,9 +1204,10 @@ static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event)
 		pr_info("Unknown key %x pressed\n", event);
 }
 
-static void eeepc_acpi_notify(struct acpi_device *device, u32 event)
+static void eeepc_acpi_notify(acpi_handle handle, u32 event, void *data)
 {
-	struct eeepc_laptop *eeepc = acpi_driver_data(device);
+	struct eeepc_laptop *eeepc = data;
+	struct acpi_device *device = eeepc->device;
 	int old_brightness, new_brightness;
 	u16 count;
 
@@ -1422,9 +1423,16 @@ static int eeepc_acpi_add(struct acpi_device *device)
 	if (result)
 		goto fail_rfkill;
 
+	result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
+						 eeepc_acpi_notify, eeepc);
+	if (result)
+		goto fail_acpi_notifier;
+
 	eeepc_device_present = true;
 	return 0;
 
+fail_acpi_notifier:
+	eeepc_rfkill_exit(eeepc);
 fail_rfkill:
 	eeepc_led_exit(eeepc);
 fail_led:
@@ -1444,6 +1452,7 @@ static void eeepc_acpi_remove(struct acpi_device *device)
 {
 	struct eeepc_laptop *eeepc = acpi_driver_data(device);
 
+	acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY, eeepc_acpi_notify);
 	eeepc_backlight_exit(eeepc);
 	eeepc_rfkill_exit(eeepc);
 	eeepc_input_exit(eeepc);
@@ -1464,11 +1473,9 @@ static struct acpi_driver eeepc_acpi_driver = {
 	.name = EEEPC_LAPTOP_NAME,
 	.class = EEEPC_ACPI_CLASS,
 	.ids = eeepc_device_ids,
-	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
 	.ops = {
 		.add = eeepc_acpi_add,
 		.remove = eeepc_acpi_remove,
-		.notify = eeepc_acpi_notify,
 	},
 };
 
-- 
2.51.0
Re: [PATCH v1 1/2] platform/x86: eeepc-laptop: Register ACPI notify handler directly
Posted by Denis Benato 1 month, 2 weeks ago
On 2/28/26 16:22, Rafael J. Wysocki wrote:
> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>
> To facilitate subsequent conversion of the driver to a platform one,
> make it install an ACPI notify handler directly instead of using
> a .notify() callback in struct acpi_driver.
>
> No intentional functional impact.
Reviewed-by: Denis Benato <denis.benato@linux.dev>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/platform/x86/eeepc-laptop.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
> index 974f55e0b36f..626a99a71fce 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -1204,9 +1204,10 @@ static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event)
>  		pr_info("Unknown key %x pressed\n", event);
>  }
>  
> -static void eeepc_acpi_notify(struct acpi_device *device, u32 event)
> +static void eeepc_acpi_notify(acpi_handle handle, u32 event, void *data)
>  {
> -	struct eeepc_laptop *eeepc = acpi_driver_data(device);
> +	struct eeepc_laptop *eeepc = data;
> +	struct acpi_device *device = eeepc->device;
>  	int old_brightness, new_brightness;
>  	u16 count;
>  
> @@ -1422,9 +1423,16 @@ static int eeepc_acpi_add(struct acpi_device *device)
>  	if (result)
>  		goto fail_rfkill;
>  
> +	result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
> +						 eeepc_acpi_notify, eeepc);
> +	if (result)
> +		goto fail_acpi_notifier;
> +
>  	eeepc_device_present = true;
>  	return 0;
>  
> +fail_acpi_notifier:
> +	eeepc_rfkill_exit(eeepc);
>  fail_rfkill:
>  	eeepc_led_exit(eeepc);
>  fail_led:
> @@ -1444,6 +1452,7 @@ static void eeepc_acpi_remove(struct acpi_device *device)
>  {
>  	struct eeepc_laptop *eeepc = acpi_driver_data(device);
>  
> +	acpi_dev_remove_notify_handler(device, ACPI_ALL_NOTIFY, eeepc_acpi_notify);
>  	eeepc_backlight_exit(eeepc);
>  	eeepc_rfkill_exit(eeepc);
>  	eeepc_input_exit(eeepc);
> @@ -1464,11 +1473,9 @@ static struct acpi_driver eeepc_acpi_driver = {
>  	.name = EEEPC_LAPTOP_NAME,
>  	.class = EEEPC_ACPI_CLASS,
>  	.ids = eeepc_device_ids,
> -	.flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
>  	.ops = {
>  		.add = eeepc_acpi_add,
>  		.remove = eeepc_acpi_remove,
> -		.notify = eeepc_acpi_notify,
>  	},
>  };
>