]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: event: Redefine acpi_notifier_call_chain()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 12:59:17 +0000 (13:59 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 13 Mar 2026 15:48:24 +0000 (16:48 +0100)
Notice that acpi_notifier_call_chain() only uses its device argument
to retrieve the pnp.device_class and pnp.bus_id values from there, so
it can be redefined to take pointers to those two strings as parameters
istead of a struct acpi_device pointer.

That allows all of its callers to pass a string literal as its first
argument, so they won't need to initialize pnp.device_class in
struct acpi_device objects operated by them any more, and its
signature becomes more similar to acpi_bus_generate_netlink_event()
then.

Update the code as per the above.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2056097.PYKUYFuaPT@rafael.j.wysocki
drivers/acpi/ac.c
drivers/acpi/acpi_video.c
drivers/acpi/battery.c
drivers/acpi/event.c
include/acpi/acpi_bus.h

index 4985c88906096e8384fd89b82513a27b7c614bbc..2b500e89169f4f78db90b18ed78a7557b03977c5 100644 (file)
@@ -133,7 +133,8 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
                acpi_bus_generate_netlink_event(adev->pnp.device_class,
                                                  dev_name(&adev->dev), event,
                                                  (u32) ac->state);
-               acpi_notifier_call_chain(adev, event, (u32) ac->state);
+               acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev),
+                                        event, ac->state);
                power_supply_changed(ac->charger);
        }
 }
index 30822d46a71ea1318a65e35a13b096cb9dcb87f8..c747827653d96888a889550b0502fe2d013effd0 100644 (file)
@@ -1566,7 +1566,8 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
                break;
        }
 
-       if (acpi_notifier_call_chain(device, event, 0))
+       if (acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+                                    event, 0))
                /* Something vetoed the keypress. */
                keycode = 0;
 
@@ -1607,7 +1608,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
                if (video_device->backlight)
                        backlight_force_update(video_device->backlight,
                                               BACKLIGHT_UPDATE_HOTKEY);
-               acpi_notifier_call_chain(device, event, 0);
+               acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+                                        event, 0);
                return;
        }
 
@@ -1640,7 +1642,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
        if (keycode)
                may_report_brightness_keys = true;
 
-       acpi_notifier_call_chain(device, event, 0);
+       acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
+                                event, 0);
 
        if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) {
                input_report_key(input, keycode, 1);
index acf5dd2177a12a5d949f0b60b890e527300844e2..1bfc4179e88593780ea29d10e7bcd485801e225b 100644 (file)
@@ -1081,7 +1081,8 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
        acpi_bus_generate_netlink_event(device->pnp.device_class,
                                        dev_name(&device->dev), event,
                                        acpi_battery_present(battery));
-       acpi_notifier_call_chain(device, event, acpi_battery_present(battery));
+       acpi_notifier_call_chain(ACPI_BATTERY_CLASS, acpi_device_bid(device),
+                                event, acpi_battery_present(battery));
        /* acpi_battery_update could remove power_supply object */
        if (old && battery->bat)
                power_supply_changed(battery->bat);
index 96a9aaaaf9f705895f2ce40d80f3952ac231fee0..4d840d2e7b98b7ac9fcd41a5b232683f5f52d9d3 100644 (file)
 /* ACPI notifier chain */
 static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
 
-int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data)
+int acpi_notifier_call_chain(const char *device_class,
+                            const char *bus_id, u32 type, u32 data)
 {
        struct acpi_bus_event event;
 
-       strscpy(event.device_class, dev->pnp.device_class);
-       strscpy(event.bus_id, dev->pnp.bus_id);
+       strscpy(event.device_class, device_class);
+       strscpy(event.bus_id, bus_id);
        event.type = type;
        event.data = data;
        return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
index aad1a95e6863d443a45985ba7ec7be4acf8664fe..ff14c9362122f7b22fd398f295ffed12474396b7 100644 (file)
@@ -625,7 +625,8 @@ int acpi_dev_install_notify_handler(struct acpi_device *adev,
 void acpi_dev_remove_notify_handler(struct acpi_device *adev,
                                    u32 handler_type,
                                    acpi_notify_handler handler);
-extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
+extern int acpi_notifier_call_chain(const char *device_class,
+                                   const char *bus_id, u32 type, u32 data);
 extern int register_acpi_notifier(struct notifier_block *);
 extern int unregister_acpi_notifier(struct notifier_block *);