Commit 8d287e82 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI: scan: Simplify acpi_table_events_fn()

Notice that the table field of struct acpi_table_events_work is never
read and its event field is always equal to ACPI_TABLE_EVENT_LOAD, so
both of them are redundant.

Accordingly, drop struct acpi_table_events_work and use struct
work_struct directly instead of it, simplify acpi_scan_table_handler()
and rename it to acpi_scan_table_notify().

Moreover, make acpi_bus_table_handler() check the event code against
ACPI_TABLE_EVENT_LOAD before calling acpi_scan_table_notify(), so it
is not necessary to do that check in the latter.

No intentional functional impact.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 5f4ce260
...@@ -1206,7 +1206,8 @@ void __init acpi_subsystem_init(void) ...@@ -1206,7 +1206,8 @@ void __init acpi_subsystem_init(void)
static acpi_status acpi_bus_table_handler(u32 event, void *table, void *context) static acpi_status acpi_bus_table_handler(u32 event, void *table, void *context)
{ {
acpi_scan_table_handler(event, table, context); if (event == ACPI_TABLE_EVENT_LOAD)
acpi_scan_table_notify();
return acpi_sysfs_table_handler(event, table, context); return acpi_sysfs_table_handler(event, table, context);
} }
......
...@@ -88,7 +88,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src); ...@@ -88,7 +88,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src);
bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context); acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
void acpi_scan_table_handler(u32 event, void *table, void *context); void acpi_scan_table_notify(void);
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Device Node Initialization / Removal Device Node Initialization / Removal
......
...@@ -2533,46 +2533,28 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr) ...@@ -2533,46 +2533,28 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
return count; return count;
} }
struct acpi_table_events_work {
struct work_struct work;
void *table;
u32 event;
};
static void acpi_table_events_fn(struct work_struct *work) static void acpi_table_events_fn(struct work_struct *work)
{ {
struct acpi_table_events_work *tew; acpi_scan_lock_acquire();
acpi_bus_scan(ACPI_ROOT_OBJECT);
tew = container_of(work, struct acpi_table_events_work, work); acpi_scan_lock_release();
if (tew->event == ACPI_TABLE_EVENT_LOAD) {
acpi_scan_lock_acquire();
acpi_bus_scan(ACPI_ROOT_OBJECT);
acpi_scan_lock_release();
}
kfree(tew); kfree(work);
} }
void acpi_scan_table_handler(u32 event, void *table, void *context) void acpi_scan_table_notify(void)
{ {
struct acpi_table_events_work *tew; struct work_struct *work;
if (!acpi_scan_initialized) if (!acpi_scan_initialized)
return; return;
if (event != ACPI_TABLE_EVENT_LOAD) work = kmalloc(sizeof(*work), GFP_KERNEL);
if (!work)
return; return;
tew = kmalloc(sizeof(*tew), GFP_KERNEL); INIT_WORK(work, acpi_table_events_fn);
if (!tew) schedule_work(work);
return;
INIT_WORK(&tew->work, acpi_table_events_fn);
tew->table = table;
tew->event = event;
schedule_work(&tew->work);
} }
int acpi_reconfig_notifier_register(struct notifier_block *nb) int acpi_reconfig_notifier_register(struct notifier_block *nb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment