diff options
Diffstat (limited to 'drivers/acpi')
49 files changed, 569 insertions, 675 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 8711e3797165..e7515aa43d6b 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -32,8 +32,7 @@ | |||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <linux/power_supply.h> | 34 | #include <linux/power_supply.h> |
35 | #include <acpi/acpi_bus.h> | 35 | #include <linux/acpi.h> |
36 | #include <acpi/acpi_drivers.h> | ||
37 | 36 | ||
38 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
39 | 38 | ||
@@ -207,7 +206,7 @@ static int acpi_ac_probe(struct platform_device *pdev) | |||
207 | goto end; | 206 | goto end; |
208 | 207 | ||
209 | result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), | 208 | result = acpi_install_notify_handler(ACPI_HANDLE(&pdev->dev), |
210 | ACPI_DEVICE_NOTIFY, acpi_ac_notify_handler, ac); | 209 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler, ac); |
211 | if (result) { | 210 | if (result) { |
212 | power_supply_unregister(&ac->charger); | 211 | power_supply_unregister(&ac->charger); |
213 | goto end; | 212 | goto end; |
@@ -255,7 +254,7 @@ static int acpi_ac_remove(struct platform_device *pdev) | |||
255 | return -EINVAL; | 254 | return -EINVAL; |
256 | 255 | ||
257 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), | 256 | acpi_remove_notify_handler(ACPI_HANDLE(&pdev->dev), |
258 | ACPI_DEVICE_NOTIFY, acpi_ac_notify_handler); | 257 | ACPI_ALL_NOTIFY, acpi_ac_notify_handler); |
259 | 258 | ||
260 | ac = platform_get_drvdata(pdev); | 259 | ac = platform_get_drvdata(pdev); |
261 | if (ac->charger.dev) | 260 | if (ac->charger.dev) |
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index a6869e110ce5..2635a01c5b3e 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/acpi.h> | 11 | #include <linux/acpi.h> |
12 | #include <acpi/acpi_bus.h> | ||
13 | #include <linux/cper.h> | 12 | #include <linux/cper.h> |
14 | #include <linux/ratelimit.h> | 13 | #include <linux/ratelimit.h> |
15 | #include <asm/cpu.h> | 14 | #include <asm/cpu.h> |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 551dad712ffe..9aeacdfca410 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info) | |||
180 | 180 | ||
181 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) | 181 | static int acpi_bind_memblk(struct memory_block *mem, void *arg) |
182 | { | 182 | { |
183 | return acpi_bind_one(&mem->dev, (acpi_handle)arg); | 183 | return acpi_bind_one(&mem->dev, arg); |
184 | } | 184 | } |
185 | 185 | ||
186 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, | 186 | static int acpi_bind_memory_blocks(struct acpi_memory_info *info, |
187 | acpi_handle handle) | 187 | struct acpi_device *adev) |
188 | { | 188 | { |
189 | return walk_memory_range(acpi_meminfo_start_pfn(info), | 189 | return walk_memory_range(acpi_meminfo_start_pfn(info), |
190 | acpi_meminfo_end_pfn(info), (void *)handle, | 190 | acpi_meminfo_end_pfn(info), adev, |
191 | acpi_bind_memblk); | 191 | acpi_bind_memblk); |
192 | } | 192 | } |
193 | 193 | ||
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg) | |||
197 | return 0; | 197 | return 0; |
198 | } | 198 | } |
199 | 199 | ||
200 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info, | 200 | static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) |
201 | acpi_handle handle) | ||
202 | { | 201 | { |
203 | walk_memory_range(acpi_meminfo_start_pfn(info), | 202 | walk_memory_range(acpi_meminfo_start_pfn(info), |
204 | acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); | 203 | acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); |
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) | |||
242 | if (result && result != -EEXIST) | 241 | if (result && result != -EEXIST) |
243 | continue; | 242 | continue; |
244 | 243 | ||
245 | result = acpi_bind_memory_blocks(info, handle); | 244 | result = acpi_bind_memory_blocks(info, mem_device->device); |
246 | if (result) { | 245 | if (result) { |
247 | acpi_unbind_memory_blocks(info, handle); | 246 | acpi_unbind_memory_blocks(info); |
248 | return -ENODEV; | 247 | return -ENODEV; |
249 | } | 248 | } |
250 | 249 | ||
@@ -285,7 +284,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) | |||
285 | if (nid == NUMA_NO_NODE) | 284 | if (nid == NUMA_NO_NODE) |
286 | nid = memory_add_physaddr_to_nid(info->start_addr); | 285 | nid = memory_add_physaddr_to_nid(info->start_addr); |
287 | 286 | ||
288 | acpi_unbind_memory_blocks(info, handle); | 287 | acpi_unbind_memory_blocks(info); |
289 | remove_memory(nid, info->start_addr, info->length); | 288 | remove_memory(nid, info->start_addr, info->length); |
290 | list_del(&info->list); | 289 | list_del(&info->list); |
291 | kfree(info); | 290 | kfree(info); |
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index fc6008fbce35..65610c0e7243 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c | |||
@@ -28,8 +28,7 @@ | |||
28 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
29 | #include <linux/clockchips.h> | 29 | #include <linux/clockchips.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <acpi/acpi_bus.h> | 31 | #include <linux/acpi.h> |
32 | #include <acpi/acpi_drivers.h> | ||
33 | #include <asm/mwait.h> | 32 | #include <asm/mwait.h> |
34 | 33 | ||
35 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" | 34 | #define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad" |
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 3c1d6b0c09a4..d58a2aba0930 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c | |||
@@ -395,7 +395,7 @@ static int acpi_processor_add(struct acpi_device *device, | |||
395 | goto err; | 395 | goto err; |
396 | } | 396 | } |
397 | 397 | ||
398 | result = acpi_bind_one(dev, pr->handle); | 398 | result = acpi_bind_one(dev, device); |
399 | if (result) | 399 | if (result) |
400 | goto err; | 400 | goto err; |
401 | 401 | ||
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c index 6d2c49b86b7f..0760b75f79cc 100644 --- a/drivers/acpi/apei/apei-base.c +++ b/drivers/acpi/apei/apei-base.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <linux/module.h> | 34 | #include <linux/module.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/acpi_io.h> | ||
38 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
39 | #include <linux/io.h> | 38 | #include <linux/io.h> |
40 | #include <linux/kref.h> | 39 | #include <linux/kref.h> |
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h index 21ba34a73883..e5bcd919d4e6 100644 --- a/drivers/acpi/apei/apei-internal.h +++ b/drivers/acpi/apei/apei-internal.h | |||
@@ -8,7 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/cper.h> | 9 | #include <linux/cper.h> |
10 | #include <linux/acpi.h> | 10 | #include <linux/acpi.h> |
11 | #include <linux/acpi_io.h> | ||
12 | 11 | ||
13 | struct apei_exec_context; | 12 | struct apei_exec_context; |
14 | 13 | ||
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index fb57d03e698b..ca0c6d7ec0d4 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/nmi.h> | 33 | #include <linux/nmi.h> |
34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
35 | #include <linux/mm.h> | 35 | #include <linux/mm.h> |
36 | #include <acpi/acpi.h> | ||
37 | 36 | ||
38 | #include "apei-internal.h" | 37 | #include "apei-internal.h" |
39 | 38 | ||
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index a30bc313787b..694c486a12ed 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/acpi.h> | 35 | #include <linux/acpi.h> |
36 | #include <linux/acpi_io.h> | ||
37 | #include <linux/io.h> | 36 | #include <linux/io.h> |
38 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
39 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index fbf1aceda8b8..470e7542bf31 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -36,8 +36,7 @@ | |||
36 | #include <linux/suspend.h> | 36 | #include <linux/suspend.h> |
37 | #include <asm/unaligned.h> | 37 | #include <asm/unaligned.h> |
38 | 38 | ||
39 | #include <acpi/acpi_bus.h> | 39 | #include <linux/acpi.h> |
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <linux/power_supply.h> | 40 | #include <linux/power_supply.h> |
42 | 41 | ||
43 | #define PREFIX "ACPI: " | 42 | #define PREFIX "ACPI: " |
@@ -62,6 +61,7 @@ MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>"); | |||
62 | MODULE_DESCRIPTION("ACPI Battery Driver"); | 61 | MODULE_DESCRIPTION("ACPI Battery Driver"); |
63 | MODULE_LICENSE("GPL"); | 62 | MODULE_LICENSE("GPL"); |
64 | 63 | ||
64 | static int battery_bix_broken_package; | ||
65 | static unsigned int cache_time = 1000; | 65 | static unsigned int cache_time = 1000; |
66 | module_param(cache_time, uint, 0644); | 66 | module_param(cache_time, uint, 0644); |
67 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); | 67 | MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); |
@@ -416,7 +416,12 @@ static int acpi_battery_get_info(struct acpi_battery *battery) | |||
416 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); | 416 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating %s", name)); |
417 | return -ENODEV; | 417 | return -ENODEV; |
418 | } | 418 | } |
419 | if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | 419 | |
420 | if (battery_bix_broken_package) | ||
421 | result = extract_package(battery, buffer.pointer, | ||
422 | extended_info_offsets + 1, | ||
423 | ARRAY_SIZE(extended_info_offsets) - 1); | ||
424 | else if (test_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags)) | ||
420 | result = extract_package(battery, buffer.pointer, | 425 | result = extract_package(battery, buffer.pointer, |
421 | extended_info_offsets, | 426 | extended_info_offsets, |
422 | ARRAY_SIZE(extended_info_offsets)); | 427 | ARRAY_SIZE(extended_info_offsets)); |
@@ -754,6 +759,17 @@ static int battery_notify(struct notifier_block *nb, | |||
754 | return 0; | 759 | return 0; |
755 | } | 760 | } |
756 | 761 | ||
762 | static struct dmi_system_id bat_dmi_table[] = { | ||
763 | { | ||
764 | .ident = "NEC LZ750/LS", | ||
765 | .matches = { | ||
766 | DMI_MATCH(DMI_SYS_VENDOR, "NEC"), | ||
767 | DMI_MATCH(DMI_PRODUCT_NAME, "PC-LZ750LS"), | ||
768 | }, | ||
769 | }, | ||
770 | {}, | ||
771 | }; | ||
772 | |||
757 | static int acpi_battery_add(struct acpi_device *device) | 773 | static int acpi_battery_add(struct acpi_device *device) |
758 | { | 774 | { |
759 | int result = 0; | 775 | int result = 0; |
@@ -846,6 +862,9 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) | |||
846 | { | 862 | { |
847 | if (acpi_disabled) | 863 | if (acpi_disabled) |
848 | return; | 864 | return; |
865 | |||
866 | if (dmi_check_system(bat_dmi_table)) | ||
867 | battery_bix_broken_package = 1; | ||
849 | acpi_bus_register_driver(&acpi_battery_driver); | 868 | acpi_bus_register_driver(&acpi_battery_driver); |
850 | } | 869 | } |
851 | 870 | ||
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c index 078c4f7fe2dd..05ee8f61bfb5 100644 --- a/drivers/acpi/blacklist.c +++ b/drivers/acpi/blacklist.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <linux/dmi.h> | 33 | #include <linux/dmi.h> |
35 | 34 | ||
36 | #include "internal.h" | 35 | #include "internal.h" |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 0710004055c8..384da5ab5955 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <asm/mpspec.h> | 37 | #include <asm/mpspec.h> |
38 | #endif | 38 | #endif |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <acpi/acpi_bus.h> | ||
41 | #include <acpi/acpi_drivers.h> | ||
42 | #include <acpi/apei.h> | 40 | #include <acpi/apei.h> |
43 | #include <linux/dmi.h> | 41 | #include <linux/dmi.h> |
44 | #include <linux/suspend.h> | 42 | #include <linux/suspend.h> |
@@ -52,9 +50,6 @@ struct acpi_device *acpi_root; | |||
52 | struct proc_dir_entry *acpi_root_dir; | 50 | struct proc_dir_entry *acpi_root_dir; |
53 | EXPORT_SYMBOL(acpi_root_dir); | 51 | EXPORT_SYMBOL(acpi_root_dir); |
54 | 52 | ||
55 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
56 | |||
57 | |||
58 | #ifdef CONFIG_X86 | 53 | #ifdef CONFIG_X86 |
59 | static int set_copy_dsdt(const struct dmi_system_id *id) | 54 | static int set_copy_dsdt(const struct dmi_system_id *id) |
60 | { | 55 | { |
@@ -115,18 +110,16 @@ int acpi_bus_get_status(struct acpi_device *device) | |||
115 | if (ACPI_FAILURE(status)) | 110 | if (ACPI_FAILURE(status)) |
116 | return -ENODEV; | 111 | return -ENODEV; |
117 | 112 | ||
118 | STRUCT_TO_INT(device->status) = (int) sta; | 113 | acpi_set_device_status(device, sta); |
119 | 114 | ||
120 | if (device->status.functional && !device->status.present) { | 115 | if (device->status.functional && !device->status.present) { |
121 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " | 116 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " |
122 | "functional but not present;\n", | 117 | "functional but not present;\n", |
123 | device->pnp.bus_id, | 118 | device->pnp.bus_id, (u32)sta)); |
124 | (u32) STRUCT_TO_INT(device->status))); | ||
125 | } | 119 | } |
126 | 120 | ||
127 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", | 121 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", |
128 | device->pnp.bus_id, | 122 | device->pnp.bus_id, (u32)sta)); |
129 | (u32) STRUCT_TO_INT(device->status))); | ||
130 | return 0; | 123 | return 0; |
131 | } | 124 | } |
132 | EXPORT_SYMBOL(acpi_bus_get_status); | 125 | EXPORT_SYMBOL(acpi_bus_get_status); |
@@ -339,58 +332,6 @@ static void acpi_bus_osc_support(void) | |||
339 | Notification Handling | 332 | Notification Handling |
340 | -------------------------------------------------------------------------- */ | 333 | -------------------------------------------------------------------------- */ |
341 | 334 | ||
342 | static void acpi_bus_check_device(acpi_handle handle) | ||
343 | { | ||
344 | struct acpi_device *device; | ||
345 | acpi_status status; | ||
346 | struct acpi_device_status old_status; | ||
347 | |||
348 | if (acpi_bus_get_device(handle, &device)) | ||
349 | return; | ||
350 | if (!device) | ||
351 | return; | ||
352 | |||
353 | old_status = device->status; | ||
354 | |||
355 | /* | ||
356 | * Make sure this device's parent is present before we go about | ||
357 | * messing with the device. | ||
358 | */ | ||
359 | if (device->parent && !device->parent->status.present) { | ||
360 | device->status = device->parent->status; | ||
361 | return; | ||
362 | } | ||
363 | |||
364 | status = acpi_bus_get_status(device); | ||
365 | if (ACPI_FAILURE(status)) | ||
366 | return; | ||
367 | |||
368 | if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) | ||
369 | return; | ||
370 | |||
371 | /* | ||
372 | * Device Insertion/Removal | ||
373 | */ | ||
374 | if ((device->status.present) && !(old_status.present)) { | ||
375 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device insertion detected\n")); | ||
376 | /* TBD: Handle device insertion */ | ||
377 | } else if (!(device->status.present) && (old_status.present)) { | ||
378 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device removal detected\n")); | ||
379 | /* TBD: Handle device removal */ | ||
380 | } | ||
381 | } | ||
382 | |||
383 | static void acpi_bus_check_scope(acpi_handle handle) | ||
384 | { | ||
385 | /* Status Change? */ | ||
386 | acpi_bus_check_device(handle); | ||
387 | |||
388 | /* | ||
389 | * TBD: Enumerate child devices within this device's scope and | ||
390 | * run acpi_bus_check_device()'s on them. | ||
391 | */ | ||
392 | } | ||
393 | |||
394 | /** | 335 | /** |
395 | * acpi_bus_notify | 336 | * acpi_bus_notify |
396 | * --------------- | 337 | * --------------- |
@@ -407,19 +348,11 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) | |||
407 | switch (type) { | 348 | switch (type) { |
408 | 349 | ||
409 | case ACPI_NOTIFY_BUS_CHECK: | 350 | case ACPI_NOTIFY_BUS_CHECK: |
410 | acpi_bus_check_scope(handle); | 351 | /* TBD */ |
411 | /* | ||
412 | * TBD: We'll need to outsource certain events to non-ACPI | ||
413 | * drivers via the device manager (device.c). | ||
414 | */ | ||
415 | break; | 352 | break; |
416 | 353 | ||
417 | case ACPI_NOTIFY_DEVICE_CHECK: | 354 | case ACPI_NOTIFY_DEVICE_CHECK: |
418 | acpi_bus_check_device(handle); | 355 | /* TBD */ |
419 | /* | ||
420 | * TBD: We'll need to outsource certain events to non-ACPI | ||
421 | * drivers via the device manager (device.c). | ||
422 | */ | ||
423 | break; | 356 | break; |
424 | 357 | ||
425 | case ACPI_NOTIFY_DEVICE_WAKE: | 358 | case ACPI_NOTIFY_DEVICE_WAKE: |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index c971929d75c2..9e3a6cb99f90 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -31,8 +31,7 @@ | |||
31 | #include <linux/seq_file.h> | 31 | #include <linux/seq_file.h> |
32 | #include <linux/input.h> | 32 | #include <linux/input.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | #include <acpi/acpi_bus.h> | 34 | #include <linux/acpi.h> |
35 | #include <acpi/acpi_drivers.h> | ||
36 | #include <acpi/button.h> | 35 | #include <acpi/button.h> |
37 | 36 | ||
38 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index e23151667655..0b6ae6eb5c4a 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -27,8 +27,7 @@ | |||
27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 27 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
28 | */ | 28 | */ |
29 | #include <linux/acpi.h> | 29 | #include <linux/acpi.h> |
30 | 30 | #include <linux/container.h> | |
31 | #include "internal.h" | ||
32 | 31 | ||
33 | #include "internal.h" | 32 | #include "internal.h" |
34 | 33 | ||
@@ -44,19 +43,65 @@ static const struct acpi_device_id container_device_ids[] = { | |||
44 | {"", 0}, | 43 | {"", 0}, |
45 | }; | 44 | }; |
46 | 45 | ||
47 | static int container_device_attach(struct acpi_device *device, | 46 | static int acpi_container_offline(struct container_dev *cdev) |
47 | { | ||
48 | struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); | ||
49 | struct acpi_device *child; | ||
50 | |||
51 | /* Check all of the dependent devices' physical companions. */ | ||
52 | list_for_each_entry(child, &adev->children, node) | ||
53 | if (!acpi_scan_is_offline(child, false)) | ||
54 | return -EBUSY; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static void acpi_container_release(struct device *dev) | ||
60 | { | ||
61 | kfree(to_container_dev(dev)); | ||
62 | } | ||
63 | |||
64 | static int container_device_attach(struct acpi_device *adev, | ||
48 | const struct acpi_device_id *not_used) | 65 | const struct acpi_device_id *not_used) |
49 | { | 66 | { |
50 | /* This is necessary for container hotplug to work. */ | 67 | struct container_dev *cdev; |
68 | struct device *dev; | ||
69 | int ret; | ||
70 | |||
71 | cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); | ||
72 | if (!cdev) | ||
73 | return -ENOMEM; | ||
74 | |||
75 | cdev->offline = acpi_container_offline; | ||
76 | dev = &cdev->dev; | ||
77 | dev->bus = &container_subsys; | ||
78 | dev_set_name(dev, "%s", dev_name(&adev->dev)); | ||
79 | ACPI_COMPANION_SET(dev, adev); | ||
80 | dev->release = acpi_container_release; | ||
81 | ret = device_register(dev); | ||
82 | if (ret) | ||
83 | return ret; | ||
84 | |||
85 | adev->driver_data = dev; | ||
51 | return 1; | 86 | return 1; |
52 | } | 87 | } |
53 | 88 | ||
89 | static void container_device_detach(struct acpi_device *adev) | ||
90 | { | ||
91 | struct device *dev = acpi_driver_data(adev); | ||
92 | |||
93 | adev->driver_data = NULL; | ||
94 | if (dev) | ||
95 | device_unregister(dev); | ||
96 | } | ||
97 | |||
54 | static struct acpi_scan_handler container_handler = { | 98 | static struct acpi_scan_handler container_handler = { |
55 | .ids = container_device_ids, | 99 | .ids = container_device_ids, |
56 | .attach = container_device_attach, | 100 | .attach = container_device_attach, |
101 | .detach = container_device_detach, | ||
57 | .hotplug = { | 102 | .hotplug = { |
58 | .enabled = true, | 103 | .enabled = true, |
59 | .mode = AHM_CONTAINER, | 104 | .demand_offline = true, |
60 | }, | 105 | }, |
61 | }; | 106 | }; |
62 | 107 | ||
diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c index 12b62f2cdb3f..c68e72414a67 100644 --- a/drivers/acpi/custom_method.c +++ b/drivers/acpi/custom_method.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/uaccess.h> | 8 | #include <linux/uaccess.h> |
9 | #include <linux/debugfs.h> | 9 | #include <linux/debugfs.h> |
10 | #include <acpi/acpi_drivers.h> | 10 | #include <linux/acpi.h> |
11 | 11 | ||
12 | #include "internal.h" | 12 | #include "internal.h" |
13 | 13 | ||
diff --git a/drivers/acpi/debugfs.c b/drivers/acpi/debugfs.c index b55d6a20dc0e..6b1919f6bd82 100644 --- a/drivers/acpi/debugfs.c +++ b/drivers/acpi/debugfs.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/export.h> | 5 | #include <linux/export.h> |
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/debugfs.h> | 7 | #include <linux/debugfs.h> |
8 | #include <acpi/acpi_drivers.h> | 8 | #include <linux/acpi.h> |
9 | 9 | ||
10 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 10 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
11 | ACPI_MODULE_NAME("debugfs"); | 11 | ACPI_MODULE_NAME("debugfs"); |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index b3480cf7db1a..d49f1e464703 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
@@ -256,6 +256,8 @@ int acpi_bus_init_power(struct acpi_device *device) | |||
256 | return -EINVAL; | 256 | return -EINVAL; |
257 | 257 | ||
258 | device->power.state = ACPI_STATE_UNKNOWN; | 258 | device->power.state = ACPI_STATE_UNKNOWN; |
259 | if (!acpi_device_is_present(device)) | ||
260 | return 0; | ||
259 | 261 | ||
260 | result = acpi_device_get_power(device, &state); | 262 | result = acpi_device_get_power(device, &state); |
261 | if (result) | 263 | if (result) |
@@ -302,15 +304,18 @@ int acpi_device_fix_up_power(struct acpi_device *device) | |||
302 | return ret; | 304 | return ret; |
303 | } | 305 | } |
304 | 306 | ||
305 | int acpi_bus_update_power(acpi_handle handle, int *state_p) | 307 | int acpi_device_update_power(struct acpi_device *device, int *state_p) |
306 | { | 308 | { |
307 | struct acpi_device *device; | ||
308 | int state; | 309 | int state; |
309 | int result; | 310 | int result; |
310 | 311 | ||
311 | result = acpi_bus_get_device(handle, &device); | 312 | if (device->power.state == ACPI_STATE_UNKNOWN) { |
312 | if (result) | 313 | result = acpi_bus_init_power(device); |
314 | if (!result && state_p) | ||
315 | *state_p = device->power.state; | ||
316 | |||
313 | return result; | 317 | return result; |
318 | } | ||
314 | 319 | ||
315 | result = acpi_device_get_power(device, &state); | 320 | result = acpi_device_get_power(device, &state); |
316 | if (result) | 321 | if (result) |
@@ -338,6 +343,15 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p) | |||
338 | 343 | ||
339 | return 0; | 344 | return 0; |
340 | } | 345 | } |
346 | |||
347 | int acpi_bus_update_power(acpi_handle handle, int *state_p) | ||
348 | { | ||
349 | struct acpi_device *device; | ||
350 | int result; | ||
351 | |||
352 | result = acpi_bus_get_device(handle, &device); | ||
353 | return result ? result : acpi_device_update_power(device, state_p); | ||
354 | } | ||
341 | EXPORT_SYMBOL_GPL(acpi_bus_update_power); | 355 | EXPORT_SYMBOL_GPL(acpi_bus_update_power); |
342 | 356 | ||
343 | bool acpi_bus_power_manageable(acpi_handle handle) | 357 | bool acpi_bus_power_manageable(acpi_handle handle) |
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index dcd73ccb514c..c431c88faaff 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -32,8 +32,8 @@ | |||
32 | #include <linux/jiffies.h> | 32 | #include <linux/jiffies.h> |
33 | #include <linux/stddef.h> | 33 | #include <linux/stddef.h> |
34 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
35 | #include <acpi/acpi_bus.h> | 35 | |
36 | #include <acpi/acpi_drivers.h> | 36 | #include "internal.h" |
37 | 37 | ||
38 | #define PREFIX "ACPI: " | 38 | #define PREFIX "ACPI: " |
39 | 39 | ||
@@ -323,14 +323,11 @@ static int dock_present(struct dock_station *ds) | |||
323 | */ | 323 | */ |
324 | static void dock_create_acpi_device(acpi_handle handle) | 324 | static void dock_create_acpi_device(acpi_handle handle) |
325 | { | 325 | { |
326 | struct acpi_device *device; | 326 | struct acpi_device *device = NULL; |
327 | int ret; | 327 | int ret; |
328 | 328 | ||
329 | if (acpi_bus_get_device(handle, &device)) { | 329 | acpi_bus_get_device(handle, &device); |
330 | /* | 330 | if (!acpi_device_enumerated(device)) { |
331 | * no device created for this object, | ||
332 | * so we should create one. | ||
333 | */ | ||
334 | ret = acpi_bus_scan(handle); | 331 | ret = acpi_bus_scan(handle); |
335 | if (ret) | 332 | if (ret) |
336 | pr_debug("error adding bus, %x\n", -ret); | 333 | pr_debug("error adding bus, %x\n", -ret); |
@@ -898,9 +895,6 @@ find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
898 | 895 | ||
899 | void __init acpi_dock_init(void) | 896 | void __init acpi_dock_init(void) |
900 | { | 897 | { |
901 | if (acpi_disabled) | ||
902 | return; | ||
903 | |||
904 | /* look for dock stations and bays */ | 898 | /* look for dock stations and bays */ |
905 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 899 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
906 | ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); | 900 | ACPI_UINT32_MAX, find_dock_and_bay, NULL, NULL, NULL); |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index ba5b56db9d27..47b1111afc90 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -39,10 +39,9 @@ | |||
39 | #include <linux/list.h> | 39 | #include <linux/list.h> |
40 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <asm/io.h> | 42 | #include <linux/acpi.h> |
43 | #include <acpi/acpi_bus.h> | ||
44 | #include <acpi/acpi_drivers.h> | ||
45 | #include <linux/dmi.h> | 43 | #include <linux/dmi.h> |
44 | #include <asm/io.h> | ||
46 | 45 | ||
47 | #include "internal.h" | 46 | #include "internal.h" |
48 | 47 | ||
@@ -91,10 +90,6 @@ static unsigned int ec_storm_threshold __read_mostly = 8; | |||
91 | module_param(ec_storm_threshold, uint, 0644); | 90 | module_param(ec_storm_threshold, uint, 0644); |
92 | MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); | 91 | MODULE_PARM_DESC(ec_storm_threshold, "Maxim false GPE numbers not considered as GPE storm"); |
93 | 92 | ||
94 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | ||
95 | /* External interfaces use first EC only, so remember */ | ||
96 | typedef int (*acpi_ec_query_func) (void *data); | ||
97 | |||
98 | struct acpi_ec_query_handler { | 93 | struct acpi_ec_query_handler { |
99 | struct list_head node; | 94 | struct list_head node; |
100 | acpi_ec_query_func func; | 95 | acpi_ec_query_func func; |
@@ -387,27 +382,6 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | |||
387 | return acpi_ec_transaction(ec, &t); | 382 | return acpi_ec_transaction(ec, &t); |
388 | } | 383 | } |
389 | 384 | ||
390 | /* | ||
391 | * Externally callable EC access functions. For now, assume 1 EC only | ||
392 | */ | ||
393 | int ec_burst_enable(void) | ||
394 | { | ||
395 | if (!first_ec) | ||
396 | return -ENODEV; | ||
397 | return acpi_ec_burst_enable(first_ec); | ||
398 | } | ||
399 | |||
400 | EXPORT_SYMBOL(ec_burst_enable); | ||
401 | |||
402 | int ec_burst_disable(void) | ||
403 | { | ||
404 | if (!first_ec) | ||
405 | return -ENODEV; | ||
406 | return acpi_ec_burst_disable(first_ec); | ||
407 | } | ||
408 | |||
409 | EXPORT_SYMBOL(ec_burst_disable); | ||
410 | |||
411 | int ec_read(u8 addr, u8 *val) | 385 | int ec_read(u8 addr, u8 *val) |
412 | { | 386 | { |
413 | int err; | 387 | int err; |
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c index 4e7b798900f2..b4c216bab22b 100644 --- a/drivers/acpi/ec_sys.c +++ b/drivers/acpi/ec_sys.c | |||
@@ -105,7 +105,7 @@ static const struct file_operations acpi_ec_io_ops = { | |||
105 | .llseek = default_llseek, | 105 | .llseek = default_llseek, |
106 | }; | 106 | }; |
107 | 107 | ||
108 | int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) | 108 | static int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) |
109 | { | 109 | { |
110 | struct dentry *dev_dir; | 110 | struct dentry *dev_dir; |
111 | char name[64]; | 111 | char name[64]; |
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index cae3b387b867..ef2d730734dc 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/poll.h> | 13 | #include <linux/poll.h> |
14 | #include <linux/gfp.h> | 14 | #include <linux/gfp.h> |
15 | #include <acpi/acpi_drivers.h> | 15 | #include <linux/acpi.h> |
16 | #include <net/netlink.h> | 16 | #include <net/netlink.h> |
17 | #include <net/genetlink.h> | 17 | #include <net/genetlink.h> |
18 | 18 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index ba3da88cee45..1fb62900f32a 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | #include <linux/thermal.h> | 31 | #include <linux/thermal.h> |
32 | #include <acpi/acpi_bus.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_drivers.h> | ||
34 | 33 | ||
35 | #define PREFIX "ACPI: " | 34 | #define PREFIX "ACPI: " |
36 | 35 | ||
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index a22a295edb69..0c789224d40d 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -37,7 +37,7 @@ int register_acpi_bus_type(struct acpi_bus_type *type) | |||
37 | { | 37 | { |
38 | if (acpi_disabled) | 38 | if (acpi_disabled) |
39 | return -ENODEV; | 39 | return -ENODEV; |
40 | if (type && type->match && type->find_device) { | 40 | if (type && type->match && type->find_companion) { |
41 | down_write(&bus_type_sem); | 41 | down_write(&bus_type_sem); |
42 | list_add_tail(&type->list, &bus_type_list); | 42 | list_add_tail(&type->list, &bus_type_list); |
43 | up_write(&bus_type_sem); | 43 | up_write(&bus_type_sem); |
@@ -82,109 +82,74 @@ static struct acpi_bus_type *acpi_get_bus_type(struct device *dev) | |||
82 | #define FIND_CHILD_MIN_SCORE 1 | 82 | #define FIND_CHILD_MIN_SCORE 1 |
83 | #define FIND_CHILD_MAX_SCORE 2 | 83 | #define FIND_CHILD_MAX_SCORE 2 |
84 | 84 | ||
85 | static acpi_status acpi_dev_present(acpi_handle handle, u32 lvl_not_used, | 85 | static int find_child_checks(struct acpi_device *adev, bool check_children) |
86 | void *not_used, void **ret_p) | ||
87 | { | ||
88 | struct acpi_device *adev = NULL; | ||
89 | |||
90 | acpi_bus_get_device(handle, &adev); | ||
91 | if (adev) { | ||
92 | *ret_p = handle; | ||
93 | return AE_CTRL_TERMINATE; | ||
94 | } | ||
95 | return AE_OK; | ||
96 | } | ||
97 | |||
98 | static int do_find_child_checks(acpi_handle handle, bool is_bridge) | ||
99 | { | 86 | { |
100 | bool sta_present = true; | 87 | bool sta_present = true; |
101 | unsigned long long sta; | 88 | unsigned long long sta; |
102 | acpi_status status; | 89 | acpi_status status; |
103 | 90 | ||
104 | status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); | 91 | status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); |
105 | if (status == AE_NOT_FOUND) | 92 | if (status == AE_NOT_FOUND) |
106 | sta_present = false; | 93 | sta_present = false; |
107 | else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) | 94 | else if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) |
108 | return -ENODEV; | 95 | return -ENODEV; |
109 | 96 | ||
110 | if (is_bridge) { | 97 | if (check_children && list_empty(&adev->children)) |
111 | void *test = NULL; | 98 | return -ENODEV; |
112 | 99 | ||
113 | /* Check if this object has at least one child device. */ | ||
114 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, | ||
115 | acpi_dev_present, NULL, NULL, &test); | ||
116 | if (!test) | ||
117 | return -ENODEV; | ||
118 | } | ||
119 | return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; | 100 | return sta_present ? FIND_CHILD_MAX_SCORE : FIND_CHILD_MIN_SCORE; |
120 | } | 101 | } |
121 | 102 | ||
122 | struct find_child_context { | 103 | struct acpi_device *acpi_find_child_device(struct acpi_device *parent, |
123 | u64 addr; | 104 | u64 address, bool check_children) |
124 | bool is_bridge; | ||
125 | acpi_handle ret; | ||
126 | int ret_score; | ||
127 | }; | ||
128 | |||
129 | static acpi_status do_find_child(acpi_handle handle, u32 lvl_not_used, | ||
130 | void *data, void **not_used) | ||
131 | { | ||
132 | struct find_child_context *context = data; | ||
133 | unsigned long long addr; | ||
134 | acpi_status status; | ||
135 | int score; | ||
136 | |||
137 | status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &addr); | ||
138 | if (ACPI_FAILURE(status) || addr != context->addr) | ||
139 | return AE_OK; | ||
140 | |||
141 | if (!context->ret) { | ||
142 | /* This is the first matching object. Save its handle. */ | ||
143 | context->ret = handle; | ||
144 | return AE_OK; | ||
145 | } | ||
146 | /* | ||
147 | * There is more than one matching object with the same _ADR value. | ||
148 | * That really is unexpected, so we are kind of beyond the scope of the | ||
149 | * spec here. We have to choose which one to return, though. | ||
150 | * | ||
151 | * First, check if the previously found object is good enough and return | ||
152 | * its handle if so. Second, check the same for the object that we've | ||
153 | * just found. | ||
154 | */ | ||
155 | if (!context->ret_score) { | ||
156 | score = do_find_child_checks(context->ret, context->is_bridge); | ||
157 | if (score == FIND_CHILD_MAX_SCORE) | ||
158 | return AE_CTRL_TERMINATE; | ||
159 | else | ||
160 | context->ret_score = score; | ||
161 | } | ||
162 | score = do_find_child_checks(handle, context->is_bridge); | ||
163 | if (score == FIND_CHILD_MAX_SCORE) { | ||
164 | context->ret = handle; | ||
165 | return AE_CTRL_TERMINATE; | ||
166 | } else if (score > context->ret_score) { | ||
167 | context->ret = handle; | ||
168 | context->ret_score = score; | ||
169 | } | ||
170 | return AE_OK; | ||
171 | } | ||
172 | |||
173 | acpi_handle acpi_find_child(acpi_handle parent, u64 addr, bool is_bridge) | ||
174 | { | 105 | { |
175 | if (parent) { | 106 | struct acpi_device *adev, *ret = NULL; |
176 | struct find_child_context context = { | 107 | int ret_score = 0; |
177 | .addr = addr, | 108 | |
178 | .is_bridge = is_bridge, | 109 | if (!parent) |
179 | }; | 110 | return NULL; |
180 | 111 | ||
181 | acpi_walk_namespace(ACPI_TYPE_DEVICE, parent, 1, do_find_child, | 112 | list_for_each_entry(adev, &parent->children, node) { |
182 | NULL, &context, NULL); | 113 | unsigned long long addr; |
183 | return context.ret; | 114 | acpi_status status; |
115 | int score; | ||
116 | |||
117 | status = acpi_evaluate_integer(adev->handle, METHOD_NAME__ADR, | ||
118 | NULL, &addr); | ||
119 | if (ACPI_FAILURE(status) || addr != address) | ||
120 | continue; | ||
121 | |||
122 | if (!ret) { | ||
123 | /* This is the first matching object. Save it. */ | ||
124 | ret = adev; | ||
125 | continue; | ||
126 | } | ||
127 | /* | ||
128 | * There is more than one matching device object with the same | ||
129 | * _ADR value. That really is unexpected, so we are kind of | ||
130 | * beyond the scope of the spec here. We have to choose which | ||
131 | * one to return, though. | ||
132 | * | ||
133 | * First, check if the previously found object is good enough | ||
134 | * and return it if so. Second, do the same for the object that | ||
135 | * we've just found. | ||
136 | */ | ||
137 | if (!ret_score) { | ||
138 | ret_score = find_child_checks(ret, check_children); | ||
139 | if (ret_score == FIND_CHILD_MAX_SCORE) | ||
140 | return ret; | ||
141 | } | ||
142 | score = find_child_checks(adev, check_children); | ||
143 | if (score == FIND_CHILD_MAX_SCORE) { | ||
144 | return adev; | ||
145 | } else if (score > ret_score) { | ||
146 | ret = adev; | ||
147 | ret_score = score; | ||
148 | } | ||
184 | } | 149 | } |
185 | return NULL; | 150 | return ret; |
186 | } | 151 | } |
187 | EXPORT_SYMBOL_GPL(acpi_find_child); | 152 | EXPORT_SYMBOL_GPL(acpi_find_child_device); |
188 | 153 | ||
189 | static void acpi_physnode_link_name(char *buf, unsigned int node_id) | 154 | static void acpi_physnode_link_name(char *buf, unsigned int node_id) |
190 | { | 155 | { |
@@ -195,9 +160,8 @@ static void acpi_physnode_link_name(char *buf, unsigned int node_id) | |||
195 | strcpy(buf, PHYSICAL_NODE_STRING); | 160 | strcpy(buf, PHYSICAL_NODE_STRING); |
196 | } | 161 | } |
197 | 162 | ||
198 | int acpi_bind_one(struct device *dev, acpi_handle handle) | 163 | int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) |
199 | { | 164 | { |
200 | struct acpi_device *acpi_dev = NULL; | ||
201 | struct acpi_device_physical_node *physical_node, *pn; | 165 | struct acpi_device_physical_node *physical_node, *pn; |
202 | char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; | 166 | char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; |
203 | struct list_head *physnode_list; | 167 | struct list_head *physnode_list; |
@@ -205,14 +169,12 @@ int acpi_bind_one(struct device *dev, acpi_handle handle) | |||
205 | int retval = -EINVAL; | 169 | int retval = -EINVAL; |
206 | 170 | ||
207 | if (ACPI_COMPANION(dev)) { | 171 | if (ACPI_COMPANION(dev)) { |
208 | if (handle) { | 172 | if (acpi_dev) { |
209 | dev_warn(dev, "ACPI companion already set\n"); | 173 | dev_warn(dev, "ACPI companion already set\n"); |
210 | return -EINVAL; | 174 | return -EINVAL; |
211 | } else { | 175 | } else { |
212 | acpi_dev = ACPI_COMPANION(dev); | 176 | acpi_dev = ACPI_COMPANION(dev); |
213 | } | 177 | } |
214 | } else { | ||
215 | acpi_bus_get_device(handle, &acpi_dev); | ||
216 | } | 178 | } |
217 | if (!acpi_dev) | 179 | if (!acpi_dev) |
218 | return -EINVAL; | 180 | return -EINVAL; |
@@ -322,29 +284,22 @@ int acpi_unbind_one(struct device *dev) | |||
322 | } | 284 | } |
323 | EXPORT_SYMBOL_GPL(acpi_unbind_one); | 285 | EXPORT_SYMBOL_GPL(acpi_unbind_one); |
324 | 286 | ||
325 | void acpi_preset_companion(struct device *dev, acpi_handle parent, u64 addr) | ||
326 | { | ||
327 | struct acpi_device *adev; | ||
328 | |||
329 | if (!acpi_bus_get_device(acpi_get_child(parent, addr), &adev)) | ||
330 | ACPI_COMPANION_SET(dev, adev); | ||
331 | } | ||
332 | EXPORT_SYMBOL_GPL(acpi_preset_companion); | ||
333 | |||
334 | static int acpi_platform_notify(struct device *dev) | 287 | static int acpi_platform_notify(struct device *dev) |
335 | { | 288 | { |
336 | struct acpi_bus_type *type = acpi_get_bus_type(dev); | 289 | struct acpi_bus_type *type = acpi_get_bus_type(dev); |
337 | acpi_handle handle; | ||
338 | int ret; | 290 | int ret; |
339 | 291 | ||
340 | ret = acpi_bind_one(dev, NULL); | 292 | ret = acpi_bind_one(dev, NULL); |
341 | if (ret && type) { | 293 | if (ret && type) { |
342 | ret = type->find_device(dev, &handle); | 294 | struct acpi_device *adev; |
343 | if (ret) { | 295 | |
296 | adev = type->find_companion(dev); | ||
297 | if (!adev) { | ||
344 | DBG("Unable to get handle for %s\n", dev_name(dev)); | 298 | DBG("Unable to get handle for %s\n", dev_name(dev)); |
299 | ret = -ENODEV; | ||
345 | goto out; | 300 | goto out; |
346 | } | 301 | } |
347 | ret = acpi_bind_one(dev, handle); | 302 | ret = acpi_bind_one(dev, adev); |
348 | if (ret) | 303 | if (ret) |
349 | goto out; | 304 | goto out; |
350 | } | 305 | } |
diff --git a/drivers/acpi/hed.c b/drivers/acpi/hed.c index 13b1d39d7cdf..aafe3ca829c2 100644 --- a/drivers/acpi/hed.c +++ b/drivers/acpi/hed.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/acpi.h> | 27 | #include <linux/acpi.h> |
28 | #include <acpi/acpi_bus.h> | ||
29 | #include <acpi/acpi_drivers.h> | ||
30 | #include <acpi/hed.h> | 28 | #include <acpi/hed.h> |
31 | 29 | ||
32 | static struct acpi_device_id acpi_hed_ids[] = { | 30 | static struct acpi_device_id acpi_hed_ids[] = { |
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index a29739c0ba79..dedbb2d802f1 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h | |||
@@ -28,7 +28,6 @@ int init_acpi_device_notify(void); | |||
28 | int acpi_scan_init(void); | 28 | int acpi_scan_init(void); |
29 | void acpi_pci_root_init(void); | 29 | void acpi_pci_root_init(void); |
30 | void acpi_pci_link_init(void); | 30 | void acpi_pci_link_init(void); |
31 | void acpi_pci_root_hp_init(void); | ||
32 | void acpi_processor_init(void); | 31 | void acpi_processor_init(void); |
33 | void acpi_platform_init(void); | 32 | void acpi_platform_init(void); |
34 | int acpi_sysfs_init(void); | 33 | int acpi_sysfs_init(void); |
@@ -73,6 +72,9 @@ void acpi_lpss_init(void); | |||
73 | static inline void acpi_lpss_init(void) {} | 72 | static inline void acpi_lpss_init(void) {} |
74 | #endif | 73 | #endif |
75 | 74 | ||
75 | bool acpi_queue_hotplug_work(struct work_struct *work); | ||
76 | bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); | ||
77 | |||
76 | /* -------------------------------------------------------------------------- | 78 | /* -------------------------------------------------------------------------- |
77 | Device Node Initialization / Removal | 79 | Device Node Initialization / Removal |
78 | -------------------------------------------------------------------------- */ | 80 | -------------------------------------------------------------------------- */ |
@@ -85,9 +87,9 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
85 | int type, unsigned long long sta); | 87 | int type, unsigned long long sta); |
86 | void acpi_device_add_finalize(struct acpi_device *device); | 88 | void acpi_device_add_finalize(struct acpi_device *device); |
87 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); | 89 | void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); |
88 | int acpi_bind_one(struct device *dev, acpi_handle handle); | 90 | int acpi_bind_one(struct device *dev, struct acpi_device *adev); |
89 | int acpi_unbind_one(struct device *dev); | 91 | int acpi_unbind_one(struct device *dev); |
90 | void acpi_bus_device_eject(void *data, u32 ost_src); | 92 | bool acpi_device_is_present(struct acpi_device *adev); |
91 | 93 | ||
92 | /* -------------------------------------------------------------------------- | 94 | /* -------------------------------------------------------------------------- |
93 | Power Resource | 95 | Power Resource |
@@ -105,6 +107,8 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state); | |||
105 | int acpi_power_on_resources(struct acpi_device *device, int state); | 107 | int acpi_power_on_resources(struct acpi_device *device, int state); |
106 | int acpi_power_transition(struct acpi_device *device, int state); | 108 | int acpi_power_transition(struct acpi_device *device, int state); |
107 | 109 | ||
110 | int acpi_device_update_power(struct acpi_device *device, int *state_p); | ||
111 | |||
108 | int acpi_wakeup_device_init(void); | 112 | int acpi_wakeup_device_init(void); |
109 | void acpi_early_processor_set_pdc(void); | 113 | void acpi_early_processor_set_pdc(void); |
110 | 114 | ||
@@ -127,12 +131,21 @@ struct acpi_ec { | |||
127 | 131 | ||
128 | extern struct acpi_ec *first_ec; | 132 | extern struct acpi_ec *first_ec; |
129 | 133 | ||
134 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | ||
135 | /* External interfaces use first EC only, so remember */ | ||
136 | typedef int (*acpi_ec_query_func) (void *data); | ||
137 | |||
130 | int acpi_ec_init(void); | 138 | int acpi_ec_init(void); |
131 | int acpi_ec_ecdt_probe(void); | 139 | int acpi_ec_ecdt_probe(void); |
132 | int acpi_boot_ec_enable(void); | 140 | int acpi_boot_ec_enable(void); |
133 | void acpi_ec_block_transactions(void); | 141 | void acpi_ec_block_transactions(void); |
134 | void acpi_ec_unblock_transactions(void); | 142 | void acpi_ec_unblock_transactions(void); |
135 | void acpi_ec_unblock_transactions_early(void); | 143 | void acpi_ec_unblock_transactions_early(void); |
144 | int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, | ||
145 | acpi_handle handle, acpi_ec_query_func func, | ||
146 | void *data); | ||
147 | void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); | ||
148 | |||
136 | 149 | ||
137 | /*-------------------------------------------------------------------------- | 150 | /*-------------------------------------------------------------------------- |
138 | Suspend/Resume | 151 | Suspend/Resume |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index a2343a1d9e0b..9e6816ef280a 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/errno.h> | 29 | #include <linux/errno.h> |
30 | #include <linux/acpi.h> | 30 | #include <linux/acpi.h> |
31 | #include <linux/numa.h> | 31 | #include <linux/numa.h> |
32 | #include <acpi/acpi_bus.h> | ||
33 | 32 | ||
34 | #define PREFIX "ACPI: " | 33 | #define PREFIX "ACPI: " |
35 | 34 | ||
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c index 386a9fe497b4..de4fe03873c5 100644 --- a/drivers/acpi/nvs.c +++ b/drivers/acpi/nvs.c | |||
@@ -12,7 +12,8 @@ | |||
12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/acpi.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/acpi_io.h> | 15 | |
16 | #include "internal.h" | ||
16 | 17 | ||
17 | /* ACPI NVS regions, APEI may use it */ | 18 | /* ACPI NVS regions, APEI may use it */ |
18 | 19 | ||
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 54a20ff4b864..fc1aa7909690 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/workqueue.h> | 39 | #include <linux/workqueue.h> |
40 | #include <linux/nmi.h> | 40 | #include <linux/nmi.h> |
41 | #include <linux/acpi.h> | 41 | #include <linux/acpi.h> |
42 | #include <linux/acpi_io.h> | ||
43 | #include <linux/efi.h> | 42 | #include <linux/efi.h> |
44 | #include <linux/ioport.h> | 43 | #include <linux/ioport.h> |
45 | #include <linux/list.h> | 44 | #include <linux/list.h> |
@@ -49,9 +48,6 @@ | |||
49 | #include <asm/io.h> | 48 | #include <asm/io.h> |
50 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
51 | 50 | ||
52 | #include <acpi/acpi.h> | ||
53 | #include <acpi/acpi_bus.h> | ||
54 | #include <acpi/processor.h> | ||
55 | #include "internal.h" | 51 | #include "internal.h" |
56 | 52 | ||
57 | #define _COMPONENT ACPI_OS_SERVICES | 53 | #define _COMPONENT ACPI_OS_SERVICES |
@@ -544,7 +540,7 @@ static u64 acpi_tables_addr; | |||
544 | static int all_tables_size; | 540 | static int all_tables_size; |
545 | 541 | ||
546 | /* Copied from acpica/tbutils.c:acpi_tb_checksum() */ | 542 | /* Copied from acpica/tbutils.c:acpi_tb_checksum() */ |
547 | u8 __init acpi_table_checksum(u8 *buffer, u32 length) | 543 | static u8 __init acpi_table_checksum(u8 *buffer, u32 length) |
548 | { | 544 | { |
549 | u8 sum = 0; | 545 | u8 sum = 0; |
550 | u8 *end = buffer + length; | 546 | u8 *end = buffer + length; |
@@ -1215,6 +1211,10 @@ acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src) | |||
1215 | return AE_OK; | 1211 | return AE_OK; |
1216 | } | 1212 | } |
1217 | 1213 | ||
1214 | bool acpi_queue_hotplug_work(struct work_struct *work) | ||
1215 | { | ||
1216 | return queue_work(kacpi_hotplug_wq, work); | ||
1217 | } | ||
1218 | 1218 | ||
1219 | acpi_status | 1219 | acpi_status |
1220 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) | 1220 | acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) |
@@ -1282,7 +1282,7 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout) | |||
1282 | jiffies = MAX_SCHEDULE_TIMEOUT; | 1282 | jiffies = MAX_SCHEDULE_TIMEOUT; |
1283 | else | 1283 | else |
1284 | jiffies = msecs_to_jiffies(timeout); | 1284 | jiffies = msecs_to_jiffies(timeout); |
1285 | 1285 | ||
1286 | ret = down_timeout(sem, jiffies); | 1286 | ret = down_timeout(sem, jiffies); |
1287 | if (ret) | 1287 | if (ret) |
1288 | status = AE_TIME; | 1288 | status = AE_TIME; |
@@ -1794,7 +1794,7 @@ acpi_status __init acpi_os_initialize1(void) | |||
1794 | { | 1794 | { |
1795 | kacpid_wq = alloc_workqueue("kacpid", 0, 1); | 1795 | kacpid_wq = alloc_workqueue("kacpid", 0, 1); |
1796 | kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); | 1796 | kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); |
1797 | kacpi_hotplug_wq = alloc_workqueue("kacpi_hotplug", 0, 1); | 1797 | kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0); |
1798 | BUG_ON(!kacpid_wq); | 1798 | BUG_ON(!kacpid_wq); |
1799 | BUG_ON(!kacpi_notify_wq); | 1799 | BUG_ON(!kacpi_notify_wq); |
1800 | BUG_ON(!kacpi_hotplug_wq); | 1800 | BUG_ON(!kacpi_hotplug_wq); |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index 41c5e1b799ef..52d45ea2bc4f 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -37,8 +37,6 @@ | |||
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/acpi.h> | 38 | #include <linux/acpi.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <acpi/acpi_bus.h> | ||
41 | #include <acpi/acpi_drivers.h> | ||
42 | 40 | ||
43 | #define PREFIX "ACPI: " | 41 | #define PREFIX "ACPI: " |
44 | 42 | ||
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 2652a614deeb..9418c7a1f786 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -39,9 +39,9 @@ | |||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/acpi.h> | ||
42 | 43 | ||
43 | #include <acpi/acpi_bus.h> | 44 | #include "internal.h" |
44 | #include <acpi/acpi_drivers.h> | ||
45 | 45 | ||
46 | #define PREFIX "ACPI: " | 46 | #define PREFIX "ACPI: " |
47 | 47 | ||
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 20360e480bd8..afafee56cf8b 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -35,9 +35,7 @@ | |||
35 | #include <linux/pci-aspm.h> | 35 | #include <linux/pci-aspm.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <acpi/acpi_bus.h> | 38 | #include <acpi/apei.h> /* for acpi_hest_init() */ |
39 | #include <acpi/acpi_drivers.h> | ||
40 | #include <acpi/apei.h> | ||
41 | 39 | ||
42 | #include "internal.h" | 40 | #include "internal.h" |
43 | 41 | ||
@@ -51,6 +49,12 @@ static int acpi_pci_root_add(struct acpi_device *device, | |||
51 | const struct acpi_device_id *not_used); | 49 | const struct acpi_device_id *not_used); |
52 | static void acpi_pci_root_remove(struct acpi_device *device); | 50 | static void acpi_pci_root_remove(struct acpi_device *device); |
53 | 51 | ||
52 | static int acpi_pci_root_scan_dependent(struct acpi_device *adev) | ||
53 | { | ||
54 | acpiphp_check_host_bridge(adev->handle); | ||
55 | return 0; | ||
56 | } | ||
57 | |||
54 | #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ | 58 | #define ACPI_PCIE_REQ_SUPPORT (OSC_PCI_EXT_CONFIG_SUPPORT \ |
55 | | OSC_PCI_ASPM_SUPPORT \ | 59 | | OSC_PCI_ASPM_SUPPORT \ |
56 | | OSC_PCI_CLOCK_PM_SUPPORT \ | 60 | | OSC_PCI_CLOCK_PM_SUPPORT \ |
@@ -66,7 +70,8 @@ static struct acpi_scan_handler pci_root_handler = { | |||
66 | .attach = acpi_pci_root_add, | 70 | .attach = acpi_pci_root_add, |
67 | .detach = acpi_pci_root_remove, | 71 | .detach = acpi_pci_root_remove, |
68 | .hotplug = { | 72 | .hotplug = { |
69 | .ignore = true, | 73 | .enabled = true, |
74 | .scan_dependent = acpi_pci_root_scan_dependent, | ||
70 | }, | 75 | }, |
71 | }; | 76 | }; |
72 | 77 | ||
@@ -624,116 +629,9 @@ static void acpi_pci_root_remove(struct acpi_device *device) | |||
624 | void __init acpi_pci_root_init(void) | 629 | void __init acpi_pci_root_init(void) |
625 | { | 630 | { |
626 | acpi_hest_init(); | 631 | acpi_hest_init(); |
627 | 632 | if (acpi_pci_disabled) | |
628 | if (!acpi_pci_disabled) { | ||
629 | pci_acpi_crs_quirks(); | ||
630 | acpi_scan_add_handler(&pci_root_handler); | ||
631 | } | ||
632 | } | ||
633 | /* Support root bridge hotplug */ | ||
634 | |||
635 | static void handle_root_bridge_insertion(acpi_handle handle) | ||
636 | { | ||
637 | struct acpi_device *device; | ||
638 | |||
639 | if (!acpi_bus_get_device(handle, &device)) { | ||
640 | dev_printk(KERN_DEBUG, &device->dev, | ||
641 | "acpi device already exists; ignoring notify\n"); | ||
642 | return; | 633 | return; |
643 | } | ||
644 | |||
645 | if (acpi_bus_scan(handle)) | ||
646 | acpi_handle_err(handle, "cannot add bridge to acpi list\n"); | ||
647 | } | ||
648 | |||
649 | static void hotplug_event_root(void *data, u32 type) | ||
650 | { | ||
651 | acpi_handle handle = data; | ||
652 | struct acpi_pci_root *root; | ||
653 | |||
654 | acpi_scan_lock_acquire(); | ||
655 | |||
656 | root = acpi_pci_find_root(handle); | ||
657 | |||
658 | switch (type) { | ||
659 | case ACPI_NOTIFY_BUS_CHECK: | ||
660 | /* bus enumerate */ | ||
661 | acpi_handle_printk(KERN_DEBUG, handle, | ||
662 | "Bus check notify on %s\n", __func__); | ||
663 | if (root) | ||
664 | acpiphp_check_host_bridge(handle); | ||
665 | else | ||
666 | handle_root_bridge_insertion(handle); | ||
667 | |||
668 | break; | ||
669 | |||
670 | case ACPI_NOTIFY_DEVICE_CHECK: | ||
671 | /* device check */ | ||
672 | acpi_handle_printk(KERN_DEBUG, handle, | ||
673 | "Device check notify on %s\n", __func__); | ||
674 | if (!root) | ||
675 | handle_root_bridge_insertion(handle); | ||
676 | break; | ||
677 | |||
678 | case ACPI_NOTIFY_EJECT_REQUEST: | ||
679 | /* request device eject */ | ||
680 | acpi_handle_printk(KERN_DEBUG, handle, | ||
681 | "Device eject notify on %s\n", __func__); | ||
682 | if (!root) | ||
683 | break; | ||
684 | |||
685 | get_device(&root->device->dev); | ||
686 | |||
687 | acpi_scan_lock_release(); | ||
688 | |||
689 | acpi_bus_device_eject(root->device, ACPI_NOTIFY_EJECT_REQUEST); | ||
690 | return; | ||
691 | default: | ||
692 | acpi_handle_warn(handle, | ||
693 | "notify_handler: unknown event type 0x%x\n", | ||
694 | type); | ||
695 | break; | ||
696 | } | ||
697 | |||
698 | acpi_scan_lock_release(); | ||
699 | } | ||
700 | |||
701 | static void handle_hotplug_event_root(acpi_handle handle, u32 type, | ||
702 | void *context) | ||
703 | { | ||
704 | acpi_hotplug_execute(hotplug_event_root, handle, type); | ||
705 | } | ||
706 | |||
707 | static acpi_status __init | ||
708 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | ||
709 | { | ||
710 | acpi_status status; | ||
711 | int *count = (int *)context; | ||
712 | |||
713 | if (!acpi_is_root_bridge(handle)) | ||
714 | return AE_OK; | ||
715 | |||
716 | (*count)++; | ||
717 | |||
718 | status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | ||
719 | handle_hotplug_event_root, NULL); | ||
720 | if (ACPI_FAILURE(status)) | ||
721 | acpi_handle_printk(KERN_DEBUG, handle, | ||
722 | "notify handler is not installed, exit status: %u\n", | ||
723 | (unsigned int)status); | ||
724 | else | ||
725 | acpi_handle_printk(KERN_DEBUG, handle, | ||
726 | "notify handler is installed\n"); | ||
727 | |||
728 | return AE_OK; | ||
729 | } | ||
730 | |||
731 | void __init acpi_pci_root_hp_init(void) | ||
732 | { | ||
733 | int num = 0; | ||
734 | |||
735 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | ||
736 | ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL); | ||
737 | 634 | ||
738 | printk(KERN_DEBUG "Found %d acpi root devices\n", num); | 635 | pci_acpi_crs_quirks(); |
636 | acpi_scan_add_handler_with_hotplug(&pci_root_handler, "pci_root"); | ||
739 | } | 637 | } |
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c index d678a180ca2a..139d9e479370 100644 --- a/drivers/acpi/pci_slot.c +++ b/drivers/acpi/pci_slot.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
36 | #include <linux/acpi.h> | 36 | #include <linux/acpi.h> |
37 | #include <linux/dmi.h> | 37 | #include <linux/dmi.h> |
38 | #include <linux/pci-acpi.h> | ||
38 | 39 | ||
39 | static bool debug; | 40 | static bool debug; |
40 | static int check_sta_before_sun; | 41 | static int check_sta_before_sun; |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index c2ad391d8041..ad7da686e6e6 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -42,8 +42,7 @@ | |||
42 | #include <linux/slab.h> | 42 | #include <linux/slab.h> |
43 | #include <linux/pm_runtime.h> | 43 | #include <linux/pm_runtime.h> |
44 | #include <linux/sysfs.h> | 44 | #include <linux/sysfs.h> |
45 | #include <acpi/acpi_bus.h> | 45 | #include <linux/acpi.h> |
46 | #include <acpi/acpi_drivers.h> | ||
47 | #include "sleep.h" | 46 | #include "sleep.h" |
48 | #include "internal.h" | 47 | #include "internal.h" |
49 | 48 | ||
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c index 6a5b152ad4d0..50fe34ffe932 100644 --- a/drivers/acpi/proc.c +++ b/drivers/acpi/proc.c | |||
@@ -3,12 +3,11 @@ | |||
3 | #include <linux/export.h> | 3 | #include <linux/export.h> |
4 | #include <linux/suspend.h> | 4 | #include <linux/suspend.h> |
5 | #include <linux/bcd.h> | 5 | #include <linux/bcd.h> |
6 | #include <linux/acpi.h> | ||
6 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
7 | 8 | ||
8 | #include <acpi/acpi_bus.h> | ||
9 | #include <acpi/acpi_drivers.h> | ||
10 | |||
11 | #include "sleep.h" | 9 | #include "sleep.h" |
10 | #include "internal.h" | ||
12 | 11 | ||
13 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 12 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
14 | 13 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index b3171f30b319..34e7b3c6a08d 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -10,8 +10,7 @@ | |||
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/dmi.h> | 11 | #include <linux/dmi.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | 13 | #include <linux/acpi.h> | |
14 | #include <acpi/acpi_drivers.h> | ||
15 | #include <acpi/processor.h> | 14 | #include <acpi/processor.h> |
16 | 15 | ||
17 | #include "internal.h" | 16 | #include "internal.h" |
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 146ab7e2b81d..c1c35623550f 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -224,9 +224,9 @@ static int __acpi_processor_start(struct acpi_device *device) | |||
224 | 224 | ||
225 | static int acpi_processor_start(struct device *dev) | 225 | static int acpi_processor_start(struct device *dev) |
226 | { | 226 | { |
227 | struct acpi_device *device; | 227 | struct acpi_device *device = ACPI_COMPANION(dev); |
228 | 228 | ||
229 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | 229 | if (!device) |
230 | return -ENODEV; | 230 | return -ENODEV; |
231 | 231 | ||
232 | return __acpi_processor_start(device); | 232 | return __acpi_processor_start(device); |
@@ -234,10 +234,10 @@ static int acpi_processor_start(struct device *dev) | |||
234 | 234 | ||
235 | static int acpi_processor_stop(struct device *dev) | 235 | static int acpi_processor_stop(struct device *dev) |
236 | { | 236 | { |
237 | struct acpi_device *device; | 237 | struct acpi_device *device = ACPI_COMPANION(dev); |
238 | struct acpi_processor *pr; | 238 | struct acpi_processor *pr; |
239 | 239 | ||
240 | if (acpi_bus_get_device(ACPI_HANDLE(dev), &device)) | 240 | if (!device) |
241 | return 0; | 241 | return 0; |
242 | 242 | ||
243 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, | 243 | acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 644516d9bde6..799644c3888c 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/clockchips.h> | 35 | #include <linux/clockchips.h> |
36 | #include <linux/cpuidle.h> | 36 | #include <linux/cpuidle.h> |
37 | #include <linux/syscore_ops.h> | 37 | #include <linux/syscore_ops.h> |
38 | #include <acpi/processor.h> | ||
38 | 39 | ||
39 | /* | 40 | /* |
40 | * Include the apic definitions for x86 to have the APIC timer related defines | 41 | * Include the apic definitions for x86 to have the APIC timer related defines |
@@ -46,9 +47,6 @@ | |||
46 | #include <asm/apic.h> | 47 | #include <asm/apic.h> |
47 | #endif | 48 | #endif |
48 | 49 | ||
49 | #include <acpi/acpi_bus.h> | ||
50 | #include <acpi/processor.h> | ||
51 | |||
52 | #define PREFIX "ACPI: " | 50 | #define PREFIX "ACPI: " |
53 | 51 | ||
54 | #define ACPI_PROCESSOR_CLASS "processor" | 52 | #define ACPI_PROCESSOR_CLASS "processor" |
@@ -213,7 +211,7 @@ static int acpi_processor_suspend(void) | |||
213 | 211 | ||
214 | static void acpi_processor_resume(void) | 212 | static void acpi_processor_resume(void) |
215 | { | 213 | { |
216 | u32 resumed_bm_rld; | 214 | u32 resumed_bm_rld = 0; |
217 | 215 | ||
218 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); | 216 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); |
219 | if (resumed_bm_rld == saved_bm_rld) | 217 | if (resumed_bm_rld == saved_bm_rld) |
@@ -598,7 +596,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
598 | case ACPI_STATE_C2: | 596 | case ACPI_STATE_C2: |
599 | if (!cx->address) | 597 | if (!cx->address) |
600 | break; | 598 | break; |
601 | cx->valid = 1; | 599 | cx->valid = 1; |
602 | break; | 600 | break; |
603 | 601 | ||
604 | case ACPI_STATE_C3: | 602 | case ACPI_STATE_C3: |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 60a7c28fc167..ff90054f04fd 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -31,15 +31,12 @@ | |||
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | 34 | #include <linux/acpi.h> | |
35 | #include <acpi/processor.h> | ||
35 | #ifdef CONFIG_X86 | 36 | #ifdef CONFIG_X86 |
36 | #include <asm/cpufeature.h> | 37 | #include <asm/cpufeature.h> |
37 | #endif | 38 | #endif |
38 | 39 | ||
39 | #include <acpi/acpi_bus.h> | ||
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | ||
42 | |||
43 | #define PREFIX "ACPI: " | 40 | #define PREFIX "ACPI: " |
44 | 41 | ||
45 | #define ACPI_PROCESSOR_CLASS "processor" | 42 | #define ACPI_PROCESSOR_CLASS "processor" |
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index d1d2e7fb5b30..e003663b2f8e 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -30,12 +30,9 @@ | |||
30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
31 | #include <linux/init.h> | 31 | #include <linux/init.h> |
32 | #include <linux/cpufreq.h> | 32 | #include <linux/cpufreq.h> |
33 | 33 | #include <linux/acpi.h> | |
34 | #include <asm/uaccess.h> | ||
35 | |||
36 | #include <acpi/acpi_bus.h> | ||
37 | #include <acpi/processor.h> | 34 | #include <acpi/processor.h> |
38 | #include <acpi/acpi_drivers.h> | 35 | #include <asm/uaccess.h> |
39 | 36 | ||
40 | #define PREFIX "ACPI: " | 37 | #define PREFIX "ACPI: " |
41 | 38 | ||
@@ -186,14 +183,14 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state) | |||
186 | 183 | ||
187 | #endif | 184 | #endif |
188 | 185 | ||
189 | /* thermal coolign device callbacks */ | 186 | /* thermal cooling device callbacks */ |
190 | static int acpi_processor_max_state(struct acpi_processor *pr) | 187 | static int acpi_processor_max_state(struct acpi_processor *pr) |
191 | { | 188 | { |
192 | int max_state = 0; | 189 | int max_state = 0; |
193 | 190 | ||
194 | /* | 191 | /* |
195 | * There exists four states according to | 192 | * There exists four states according to |
196 | * cpufreq_thermal_reduction_ptg. 0, 1, 2, 3 | 193 | * cpufreq_thermal_reduction_pctg. 0, 1, 2, 3 |
197 | */ | 194 | */ |
198 | max_state += cpufreq_get_max_state(pr->id); | 195 | max_state += cpufreq_get_max_state(pr->id); |
199 | if (pr->flags.throttling) | 196 | if (pr->flags.throttling) |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index e7dd2c1fee79..28baa05b8018 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -32,14 +32,11 @@ | |||
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/cpufreq.h> | 34 | #include <linux/cpufreq.h> |
35 | 35 | #include <linux/acpi.h> | |
36 | #include <acpi/processor.h> | ||
36 | #include <asm/io.h> | 37 | #include <asm/io.h> |
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | 39 | ||
39 | #include <acpi/acpi_bus.h> | ||
40 | #include <acpi/acpi_drivers.h> | ||
41 | #include <acpi/processor.h> | ||
42 | |||
43 | #define PREFIX "ACPI: " | 40 | #define PREFIX "ACPI: " |
44 | 41 | ||
45 | #define ACPI_PROCESSOR_CLASS "processor" | 42 | #define ACPI_PROCESSOR_CLASS "processor" |
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c index b78bc605837e..26e5b5060523 100644 --- a/drivers/acpi/sbshc.c +++ b/drivers/acpi/sbshc.c | |||
@@ -8,8 +8,7 @@ | |||
8 | * the Free Software Foundation version 2. | 8 | * the Free Software Foundation version 2. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <acpi/acpi_bus.h> | 11 | #include <linux/acpi.h> |
12 | #include <acpi/acpi_drivers.h> | ||
13 | #include <linux/wait.h> | 12 | #include <linux/wait.h> |
14 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
15 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index fd39459926b1..c0f57ff15024 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -12,13 +12,12 @@ | |||
12 | #include <linux/dmi.h> | 12 | #include <linux/dmi.h> |
13 | #include <linux/nls.h> | 13 | #include <linux/nls.h> |
14 | 14 | ||
15 | #include <acpi/acpi_drivers.h> | 15 | #include <asm/pgtable.h> |
16 | 16 | ||
17 | #include "internal.h" | 17 | #include "internal.h" |
18 | 18 | ||
19 | #define _COMPONENT ACPI_BUS_COMPONENT | 19 | #define _COMPONENT ACPI_BUS_COMPONENT |
20 | ACPI_MODULE_NAME("scan"); | 20 | ACPI_MODULE_NAME("scan"); |
21 | #define STRUCT_TO_INT(s) (*((int*)&s)) | ||
22 | extern struct acpi_device *acpi_root; | 21 | extern struct acpi_device *acpi_root; |
23 | 22 | ||
24 | #define ACPI_BUS_CLASS "system_bus" | 23 | #define ACPI_BUS_CLASS "system_bus" |
@@ -27,6 +26,8 @@ extern struct acpi_device *acpi_root; | |||
27 | 26 | ||
28 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) | 27 | #define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent) |
29 | 28 | ||
29 | #define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page) | ||
30 | |||
30 | /* | 31 | /* |
31 | * If set, devices will be hot-removed even if they cannot be put offline | 32 | * If set, devices will be hot-removed even if they cannot be put offline |
32 | * gracefully (from the kernel's standpoint). | 33 | * gracefully (from the kernel's standpoint). |
@@ -125,6 +126,26 @@ acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, cha | |||
125 | } | 126 | } |
126 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); | 127 | static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); |
127 | 128 | ||
129 | bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent) | ||
130 | { | ||
131 | struct acpi_device_physical_node *pn; | ||
132 | bool offline = true; | ||
133 | |||
134 | mutex_lock(&adev->physical_node_lock); | ||
135 | |||
136 | list_for_each_entry(pn, &adev->physical_node_list, node) | ||
137 | if (device_supports_offline(pn->dev) && !pn->dev->offline) { | ||
138 | if (uevent) | ||
139 | kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE); | ||
140 | |||
141 | offline = false; | ||
142 | break; | ||
143 | } | ||
144 | |||
145 | mutex_unlock(&adev->physical_node_lock); | ||
146 | return offline; | ||
147 | } | ||
148 | |||
128 | static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, | 149 | static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data, |
129 | void **ret_p) | 150 | void **ret_p) |
130 | { | 151 | { |
@@ -195,19 +216,11 @@ static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data, | |||
195 | return AE_OK; | 216 | return AE_OK; |
196 | } | 217 | } |
197 | 218 | ||
198 | static int acpi_scan_hot_remove(struct acpi_device *device) | 219 | static int acpi_scan_try_to_offline(struct acpi_device *device) |
199 | { | 220 | { |
200 | acpi_handle handle = device->handle; | 221 | acpi_handle handle = device->handle; |
201 | struct device *errdev; | 222 | struct device *errdev = NULL; |
202 | acpi_status status; | 223 | acpi_status status; |
203 | unsigned long long sta; | ||
204 | |||
205 | /* If there is no handle, the device node has been unregistered. */ | ||
206 | if (!handle) { | ||
207 | dev_dbg(&device->dev, "ACPI handle missing\n"); | ||
208 | put_device(&device->dev); | ||
209 | return -EINVAL; | ||
210 | } | ||
211 | 224 | ||
212 | /* | 225 | /* |
213 | * Carry out two passes here and ignore errors in the first pass, | 226 | * Carry out two passes here and ignore errors in the first pass, |
@@ -218,7 +231,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
218 | * | 231 | * |
219 | * If the first pass is successful, the second one isn't needed, though. | 232 | * If the first pass is successful, the second one isn't needed, though. |
220 | */ | 233 | */ |
221 | errdev = NULL; | ||
222 | status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 234 | status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
223 | NULL, acpi_bus_offline, (void *)false, | 235 | NULL, acpi_bus_offline, (void *)false, |
224 | (void **)&errdev); | 236 | (void **)&errdev); |
@@ -226,7 +238,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
226 | dev_warn(errdev, "Offline disabled.\n"); | 238 | dev_warn(errdev, "Offline disabled.\n"); |
227 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 239 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
228 | acpi_bus_online, NULL, NULL, NULL); | 240 | acpi_bus_online, NULL, NULL, NULL); |
229 | put_device(&device->dev); | ||
230 | return -EPERM; | 241 | return -EPERM; |
231 | } | 242 | } |
232 | acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); | 243 | acpi_bus_offline(handle, 0, (void *)false, (void **)&errdev); |
@@ -245,20 +256,32 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
245 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, | 256 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, |
246 | ACPI_UINT32_MAX, acpi_bus_online, | 257 | ACPI_UINT32_MAX, acpi_bus_online, |
247 | NULL, NULL, NULL); | 258 | NULL, NULL, NULL); |
248 | put_device(&device->dev); | ||
249 | return -EBUSY; | 259 | return -EBUSY; |
250 | } | 260 | } |
251 | } | 261 | } |
262 | return 0; | ||
263 | } | ||
264 | |||
265 | static int acpi_scan_hot_remove(struct acpi_device *device) | ||
266 | { | ||
267 | acpi_handle handle = device->handle; | ||
268 | unsigned long long sta; | ||
269 | acpi_status status; | ||
270 | |||
271 | if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) { | ||
272 | if (!acpi_scan_is_offline(device, true)) | ||
273 | return -EBUSY; | ||
274 | } else { | ||
275 | int error = acpi_scan_try_to_offline(device); | ||
276 | if (error) | ||
277 | return error; | ||
278 | } | ||
252 | 279 | ||
253 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 280 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
254 | "Hot-removing device %s...\n", dev_name(&device->dev))); | 281 | "Hot-removing device %s...\n", dev_name(&device->dev))); |
255 | 282 | ||
256 | acpi_bus_trim(device); | 283 | acpi_bus_trim(device); |
257 | 284 | ||
258 | /* Device node has been unregistered. */ | ||
259 | put_device(&device->dev); | ||
260 | device = NULL; | ||
261 | |||
262 | acpi_evaluate_lck(handle, 0); | 285 | acpi_evaluate_lck(handle, 0); |
263 | /* | 286 | /* |
264 | * TBD: _EJD support. | 287 | * TBD: _EJD support. |
@@ -285,115 +308,127 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
285 | return 0; | 308 | return 0; |
286 | } | 309 | } |
287 | 310 | ||
288 | void acpi_bus_device_eject(void *data, u32 ost_src) | 311 | static int acpi_scan_device_not_present(struct acpi_device *adev) |
289 | { | 312 | { |
290 | struct acpi_device *device = data; | 313 | if (!acpi_device_enumerated(adev)) { |
291 | acpi_handle handle = device->handle; | 314 | dev_warn(&adev->dev, "Still not present\n"); |
292 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 315 | return -EALREADY; |
293 | int error; | 316 | } |
317 | acpi_bus_trim(adev); | ||
318 | return 0; | ||
319 | } | ||
294 | 320 | ||
295 | lock_device_hotplug(); | 321 | static int acpi_scan_device_check(struct acpi_device *adev) |
296 | mutex_lock(&acpi_scan_lock); | 322 | { |
323 | int error; | ||
297 | 324 | ||
298 | if (ost_src == ACPI_NOTIFY_EJECT_REQUEST) | 325 | acpi_bus_get_status(adev); |
299 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, | 326 | if (adev->status.present || adev->status.functional) { |
300 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | 327 | /* |
328 | * This function is only called for device objects for which | ||
329 | * matching scan handlers exist. The only situation in which | ||
330 | * the scan handler is not attached to this device object yet | ||
331 | * is when the device has just appeared (either it wasn't | ||
332 | * present at all before or it was removed and then added | ||
333 | * again). | ||
334 | */ | ||
335 | if (adev->handler) { | ||
336 | dev_warn(&adev->dev, "Already enumerated\n"); | ||
337 | return -EALREADY; | ||
338 | } | ||
339 | error = acpi_bus_scan(adev->handle); | ||
340 | if (error) { | ||
341 | dev_warn(&adev->dev, "Namespace scan failure\n"); | ||
342 | return error; | ||
343 | } | ||
344 | if (!adev->handler) { | ||
345 | dev_warn(&adev->dev, "Enumeration failure\n"); | ||
346 | error = -ENODEV; | ||
347 | } | ||
348 | } else { | ||
349 | error = acpi_scan_device_not_present(adev); | ||
350 | } | ||
351 | return error; | ||
352 | } | ||
301 | 353 | ||
302 | if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) | 354 | static int acpi_scan_bus_check(struct acpi_device *adev) |
303 | kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); | 355 | { |
356 | struct acpi_scan_handler *handler = adev->handler; | ||
357 | struct acpi_device *child; | ||
358 | int error; | ||
304 | 359 | ||
305 | error = acpi_scan_hot_remove(device); | 360 | acpi_bus_get_status(adev); |
306 | if (error == -EPERM) { | 361 | if (!(adev->status.present || adev->status.functional)) { |
307 | goto err_support; | 362 | acpi_scan_device_not_present(adev); |
308 | } else if (error) { | 363 | return 0; |
309 | goto err_out; | ||
310 | } | 364 | } |
365 | if (handler && handler->hotplug.scan_dependent) | ||
366 | return handler->hotplug.scan_dependent(adev); | ||
311 | 367 | ||
312 | out: | 368 | error = acpi_bus_scan(adev->handle); |
313 | mutex_unlock(&acpi_scan_lock); | 369 | if (error) { |
314 | unlock_device_hotplug(); | 370 | dev_warn(&adev->dev, "Namespace scan failure\n"); |
315 | return; | 371 | return error; |
316 | 372 | } | |
317 | err_support: | 373 | list_for_each_entry(child, &adev->children, node) { |
318 | ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | 374 | error = acpi_scan_bus_check(child); |
319 | err_out: | 375 | if (error) |
320 | acpi_evaluate_hotplug_ost(handle, ost_src, ost_code, NULL); | 376 | return error; |
321 | goto out; | 377 | } |
378 | return 0; | ||
322 | } | 379 | } |
323 | 380 | ||
324 | static void acpi_scan_bus_device_check(void *data, u32 ost_source) | 381 | static void acpi_device_hotplug(void *data, u32 src) |
325 | { | 382 | { |
326 | acpi_handle handle = data; | ||
327 | struct acpi_device *device = NULL; | ||
328 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 383 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; |
384 | struct acpi_device *adev = data; | ||
329 | int error; | 385 | int error; |
330 | 386 | ||
331 | lock_device_hotplug(); | 387 | lock_device_hotplug(); |
332 | mutex_lock(&acpi_scan_lock); | 388 | mutex_lock(&acpi_scan_lock); |
333 | 389 | ||
334 | if (ost_source != ACPI_NOTIFY_BUS_CHECK) { | 390 | /* |
335 | acpi_bus_get_device(handle, &device); | 391 | * The device object's ACPI handle cannot become invalid as long as we |
336 | if (device) { | 392 | * are holding acpi_scan_lock, but it may have become invalid before |
337 | dev_warn(&device->dev, "Attempt to re-insert\n"); | 393 | * that lock was acquired. |
338 | goto out; | 394 | */ |
339 | } | 395 | if (adev->handle == INVALID_ACPI_HANDLE) |
340 | } | ||
341 | error = acpi_bus_scan(handle); | ||
342 | if (error) { | ||
343 | acpi_handle_warn(handle, "Namespace scan failure\n"); | ||
344 | goto out; | ||
345 | } | ||
346 | error = acpi_bus_get_device(handle, &device); | ||
347 | if (error) { | ||
348 | acpi_handle_warn(handle, "Missing device node object\n"); | ||
349 | goto out; | 396 | goto out; |
350 | } | ||
351 | ost_code = ACPI_OST_SC_SUCCESS; | ||
352 | if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) | ||
353 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | ||
354 | |||
355 | out: | ||
356 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); | ||
357 | mutex_unlock(&acpi_scan_lock); | ||
358 | unlock_device_hotplug(); | ||
359 | } | ||
360 | |||
361 | static void acpi_hotplug_unsupported(acpi_handle handle, u32 type) | ||
362 | { | ||
363 | u32 ost_status; | ||
364 | 397 | ||
365 | switch (type) { | 398 | switch (src) { |
366 | case ACPI_NOTIFY_BUS_CHECK: | 399 | case ACPI_NOTIFY_BUS_CHECK: |
367 | acpi_handle_debug(handle, | 400 | error = acpi_scan_bus_check(adev); |
368 | "ACPI_NOTIFY_BUS_CHECK event: unsupported\n"); | ||
369 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
370 | break; | 401 | break; |
371 | case ACPI_NOTIFY_DEVICE_CHECK: | 402 | case ACPI_NOTIFY_DEVICE_CHECK: |
372 | acpi_handle_debug(handle, | 403 | error = acpi_scan_device_check(adev); |
373 | "ACPI_NOTIFY_DEVICE_CHECK event: unsupported\n"); | ||
374 | ost_status = ACPI_OST_SC_INSERT_NOT_SUPPORTED; | ||
375 | break; | 404 | break; |
376 | case ACPI_NOTIFY_EJECT_REQUEST: | 405 | case ACPI_NOTIFY_EJECT_REQUEST: |
377 | acpi_handle_debug(handle, | 406 | case ACPI_OST_EC_OSPM_EJECT: |
378 | "ACPI_NOTIFY_EJECT_REQUEST event: unsupported\n"); | 407 | error = acpi_scan_hot_remove(adev); |
379 | ost_status = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
380 | break; | 408 | break; |
381 | default: | 409 | default: |
382 | /* non-hotplug event; possibly handled by other handler */ | 410 | error = -EINVAL; |
383 | return; | 411 | break; |
384 | } | 412 | } |
413 | if (!error) | ||
414 | ost_code = ACPI_OST_SC_SUCCESS; | ||
385 | 415 | ||
386 | acpi_evaluate_hotplug_ost(handle, type, ost_status, NULL); | 416 | out: |
417 | acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL); | ||
418 | put_device(&adev->dev); | ||
419 | mutex_unlock(&acpi_scan_lock); | ||
420 | unlock_device_hotplug(); | ||
387 | } | 421 | } |
388 | 422 | ||
389 | static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) | 423 | static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) |
390 | { | 424 | { |
425 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | ||
391 | struct acpi_scan_handler *handler = data; | 426 | struct acpi_scan_handler *handler = data; |
392 | struct acpi_device *adev; | 427 | struct acpi_device *adev; |
393 | acpi_status status; | 428 | acpi_status status; |
394 | 429 | ||
395 | if (!handler->hotplug.enabled) | 430 | if (acpi_bus_get_device(handle, &adev)) |
396 | return acpi_hotplug_unsupported(handle, type); | 431 | goto err_out; |
397 | 432 | ||
398 | switch (type) { | 433 | switch (type) { |
399 | case ACPI_NOTIFY_BUS_CHECK: | 434 | case ACPI_NOTIFY_BUS_CHECK: |
@@ -404,27 +439,27 @@ static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data) | |||
404 | break; | 439 | break; |
405 | case ACPI_NOTIFY_EJECT_REQUEST: | 440 | case ACPI_NOTIFY_EJECT_REQUEST: |
406 | acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); | 441 | acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n"); |
407 | if (acpi_bus_get_device(handle, &adev)) | 442 | if (!handler->hotplug.enabled) { |
443 | acpi_handle_err(handle, "Eject disabled\n"); | ||
444 | ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; | ||
408 | goto err_out; | 445 | goto err_out; |
409 | 446 | } | |
410 | get_device(&adev->dev); | 447 | acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, |
411 | status = acpi_hotplug_execute(acpi_bus_device_eject, adev, type); | 448 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); |
412 | if (ACPI_SUCCESS(status)) | 449 | break; |
413 | return; | ||
414 | |||
415 | put_device(&adev->dev); | ||
416 | goto err_out; | ||
417 | default: | 450 | default: |
418 | /* non-hotplug event; possibly handled by other handler */ | 451 | /* non-hotplug event; possibly handled by other handler */ |
419 | return; | 452 | return; |
420 | } | 453 | } |
421 | status = acpi_hotplug_execute(acpi_scan_bus_device_check, handle, type); | 454 | get_device(&adev->dev); |
455 | status = acpi_hotplug_execute(acpi_device_hotplug, adev, type); | ||
422 | if (ACPI_SUCCESS(status)) | 456 | if (ACPI_SUCCESS(status)) |
423 | return; | 457 | return; |
424 | 458 | ||
459 | put_device(&adev->dev); | ||
460 | |||
425 | err_out: | 461 | err_out: |
426 | acpi_evaluate_hotplug_ost(handle, type, | 462 | acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); |
427 | ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); | ||
428 | } | 463 | } |
429 | 464 | ||
430 | static ssize_t real_power_state_show(struct device *dev, | 465 | static ssize_t real_power_state_show(struct device *dev, |
@@ -475,7 +510,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr, | |||
475 | acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, | 510 | acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, |
476 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); | 511 | ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); |
477 | get_device(&acpi_device->dev); | 512 | get_device(&acpi_device->dev); |
478 | status = acpi_hotplug_execute(acpi_bus_device_eject, acpi_device, | 513 | status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device, |
479 | ACPI_OST_EC_OSPM_EJECT); | 514 | ACPI_OST_EC_OSPM_EJECT); |
480 | if (ACPI_SUCCESS(status)) | 515 | if (ACPI_SUCCESS(status)) |
481 | return count; | 516 | return count; |
@@ -567,6 +602,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr, | |||
567 | } | 602 | } |
568 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); | 603 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); |
569 | 604 | ||
605 | static ssize_t status_show(struct device *dev, struct device_attribute *attr, | ||
606 | char *buf) { | ||
607 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
608 | acpi_status status; | ||
609 | unsigned long long sta; | ||
610 | |||
611 | status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta); | ||
612 | if (ACPI_FAILURE(status)) | ||
613 | return -ENODEV; | ||
614 | |||
615 | return sprintf(buf, "%llu\n", sta); | ||
616 | } | ||
617 | static DEVICE_ATTR_RO(status); | ||
618 | |||
570 | static int acpi_device_setup_files(struct acpi_device *dev) | 619 | static int acpi_device_setup_files(struct acpi_device *dev) |
571 | { | 620 | { |
572 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 621 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -622,6 +671,12 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
622 | dev->pnp.sun = (unsigned long)-1; | 671 | dev->pnp.sun = (unsigned long)-1; |
623 | } | 672 | } |
624 | 673 | ||
674 | if (acpi_has_method(dev->handle, "_STA")) { | ||
675 | result = device_create_file(&dev->dev, &dev_attr_status); | ||
676 | if (result) | ||
677 | goto end; | ||
678 | } | ||
679 | |||
625 | /* | 680 | /* |
626 | * If device has _EJ0, 'eject' file is created that is used to trigger | 681 | * If device has _EJ0, 'eject' file is created that is used to trigger |
627 | * hot-removal function from userland. | 682 | * hot-removal function from userland. |
@@ -677,6 +732,8 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
677 | device_remove_file(&dev->dev, &dev_attr_adr); | 732 | device_remove_file(&dev->dev, &dev_attr_adr); |
678 | device_remove_file(&dev->dev, &dev_attr_modalias); | 733 | device_remove_file(&dev->dev, &dev_attr_modalias); |
679 | device_remove_file(&dev->dev, &dev_attr_hid); | 734 | device_remove_file(&dev->dev, &dev_attr_hid); |
735 | if (acpi_has_method(dev->handle, "_STA")) | ||
736 | device_remove_file(&dev->dev, &dev_attr_status); | ||
680 | if (dev->handle) | 737 | if (dev->handle) |
681 | device_remove_file(&dev->dev, &dev_attr_path); | 738 | device_remove_file(&dev->dev, &dev_attr_path); |
682 | } | 739 | } |
@@ -907,9 +964,91 @@ struct bus_type acpi_bus_type = { | |||
907 | .uevent = acpi_device_uevent, | 964 | .uevent = acpi_device_uevent, |
908 | }; | 965 | }; |
909 | 966 | ||
910 | static void acpi_bus_data_handler(acpi_handle handle, void *context) | 967 | static void acpi_device_del(struct acpi_device *device) |
911 | { | 968 | { |
912 | /* Intentionally empty. */ | 969 | mutex_lock(&acpi_device_lock); |
970 | if (device->parent) | ||
971 | list_del(&device->node); | ||
972 | |||
973 | list_del(&device->wakeup_list); | ||
974 | mutex_unlock(&acpi_device_lock); | ||
975 | |||
976 | acpi_power_add_remove_device(device, false); | ||
977 | acpi_device_remove_files(device); | ||
978 | if (device->remove) | ||
979 | device->remove(device); | ||
980 | |||
981 | device_del(&device->dev); | ||
982 | } | ||
983 | |||
984 | static LIST_HEAD(acpi_device_del_list); | ||
985 | static DEFINE_MUTEX(acpi_device_del_lock); | ||
986 | |||
987 | static void acpi_device_del_work_fn(struct work_struct *work_not_used) | ||
988 | { | ||
989 | for (;;) { | ||
990 | struct acpi_device *adev; | ||
991 | |||
992 | mutex_lock(&acpi_device_del_lock); | ||
993 | |||
994 | if (list_empty(&acpi_device_del_list)) { | ||
995 | mutex_unlock(&acpi_device_del_lock); | ||
996 | break; | ||
997 | } | ||
998 | adev = list_first_entry(&acpi_device_del_list, | ||
999 | struct acpi_device, del_list); | ||
1000 | list_del(&adev->del_list); | ||
1001 | |||
1002 | mutex_unlock(&acpi_device_del_lock); | ||
1003 | |||
1004 | acpi_device_del(adev); | ||
1005 | /* | ||
1006 | * Drop references to all power resources that might have been | ||
1007 | * used by the device. | ||
1008 | */ | ||
1009 | acpi_power_transition(adev, ACPI_STATE_D3_COLD); | ||
1010 | put_device(&adev->dev); | ||
1011 | } | ||
1012 | } | ||
1013 | |||
1014 | /** | ||
1015 | * acpi_scan_drop_device - Drop an ACPI device object. | ||
1016 | * @handle: Handle of an ACPI namespace node, not used. | ||
1017 | * @context: Address of the ACPI device object to drop. | ||
1018 | * | ||
1019 | * This is invoked by acpi_ns_delete_node() during the removal of the ACPI | ||
1020 | * namespace node the device object pointed to by @context is attached to. | ||
1021 | * | ||
1022 | * The unregistration is carried out asynchronously to avoid running | ||
1023 | * acpi_device_del() under the ACPICA's namespace mutex and the list is used to | ||
1024 | * ensure the correct ordering (the device objects must be unregistered in the | ||
1025 | * same order in which the corresponding namespace nodes are deleted). | ||
1026 | */ | ||
1027 | static void acpi_scan_drop_device(acpi_handle handle, void *context) | ||
1028 | { | ||
1029 | static DECLARE_WORK(work, acpi_device_del_work_fn); | ||
1030 | struct acpi_device *adev = context; | ||
1031 | |||
1032 | mutex_lock(&acpi_device_del_lock); | ||
1033 | |||
1034 | /* | ||
1035 | * Use the ACPI hotplug workqueue which is ordered, so this work item | ||
1036 | * won't run after any hotplug work items submitted subsequently. That | ||
1037 | * prevents attempts to register device objects identical to those being | ||
1038 | * deleted from happening concurrently (such attempts result from | ||
1039 | * hotplug events handled via the ACPI hotplug workqueue). It also will | ||
1040 | * run after all of the work items submitted previosuly, which helps | ||
1041 | * those work items to ensure that they are not accessing stale device | ||
1042 | * objects. | ||
1043 | */ | ||
1044 | if (list_empty(&acpi_device_del_list)) | ||
1045 | acpi_queue_hotplug_work(&work); | ||
1046 | |||
1047 | list_add_tail(&adev->del_list, &acpi_device_del_list); | ||
1048 | /* Make acpi_ns_validate_handle() return NULL for this handle. */ | ||
1049 | adev->handle = INVALID_ACPI_HANDLE; | ||
1050 | |||
1051 | mutex_unlock(&acpi_device_del_lock); | ||
913 | } | 1052 | } |
914 | 1053 | ||
915 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | 1054 | int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) |
@@ -919,7 +1058,7 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) | |||
919 | if (!device) | 1058 | if (!device) |
920 | return -EINVAL; | 1059 | return -EINVAL; |
921 | 1060 | ||
922 | status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); | 1061 | status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device); |
923 | if (ACPI_FAILURE(status) || !*device) { | 1062 | if (ACPI_FAILURE(status) || !*device) { |
924 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", | 1063 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", |
925 | handle)); | 1064 | handle)); |
@@ -939,7 +1078,7 @@ int acpi_device_add(struct acpi_device *device, | |||
939 | if (device->handle) { | 1078 | if (device->handle) { |
940 | acpi_status status; | 1079 | acpi_status status; |
941 | 1080 | ||
942 | status = acpi_attach_data(device->handle, acpi_bus_data_handler, | 1081 | status = acpi_attach_data(device->handle, acpi_scan_drop_device, |
943 | device); | 1082 | device); |
944 | if (ACPI_FAILURE(status)) { | 1083 | if (ACPI_FAILURE(status)) { |
945 | acpi_handle_err(device->handle, | 1084 | acpi_handle_err(device->handle, |
@@ -957,6 +1096,7 @@ int acpi_device_add(struct acpi_device *device, | |||
957 | INIT_LIST_HEAD(&device->node); | 1096 | INIT_LIST_HEAD(&device->node); |
958 | INIT_LIST_HEAD(&device->wakeup_list); | 1097 | INIT_LIST_HEAD(&device->wakeup_list); |
959 | INIT_LIST_HEAD(&device->physical_node_list); | 1098 | INIT_LIST_HEAD(&device->physical_node_list); |
1099 | INIT_LIST_HEAD(&device->del_list); | ||
960 | mutex_init(&device->physical_node_lock); | 1100 | mutex_init(&device->physical_node_lock); |
961 | 1101 | ||
962 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 1102 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
@@ -1020,37 +1160,10 @@ int acpi_device_add(struct acpi_device *device, | |||
1020 | mutex_unlock(&acpi_device_lock); | 1160 | mutex_unlock(&acpi_device_lock); |
1021 | 1161 | ||
1022 | err_detach: | 1162 | err_detach: |
1023 | acpi_detach_data(device->handle, acpi_bus_data_handler); | 1163 | acpi_detach_data(device->handle, acpi_scan_drop_device); |
1024 | return result; | 1164 | return result; |
1025 | } | 1165 | } |
1026 | 1166 | ||
1027 | static void acpi_device_unregister(struct acpi_device *device) | ||
1028 | { | ||
1029 | mutex_lock(&acpi_device_lock); | ||
1030 | if (device->parent) | ||
1031 | list_del(&device->node); | ||
1032 | |||
1033 | list_del(&device->wakeup_list); | ||
1034 | mutex_unlock(&acpi_device_lock); | ||
1035 | |||
1036 | acpi_detach_data(device->handle, acpi_bus_data_handler); | ||
1037 | |||
1038 | acpi_power_add_remove_device(device, false); | ||
1039 | acpi_device_remove_files(device); | ||
1040 | if (device->remove) | ||
1041 | device->remove(device); | ||
1042 | |||
1043 | device_del(&device->dev); | ||
1044 | /* | ||
1045 | * Transition the device to D3cold to drop the reference counts of all | ||
1046 | * power resources the device depends on and turn off the ones that have | ||
1047 | * no more references. | ||
1048 | */ | ||
1049 | acpi_device_set_power(device, ACPI_STATE_D3_COLD); | ||
1050 | device->handle = NULL; | ||
1051 | put_device(&device->dev); | ||
1052 | } | ||
1053 | |||
1054 | /* -------------------------------------------------------------------------- | 1167 | /* -------------------------------------------------------------------------- |
1055 | Driver Management | 1168 | Driver Management |
1056 | -------------------------------------------------------------------------- */ | 1169 | -------------------------------------------------------------------------- */ |
@@ -1624,11 +1737,13 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, | |||
1624 | device->device_type = type; | 1737 | device->device_type = type; |
1625 | device->handle = handle; | 1738 | device->handle = handle; |
1626 | device->parent = acpi_bus_get_parent(handle); | 1739 | device->parent = acpi_bus_get_parent(handle); |
1627 | STRUCT_TO_INT(device->status) = sta; | 1740 | acpi_set_device_status(device, sta); |
1628 | acpi_device_get_busid(device); | 1741 | acpi_device_get_busid(device); |
1629 | acpi_set_pnp_ids(handle, &device->pnp, type); | 1742 | acpi_set_pnp_ids(handle, &device->pnp, type); |
1630 | acpi_bus_get_flags(device); | 1743 | acpi_bus_get_flags(device); |
1631 | device->flags.match_driver = false; | 1744 | device->flags.match_driver = false; |
1745 | device->flags.initialized = true; | ||
1746 | device->flags.visited = false; | ||
1632 | device_initialize(&device->dev); | 1747 | device_initialize(&device->dev); |
1633 | dev_set_uevent_suppress(&device->dev, true); | 1748 | dev_set_uevent_suppress(&device->dev, true); |
1634 | } | 1749 | } |
@@ -1713,6 +1828,15 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type, | |||
1713 | return 0; | 1828 | return 0; |
1714 | } | 1829 | } |
1715 | 1830 | ||
1831 | bool acpi_device_is_present(struct acpi_device *adev) | ||
1832 | { | ||
1833 | if (adev->status.present || adev->status.functional) | ||
1834 | return true; | ||
1835 | |||
1836 | adev->flags.initialized = false; | ||
1837 | return false; | ||
1838 | } | ||
1839 | |||
1716 | static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, | 1840 | static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, |
1717 | char *idstr, | 1841 | char *idstr, |
1718 | const struct acpi_device_id **matchid) | 1842 | const struct acpi_device_id **matchid) |
@@ -1772,7 +1896,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type) | |||
1772 | */ | 1896 | */ |
1773 | list_for_each_entry(hwid, &pnp.ids, list) { | 1897 | list_for_each_entry(hwid, &pnp.ids, list) { |
1774 | handler = acpi_scan_match_handler(hwid->id, NULL); | 1898 | handler = acpi_scan_match_handler(hwid->id, NULL); |
1775 | if (handler && !handler->hotplug.ignore) { | 1899 | if (handler) { |
1776 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1900 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1777 | acpi_hotplug_notify_cb, handler); | 1901 | acpi_hotplug_notify_cb, handler); |
1778 | break; | 1902 | break; |
@@ -1806,18 +1930,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, | |||
1806 | 1930 | ||
1807 | acpi_scan_init_hotplug(handle, type); | 1931 | acpi_scan_init_hotplug(handle, type); |
1808 | 1932 | ||
1809 | if (!(sta & ACPI_STA_DEVICE_PRESENT) && | ||
1810 | !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { | ||
1811 | struct acpi_device_wakeup wakeup; | ||
1812 | |||
1813 | if (acpi_has_method(handle, "_PRW")) { | ||
1814 | acpi_bus_extract_wakeup_device_power_package(handle, | ||
1815 | &wakeup); | ||
1816 | acpi_power_resources_list_free(&wakeup.resources); | ||
1817 | } | ||
1818 | return AE_CTRL_DEPTH; | ||
1819 | } | ||
1820 | |||
1821 | acpi_add_single_object(&device, handle, type, sta); | 1933 | acpi_add_single_object(&device, handle, type, sta); |
1822 | if (!device) | 1934 | if (!device) |
1823 | return AE_CTRL_DEPTH; | 1935 | return AE_CTRL_DEPTH; |
@@ -1852,36 +1964,40 @@ static int acpi_scan_attach_handler(struct acpi_device *device) | |||
1852 | return ret; | 1964 | return ret; |
1853 | } | 1965 | } |
1854 | 1966 | ||
1855 | static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, | 1967 | static void acpi_bus_attach(struct acpi_device *device) |
1856 | void *not_used, void **ret_not_used) | ||
1857 | { | 1968 | { |
1858 | struct acpi_device *device; | 1969 | struct acpi_device *child; |
1859 | unsigned long long sta_not_used; | ||
1860 | int ret; | 1970 | int ret; |
1861 | 1971 | ||
1862 | /* | 1972 | acpi_bus_get_status(device); |
1863 | * Ignore errors ignored by acpi_bus_check_add() to avoid terminating | 1973 | /* Skip devices that are not present. */ |
1864 | * namespace walks prematurely. | 1974 | if (!acpi_device_is_present(device)) { |
1865 | */ | 1975 | device->flags.visited = false; |
1866 | if (acpi_bus_type_and_status(handle, &ret, &sta_not_used)) | 1976 | return; |
1867 | return AE_OK; | 1977 | } |
1868 | |||
1869 | if (acpi_bus_get_device(handle, &device)) | ||
1870 | return AE_CTRL_DEPTH; | ||
1871 | |||
1872 | if (device->handler) | 1978 | if (device->handler) |
1873 | return AE_OK; | 1979 | goto ok; |
1874 | 1980 | ||
1981 | if (!device->flags.initialized) { | ||
1982 | acpi_bus_update_power(device, NULL); | ||
1983 | device->flags.initialized = true; | ||
1984 | } | ||
1985 | device->flags.visited = false; | ||
1875 | ret = acpi_scan_attach_handler(device); | 1986 | ret = acpi_scan_attach_handler(device); |
1876 | if (ret < 0) | 1987 | if (ret < 0) |
1877 | return AE_CTRL_DEPTH; | 1988 | return; |
1878 | 1989 | ||
1879 | device->flags.match_driver = true; | 1990 | device->flags.match_driver = true; |
1880 | if (ret > 0) | 1991 | if (!ret) { |
1881 | return AE_OK; | 1992 | ret = device_attach(&device->dev); |
1993 | if (ret < 0) | ||
1994 | return; | ||
1995 | } | ||
1996 | device->flags.visited = true; | ||
1882 | 1997 | ||
1883 | ret = device_attach(&device->dev); | 1998 | ok: |
1884 | return ret >= 0 ? AE_OK : AE_CTRL_DEPTH; | 1999 | list_for_each_entry(child, &device->children, node) |
2000 | acpi_bus_attach(child); | ||
1885 | } | 2001 | } |
1886 | 2002 | ||
1887 | /** | 2003 | /** |
@@ -1901,75 +2017,48 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, | |||
1901 | int acpi_bus_scan(acpi_handle handle) | 2017 | int acpi_bus_scan(acpi_handle handle) |
1902 | { | 2018 | { |
1903 | void *device = NULL; | 2019 | void *device = NULL; |
1904 | int error = 0; | ||
1905 | 2020 | ||
1906 | if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) | 2021 | if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) |
1907 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | 2022 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, |
1908 | acpi_bus_check_add, NULL, NULL, &device); | 2023 | acpi_bus_check_add, NULL, NULL, &device); |
1909 | 2024 | ||
1910 | if (!device) | 2025 | if (device) { |
1911 | error = -ENODEV; | 2026 | acpi_bus_attach(device); |
1912 | else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) | 2027 | return 0; |
1913 | acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, | ||
1914 | acpi_bus_device_attach, NULL, NULL, NULL); | ||
1915 | |||
1916 | return error; | ||
1917 | } | ||
1918 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1919 | |||
1920 | static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, | ||
1921 | void *not_used, void **ret_not_used) | ||
1922 | { | ||
1923 | struct acpi_device *device = NULL; | ||
1924 | |||
1925 | if (!acpi_bus_get_device(handle, &device)) { | ||
1926 | struct acpi_scan_handler *dev_handler = device->handler; | ||
1927 | |||
1928 | if (dev_handler) { | ||
1929 | if (dev_handler->detach) | ||
1930 | dev_handler->detach(device); | ||
1931 | |||
1932 | device->handler = NULL; | ||
1933 | } else { | ||
1934 | device_release_driver(&device->dev); | ||
1935 | } | ||
1936 | } | 2028 | } |
1937 | return AE_OK; | 2029 | return -ENODEV; |
1938 | } | ||
1939 | |||
1940 | static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used, | ||
1941 | void *not_used, void **ret_not_used) | ||
1942 | { | ||
1943 | struct acpi_device *device = NULL; | ||
1944 | |||
1945 | if (!acpi_bus_get_device(handle, &device)) | ||
1946 | acpi_device_unregister(device); | ||
1947 | |||
1948 | return AE_OK; | ||
1949 | } | 2030 | } |
2031 | EXPORT_SYMBOL(acpi_bus_scan); | ||
1950 | 2032 | ||
1951 | /** | 2033 | /** |
1952 | * acpi_bus_trim - Remove ACPI device node and all of its descendants | 2034 | * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. |
1953 | * @start: Root of the ACPI device nodes subtree to remove. | 2035 | * @adev: Root of the ACPI namespace scope to walk. |
1954 | * | 2036 | * |
1955 | * Must be called under acpi_scan_lock. | 2037 | * Must be called under acpi_scan_lock. |
1956 | */ | 2038 | */ |
1957 | void acpi_bus_trim(struct acpi_device *start) | 2039 | void acpi_bus_trim(struct acpi_device *adev) |
1958 | { | 2040 | { |
2041 | struct acpi_scan_handler *handler = adev->handler; | ||
2042 | struct acpi_device *child; | ||
2043 | |||
2044 | list_for_each_entry_reverse(child, &adev->children, node) | ||
2045 | acpi_bus_trim(child); | ||
2046 | |||
2047 | if (handler) { | ||
2048 | if (handler->detach) | ||
2049 | handler->detach(adev); | ||
2050 | |||
2051 | adev->handler = NULL; | ||
2052 | } else { | ||
2053 | device_release_driver(&adev->dev); | ||
2054 | } | ||
1959 | /* | 2055 | /* |
1960 | * Execute acpi_bus_device_detach() as a post-order callback to detach | 2056 | * Most likely, the device is going away, so put it into D3cold before |
1961 | * all ACPI drivers from the device nodes being removed. | 2057 | * that. |
1962 | */ | ||
1963 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, | ||
1964 | acpi_bus_device_detach, NULL, NULL); | ||
1965 | acpi_bus_device_detach(start->handle, 0, NULL, NULL); | ||
1966 | /* | ||
1967 | * Execute acpi_bus_remove() as a post-order callback to remove device | ||
1968 | * nodes in the given namespace scope. | ||
1969 | */ | 2058 | */ |
1970 | acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, | 2059 | acpi_device_set_power(adev, ACPI_STATE_D3_COLD); |
1971 | acpi_bus_remove, NULL, NULL); | 2060 | adev->flags.initialized = false; |
1972 | acpi_bus_remove(start->handle, 0, NULL, NULL); | 2061 | adev->flags.visited = false; |
1973 | } | 2062 | } |
1974 | EXPORT_SYMBOL_GPL(acpi_bus_trim); | 2063 | EXPORT_SYMBOL_GPL(acpi_bus_trim); |
1975 | 2064 | ||
@@ -2047,14 +2136,14 @@ int __init acpi_scan_init(void) | |||
2047 | 2136 | ||
2048 | result = acpi_bus_scan_fixed(); | 2137 | result = acpi_bus_scan_fixed(); |
2049 | if (result) { | 2138 | if (result) { |
2050 | acpi_device_unregister(acpi_root); | 2139 | acpi_detach_data(acpi_root->handle, acpi_scan_drop_device); |
2140 | acpi_device_del(acpi_root); | ||
2141 | put_device(&acpi_root->dev); | ||
2051 | goto out; | 2142 | goto out; |
2052 | } | 2143 | } |
2053 | 2144 | ||
2054 | acpi_update_all_gpes(); | 2145 | acpi_update_all_gpes(); |
2055 | 2146 | ||
2056 | acpi_pci_root_hp_init(); | ||
2057 | |||
2058 | out: | 2147 | out: |
2059 | mutex_unlock(&acpi_scan_lock); | 2148 | mutex_unlock(&acpi_scan_lock); |
2060 | return result; | 2149 | return result; |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 721e949e606e..54ab26664039 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -18,12 +18,8 @@ | |||
18 | #include <linux/reboot.h> | 18 | #include <linux/reboot.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | |||
22 | #include <asm/io.h> | 21 | #include <asm/io.h> |
23 | 22 | ||
24 | #include <acpi/acpi_bus.h> | ||
25 | #include <acpi/acpi_drivers.h> | ||
26 | |||
27 | #include "internal.h" | 23 | #include "internal.h" |
28 | #include "sleep.h" | 24 | #include "sleep.h" |
29 | 25 | ||
@@ -806,9 +802,6 @@ int __init acpi_sleep_init(void) | |||
806 | char *pos = supported; | 802 | char *pos = supported; |
807 | int i; | 803 | int i; |
808 | 804 | ||
809 | if (acpi_disabled) | ||
810 | return 0; | ||
811 | |||
812 | acpi_sleep_dmi_check(); | 805 | acpi_sleep_dmi_check(); |
813 | 806 | ||
814 | sleep_states[ACPI_STATE_S0] = 1; | 807 | sleep_states[ACPI_STATE_S0] = 1; |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 6dbc3ca45223..443dc9366052 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/moduleparam.h> | 7 | #include <linux/moduleparam.h> |
8 | #include <acpi/acpi_drivers.h> | 8 | #include <linux/acpi.h> |
9 | 9 | ||
10 | #include "internal.h" | 10 | #include "internal.h" |
11 | 11 | ||
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index d67a1fe07f0e..5837f857ac2e 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -278,12 +278,13 @@ acpi_table_parse_madt(enum acpi_madt_type id, | |||
278 | 278 | ||
279 | /** | 279 | /** |
280 | * acpi_table_parse - find table with @id, run @handler on it | 280 | * acpi_table_parse - find table with @id, run @handler on it |
281 | * | ||
282 | * @id: table id to find | 281 | * @id: table id to find |
283 | * @handler: handler to run | 282 | * @handler: handler to run |
284 | * | 283 | * |
285 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, | 284 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, |
286 | * run @handler on it. Return 0 if table found, return on if not. | 285 | * run @handler on it. |
286 | * | ||
287 | * Return 0 if table found, -errno if not. | ||
287 | */ | 288 | */ |
288 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | 289 | int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) |
289 | { | 290 | { |
@@ -293,7 +294,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
293 | if (acpi_disabled) | 294 | if (acpi_disabled) |
294 | return -ENODEV; | 295 | return -ENODEV; |
295 | 296 | ||
296 | if (!handler) | 297 | if (!id || !handler) |
297 | return -EINVAL; | 298 | return -EINVAL; |
298 | 299 | ||
299 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) | 300 | if (strncmp(id, ACPI_SIG_MADT, 4) == 0) |
@@ -306,7 +307,7 @@ int __init acpi_table_parse(char *id, acpi_tbl_table_handler handler) | |||
306 | early_acpi_os_unmap_memory(table, tbl_size); | 307 | early_acpi_os_unmap_memory(table, tbl_size); |
307 | return 0; | 308 | return 0; |
308 | } else | 309 | } else |
309 | return 1; | 310 | return -ENODEV; |
310 | } | 311 | } |
311 | 312 | ||
312 | /* | 313 | /* |
@@ -351,7 +352,7 @@ int __init acpi_table_init(void) | |||
351 | 352 | ||
352 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); | 353 | status = acpi_initialize_tables(initial_tables, ACPI_MAX_TABLES, 0); |
353 | if (ACPI_FAILURE(status)) | 354 | if (ACPI_FAILURE(status)) |
354 | return 1; | 355 | return -EINVAL; |
355 | 356 | ||
356 | check_multiple_madt(); | 357 | check_multiple_madt(); |
357 | return 0; | 358 | return 0; |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 0d9f46b5ae6d..1fd21ad69c98 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -41,10 +41,9 @@ | |||
41 | #include <linux/kmod.h> | 41 | #include <linux/kmod.h> |
42 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | #include <asm/uaccess.h> | ||
45 | #include <linux/thermal.h> | 44 | #include <linux/thermal.h> |
46 | #include <acpi/acpi_bus.h> | 45 | #include <linux/acpi.h> |
47 | #include <acpi/acpi_drivers.h> | 46 | #include <asm/uaccess.h> |
48 | 47 | ||
49 | #define PREFIX "ACPI: " | 48 | #define PREFIX "ACPI: " |
50 | 49 | ||
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 6d408bfbbb1d..1336b9151479 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -30,8 +30,6 @@ | |||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/hardirq.h> | 31 | #include <linux/hardirq.h> |
32 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <acpi/acpi_drivers.h> | ||
35 | 33 | ||
36 | #include "internal.h" | 34 | #include "internal.h" |
37 | 35 | ||
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 995e91bcb97b..b727d105046d 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -37,12 +37,11 @@ | |||
37 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
38 | #include <linux/pci_ids.h> | 38 | #include <linux/pci_ids.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <asm/uaccess.h> | ||
41 | #include <linux/dmi.h> | 40 | #include <linux/dmi.h> |
42 | #include <acpi/acpi_bus.h> | ||
43 | #include <acpi/acpi_drivers.h> | ||
44 | #include <linux/suspend.h> | 41 | #include <linux/suspend.h> |
42 | #include <linux/acpi.h> | ||
45 | #include <acpi/video.h> | 43 | #include <acpi/video.h> |
44 | #include <asm/uaccess.h> | ||
46 | 45 | ||
47 | #include "internal.h" | 46 | #include "internal.h" |
48 | 47 | ||
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c index 7bfbe40bc43b..1638401ab282 100644 --- a/drivers/acpi/wakeup.c +++ b/drivers/acpi/wakeup.c | |||
@@ -5,7 +5,6 @@ | |||
5 | 5 | ||
6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
7 | #include <linux/acpi.h> | 7 | #include <linux/acpi.h> |
8 | #include <acpi/acpi_drivers.h> | ||
9 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
10 | #include <linux/types.h> | 9 | #include <linux/types.h> |
11 | 10 | ||