Skip to content

Commit 69652f3

Browse files
committed
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
1 parent 97892d5 commit 69652f3

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

drivers/acpi/ac.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
133133
acpi_bus_generate_netlink_event(adev->pnp.device_class,
134134
dev_name(&adev->dev), event,
135135
(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);
137138
power_supply_changed(ac->charger);
138139
}
139140
}

drivers/acpi/acpi_video.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,8 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
15661566
break;
15671567
}
15681568

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))
15701571
/* Something vetoed the keypress. */
15711572
keycode = 0;
15721573

@@ -1607,7 +1608,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
16071608
if (video_device->backlight)
16081609
backlight_force_update(video_device->backlight,
16091610
BACKLIGHT_UPDATE_HOTKEY);
1610-
acpi_notifier_call_chain(device, event, 0);
1611+
acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
1612+
event, 0);
16111613
return;
16121614
}
16131615

@@ -1640,7 +1642,8 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
16401642
if (keycode)
16411643
may_report_brightness_keys = true;
16421644

1643-
acpi_notifier_call_chain(device, event, 0);
1645+
acpi_notifier_call_chain(ACPI_VIDEO_CLASS, acpi_device_bid(device),
1646+
event, 0);
16441647

16451648
if (keycode && (report_key_events & REPORT_BRIGHTNESS_KEY_EVENTS)) {
16461649
input_report_key(input, keycode, 1);

drivers/acpi/battery.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,8 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10811081
acpi_bus_generate_netlink_event(device->pnp.device_class,
10821082
dev_name(&device->dev), event,
10831083
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));
10851086
/* acpi_battery_update could remove power_supply object */
10861087
if (old && battery->bat)
10871088
power_supply_changed(battery->bat);

drivers/acpi/event.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
/* ACPI notifier chain */
2525
static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
2626

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)
2829
{
2930
struct acpi_bus_event event;
3031

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);
3334
event.type = type;
3435
event.data = data;
3536
return (blocking_notifier_call_chain(&acpi_chain_head, 0, (void *)&event)

include/acpi/acpi_bus.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ int acpi_dev_install_notify_handler(struct acpi_device *adev,
625625
void acpi_dev_remove_notify_handler(struct acpi_device *adev,
626626
u32 handler_type,
627627
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);
629630
extern int register_acpi_notifier(struct notifier_block *);
630631
extern int unregister_acpi_notifier(struct notifier_block *);
631632

0 commit comments

Comments
 (0)