Skip to content

Commit 8d287e8

Browse files
committed
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: Rafael J. Wysocki <[email protected]>
1 parent 5f4ce26 commit 8d287e8

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

drivers/acpi/bus.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,8 @@ void __init acpi_subsystem_init(void)
12061206

12071207
static acpi_status acpi_bus_table_handler(u32 event, void *table, void *context)
12081208
{
1209-
acpi_scan_table_handler(event, table, context);
1209+
if (event == ACPI_TABLE_EVENT_LOAD)
1210+
acpi_scan_table_notify();
12101211

12111212
return acpi_sysfs_table_handler(event, table, context);
12121213
}

drivers/acpi/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src);
8888
bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
8989

9090
acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context);
91-
void acpi_scan_table_handler(u32 event, void *table, void *context);
91+
void acpi_scan_table_notify(void);
9292

9393
/* --------------------------------------------------------------------------
9494
Device Node Initialization / Removal

drivers/acpi/scan.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,46 +2533,28 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
25332533
return count;
25342534
}
25352535

2536-
struct acpi_table_events_work {
2537-
struct work_struct work;
2538-
void *table;
2539-
u32 event;
2540-
};
2541-
25422536
static void acpi_table_events_fn(struct work_struct *work)
25432537
{
2544-
struct acpi_table_events_work *tew;
2545-
2546-
tew = container_of(work, struct acpi_table_events_work, work);
2547-
2548-
if (tew->event == ACPI_TABLE_EVENT_LOAD) {
2549-
acpi_scan_lock_acquire();
2550-
acpi_bus_scan(ACPI_ROOT_OBJECT);
2551-
acpi_scan_lock_release();
2552-
}
2538+
acpi_scan_lock_acquire();
2539+
acpi_bus_scan(ACPI_ROOT_OBJECT);
2540+
acpi_scan_lock_release();
25532541

2554-
kfree(tew);
2542+
kfree(work);
25552543
}
25562544

2557-
void acpi_scan_table_handler(u32 event, void *table, void *context)
2545+
void acpi_scan_table_notify(void)
25582546
{
2559-
struct acpi_table_events_work *tew;
2547+
struct work_struct *work;
25602548

25612549
if (!acpi_scan_initialized)
25622550
return;
25632551

2564-
if (event != ACPI_TABLE_EVENT_LOAD)
2552+
work = kmalloc(sizeof(*work), GFP_KERNEL);
2553+
if (!work)
25652554
return;
25662555

2567-
tew = kmalloc(sizeof(*tew), GFP_KERNEL);
2568-
if (!tew)
2569-
return;
2570-
2571-
INIT_WORK(&tew->work, acpi_table_events_fn);
2572-
tew->table = table;
2573-
tew->event = event;
2574-
2575-
schedule_work(&tew->work);
2556+
INIT_WORK(work, acpi_table_events_fn);
2557+
schedule_work(work);
25762558
}
25772559

25782560
int acpi_reconfig_notifier_register(struct notifier_block *nb)

0 commit comments

Comments
 (0)