Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: event: Redefine acpi_notifier_call_chain()

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

+16 -9
+2 -1
drivers/acpi/ac.c
··· 133 133 acpi_bus_generate_netlink_event(adev->pnp.device_class, 134 134 dev_name(&adev->dev), event, 135 135 (u32) ac->state); 136 - acpi_notifier_call_chain(adev, event, (u32) ac->state); 136 + acpi_notifier_call_chain(ACPI_AC_CLASS, acpi_device_bid(adev), 137 + event, ac->state); 137 138 power_supply_changed(ac->charger); 138 139 } 139 140 }
+6 -3
drivers/acpi/acpi_video.c
··· 1566 1566 break; 1567 1567 } 1568 1568 1569 - if (acpi_notifier_call_chain(device, event, 0)) 1569 + if (acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device), 1570 + event, 0)) 1570 1571 /* Something vetoed the keypress. */ 1571 1572 keycode = 0; 1572 1573 ··· 1608 1607 if (video_device->backlight) 1609 1608 backlight_force_update(video_device->backlight, 1610 1609 BACKLIGHT_UPDATE_HOTKEY); 1611 - acpi_notifier_call_chain(device, event, 0); 1610 + acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device), 1611 + event, 0); 1612 1612 return; 1613 1613 } 1614 1614 ··· 1642 1640 if (keycode) 1643 1641 may_report_brightness_keys = true; 1644 1642 1645 - acpi_notifier_call_chain(device, event, 0); 1643 + acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device), 1644 + event, 0); 1646 1645 1647 1646 if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) { 1648 1647 input_report_key(input, keycode, 1);
+2 -1
drivers/acpi/battery.c
··· 1081 1081 acpi_bus_generate_netlink_event(device->pnp.device_class, 1082 1082 dev_name(&device->dev), event, 1083 1083 acpi_battery_present(battery)); 1084 - acpi_notifier_call_chain(device, event, acpi_battery_present(battery)); 1084 + acpi_notifier_call_chain(ACPI_BATTERY_CLASS, acpi_device_bid(device), 1085 + event, acpi_battery_present(battery)); 1085 1086 /* acpi_battery_update could remove power_supply object */ 1086 1087 if (old && battery->bat) 1087 1088 power_supply_changed(battery->bat);
+4 -3
drivers/acpi/event.c
··· 24 24 /* ACPI notifier chain */ 25 25 static BLOCKING_NOTIFIER_HEAD(acpi_chain_head); 26 26 27 - int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) 27 + int acpi_notifier_call_chain(const char *device_class, 28 + const char *bus_id, u32 type, u32 data) 28 29 { 29 30 struct acpi_bus_event event; 30 31 31 - strscpy(event.device_class, dev->pnp.device_class); 32 - strscpy(event.bus_id, dev->pnp.bus_id); 32 + strscpy(event.device_class, device_class); 33 + strscpy(event.bus_id, bus_id); 33 34 event.type = type; 34 35 event.data = data; 35 36 return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)
+2 -1
include/acpi/acpi_bus.h
··· 625 625 void acpi_dev_remove_notify_handler(struct acpi_device *adev, 626 626 u32 handler_type, 627 627 acpi_notify_handler handler); 628 - extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32); 628 + extern int acpi_notifier_call_chain(const char *device_class, 629 + const char *bus_id, u32 type, u32 data); 629 630 extern int register_acpi_notifier(struct notifier_block *); 630 631 extern int unregister_acpi_notifier(struct notifier_block *); 631 632