aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-17 08:47:04 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-17 08:47:04 -0400
commitd983f93328041f85e884a586810a67528ae59945 (patch)
treecee4bb57846b237dc63bd111fa2ffe6cbcdc7cba
parentdcb99fd9b08cfe1afe426af4d8d3cbc429190f15 (diff)
parentb8a62d540240387c7e97a69127cab3ab9cadc70a (diff)
Merge branch 'acpi-pci-hotplug'
* acpi-pci-hotplug: (23 commits) ACPI / hotplug / PCI: Use pci_device_is_present() ACPI / hotplug / PCI: Add ACPIPHP contexts to devices handled by PCIeHP ACPI / hotplug / PCI: Rename register_slot() to acpiphp_add_context() ACPI / hotplug / PCI: Execute _EJ0 under the ACPI scan lock ACPI / hotplug / PCI: Rework acpiphp_check_host_bridge() ACPI / hotplug / PCI: Hotplug notifications from acpi_bus_notify() ACPI / hotplug / PCI: Simplify acpi_install_hotplug_notify_handler() ACPI / hotplug / PCI: Rework the handling of eject requests ACPI / hotplug / PCI: Consolidate ACPIPHP with ACPI core hotplug ACPI / hotplug / PCI: Define hotplug context lock in the core ACPI / hotplug: Fix potential race in acpi_bus_notify() ACPICA: Introduce acpi_get_data_full() and rework acpi_get_data() ACPI / hotplug / PCI: Do not pass ACPI handle to hotplug_event() ACPI / hotplug / PCI: Use acpi_handle_debug() in hotplug_event() ACPI / hotplug / PCI: Simplify hotplug_event() ACPI / hotplug / PCI: Drop crit_sect locking ACPI / hotplug / PCI: Drop acpiphp_bus_add() ACPI / hotplug / PCI: Store acpi_device pointer in acpiphp_context ACPI / hotplug / PCI: Rework acpiphp_no_hotplug() ACPI / hotplug / PCI: Drop acpiphp_bus_trim() ...
-rw-r--r--drivers/acpi/acpica/nsxfeval.c33
-rw-r--r--drivers/acpi/bus.c61
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/pci_root.c2
-rw-r--r--drivers/acpi/scan.c181
-rw-r--r--drivers/pci/hotplug/acpiphp.h16
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c441
-rw-r--r--include/acpi/acpi_bus.h27
-rw-r--r--include/acpi/acpixf.h4
-rw-r--r--include/linux/pci-acpi.h4
10 files changed, 353 insertions, 417 deletions
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index 1f0c28ba50df..d6b33bc7bab0 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -923,19 +923,22 @@ ACPI_EXPORT_SYMBOL(acpi_detach_data)
923 923
924/******************************************************************************* 924/*******************************************************************************
925 * 925 *
926 * FUNCTION: acpi_get_data 926 * FUNCTION: acpi_get_data_full
927 * 927 *
928 * PARAMETERS: obj_handle - Namespace node 928 * PARAMETERS: obj_handle - Namespace node
929 * handler - Handler used in call to attach_data 929 * handler - Handler used in call to attach_data
930 * data - Where the data is returned 930 * data - Where the data is returned
931 * callback - function to execute before returning
931 * 932 *
932 * RETURN: Status 933 * RETURN: Status
933 * 934 *
934 * DESCRIPTION: Retrieve data that was previously attached to a namespace node. 935 * DESCRIPTION: Retrieve data that was previously attached to a namespace node
936 * and execute a callback before returning.
935 * 937 *
936 ******************************************************************************/ 938 ******************************************************************************/
937acpi_status 939acpi_status
938acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) 940acpi_get_data_full(acpi_handle obj_handle, acpi_object_handler handler,
941 void **data, void (*callback)(void *))
939{ 942{
940 struct acpi_namespace_node *node; 943 struct acpi_namespace_node *node;
941 acpi_status status; 944 acpi_status status;
@@ -960,10 +963,34 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
960 } 963 }
961 964
962 status = acpi_ns_get_attached_data(node, handler, data); 965 status = acpi_ns_get_attached_data(node, handler, data);
966 if (ACPI_SUCCESS(status) && callback) {
967 callback(*data);
968 }
963 969
964unlock_and_exit: 970unlock_and_exit:
965 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 971 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
966 return (status); 972 return (status);
967} 973}
968 974
975ACPI_EXPORT_SYMBOL(acpi_get_data_full)
976
977/*******************************************************************************
978 *
979 * FUNCTION: acpi_get_data
980 *
981 * PARAMETERS: obj_handle - Namespace node
982 * handler - Handler used in call to attach_data
983 * data - Where the data is returned
984 *
985 * RETURN: Status
986 *
987 * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
988 *
989 ******************************************************************************/
990acpi_status
991acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
992{
993 return acpi_get_data_full(obj_handle, handler, data, NULL);
994}
995
969ACPI_EXPORT_SYMBOL(acpi_get_data) 996ACPI_EXPORT_SYMBOL(acpi_get_data)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index fcb59c21c68d..e61e7b8a2eaf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -340,60 +340,77 @@ static void acpi_bus_osc_support(void)
340 */ 340 */
341static void acpi_bus_notify(acpi_handle handle, u32 type, void *data) 341static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
342{ 342{
343 struct acpi_device *device = NULL; 343 struct acpi_device *adev;
344 struct acpi_driver *driver; 344 struct acpi_driver *driver;
345 345 acpi_status status;
346 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n", 346 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
347 type, handle));
348 347
349 switch (type) { 348 switch (type) {
350
351 case ACPI_NOTIFY_BUS_CHECK: 349 case ACPI_NOTIFY_BUS_CHECK:
352 /* TBD */ 350 acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n");
353 break; 351 break;
354 352
355 case ACPI_NOTIFY_DEVICE_CHECK: 353 case ACPI_NOTIFY_DEVICE_CHECK:
356 /* TBD */ 354 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
357 break; 355 break;
358 356
359 case ACPI_NOTIFY_DEVICE_WAKE: 357 case ACPI_NOTIFY_DEVICE_WAKE:
360 /* TBD */ 358 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_WAKE event\n");
361 break; 359 break;
362 360
363 case ACPI_NOTIFY_EJECT_REQUEST: 361 case ACPI_NOTIFY_EJECT_REQUEST:
364 /* TBD */ 362 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
365 break; 363 break;
366 364
367 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: 365 case ACPI_NOTIFY_DEVICE_CHECK_LIGHT:
366 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK_LIGHT event\n");
368 /* TBD: Exactly what does 'light' mean? */ 367 /* TBD: Exactly what does 'light' mean? */
369 break; 368 break;
370 369
371 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 370 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
372 /* TBD */ 371 acpi_handle_err(handle, "Device cannot be configured due "
372 "to a frequency mismatch\n");
373 break; 373 break;
374 374
375 case ACPI_NOTIFY_BUS_MODE_MISMATCH: 375 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
376 /* TBD */ 376 acpi_handle_err(handle, "Device cannot be configured due "
377 "to a bus mode mismatch\n");
377 break; 378 break;
378 379
379 case ACPI_NOTIFY_POWER_FAULT: 380 case ACPI_NOTIFY_POWER_FAULT:
380 /* TBD */ 381 acpi_handle_err(handle, "Device has suffered a power fault\n");
381 break; 382 break;
382 383
383 default: 384 default:
384 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 385 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
385 "Received unknown/unsupported notification [%08x]\n", 386 ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY;
386 type)); 387 goto err;
387 break;
388 } 388 }
389 389
390 acpi_bus_get_device(handle, &device); 390 adev = acpi_bus_get_acpi_device(handle);
391 if (device) { 391 if (!adev)
392 driver = device->driver; 392 goto err;
393 if (driver && driver->ops.notify && 393
394 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS)) 394 driver = adev->driver;
395 driver->ops.notify(device, type); 395 if (driver && driver->ops.notify &&
396 (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS))
397 driver->ops.notify(adev, type);
398
399 switch (type) {
400 case ACPI_NOTIFY_BUS_CHECK:
401 case ACPI_NOTIFY_DEVICE_CHECK:
402 case ACPI_NOTIFY_EJECT_REQUEST:
403 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
404 if (ACPI_SUCCESS(status))
405 return;
406 default:
407 break;
396 } 408 }
409 acpi_bus_put_acpi_device(adev);
410 return;
411
412 err:
413 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
397} 414}
398 415
399/* -------------------------------------------------------------------------- 416/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index dedbb2d802f1..143d5df5ec32 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -73,6 +73,7 @@ static inline void acpi_lpss_init(void) {}
73#endif 73#endif
74 74
75bool acpi_queue_hotplug_work(struct work_struct *work); 75bool acpi_queue_hotplug_work(struct work_struct *work);
76void acpi_device_hotplug(void *data, u32 src);
76bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); 77bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
77 78
78/* -------------------------------------------------------------------------- 79/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index c1c4102e6478..c288ff3c6998 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -51,7 +51,7 @@ static void acpi_pci_root_remove(struct acpi_device *device);
51 51
52static int acpi_pci_root_scan_dependent(struct acpi_device *adev) 52static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
53{ 53{
54 acpiphp_check_host_bridge(adev->handle); 54 acpiphp_check_host_bridge(adev);
55 return 0; 55 return 0;
56} 56}
57 57
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 57b053f424d1..8bb48bfab1df 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -41,6 +41,7 @@ static DEFINE_MUTEX(acpi_scan_lock);
41static LIST_HEAD(acpi_scan_handlers_list); 41static LIST_HEAD(acpi_scan_handlers_list);
42DEFINE_MUTEX(acpi_device_lock); 42DEFINE_MUTEX(acpi_device_lock);
43LIST_HEAD(acpi_wakeup_device_list); 43LIST_HEAD(acpi_wakeup_device_list);
44static DEFINE_MUTEX(acpi_hp_context_lock);
44 45
45struct acpi_device_bus_id{ 46struct acpi_device_bus_id{
46 char bus_id[15]; 47 char bus_id[15];
@@ -60,6 +61,16 @@ void acpi_scan_lock_release(void)
60} 61}
61EXPORT_SYMBOL_GPL(acpi_scan_lock_release); 62EXPORT_SYMBOL_GPL(acpi_scan_lock_release);
62 63
64void acpi_lock_hp_context(void)
65{
66 mutex_lock(&acpi_hp_context_lock);
67}
68
69void acpi_unlock_hp_context(void)
70{
71 mutex_unlock(&acpi_hp_context_lock);
72}
73
63int acpi_scan_add_handler(struct acpi_scan_handler *handler) 74int acpi_scan_add_handler(struct acpi_scan_handler *handler)
64{ 75{
65 if (!handler || !handler->attach) 76 if (!handler || !handler->attach)
@@ -439,90 +450,74 @@ static int acpi_scan_bus_check(struct acpi_device *adev)
439 return 0; 450 return 0;
440} 451}
441 452
442static void acpi_device_hotplug(void *data, u32 src) 453static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
454{
455 switch (type) {
456 case ACPI_NOTIFY_BUS_CHECK:
457 return acpi_scan_bus_check(adev);
458 case ACPI_NOTIFY_DEVICE_CHECK:
459 return acpi_scan_device_check(adev);
460 case ACPI_NOTIFY_EJECT_REQUEST:
461 case ACPI_OST_EC_OSPM_EJECT:
462 if (adev->handler && !adev->handler->hotplug.enabled) {
463 dev_info(&adev->dev, "Eject disabled\n");
464 return -EPERM;
465 }
466 acpi_evaluate_hotplug_ost(adev->handle, ACPI_NOTIFY_EJECT_REQUEST,
467 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
468 return acpi_scan_hot_remove(adev);
469 }
470 return -EINVAL;
471}
472
473void acpi_device_hotplug(void *data, u32 src)
443{ 474{
444 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 475 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
445 struct acpi_device *adev = data; 476 struct acpi_device *adev = data;
446 int error; 477 int error = -ENODEV;
447 478
448 lock_device_hotplug(); 479 lock_device_hotplug();
449 mutex_lock(&acpi_scan_lock); 480 mutex_lock(&acpi_scan_lock);
450 481
451 /* 482 /*
452 * The device object's ACPI handle cannot become invalid as long as we 483 * The device object's ACPI handle cannot become invalid as long as we
453 * are holding acpi_scan_lock, but it may have become invalid before 484 * are holding acpi_scan_lock, but it might have become invalid before
454 * that lock was acquired. 485 * that lock was acquired.
455 */ 486 */
456 if (adev->handle == INVALID_ACPI_HANDLE) 487 if (adev->handle == INVALID_ACPI_HANDLE)
457 goto out;
458
459 switch (src) {
460 case ACPI_NOTIFY_BUS_CHECK:
461 error = acpi_scan_bus_check(adev);
462 break;
463 case ACPI_NOTIFY_DEVICE_CHECK:
464 error = acpi_scan_device_check(adev);
465 break;
466 case ACPI_NOTIFY_EJECT_REQUEST:
467 case ACPI_OST_EC_OSPM_EJECT:
468 error = acpi_scan_hot_remove(adev);
469 break;
470 default:
471 error = -EINVAL;
472 break;
473 }
474 if (!error)
475 ost_code = ACPI_OST_SC_SUCCESS;
476
477 out:
478 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
479 put_device(&adev->dev);
480 mutex_unlock(&acpi_scan_lock);
481 unlock_device_hotplug();
482}
483
484static void acpi_hotplug_notify_cb(acpi_handle handle, u32 type, void *data)
485{
486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
487 struct acpi_device *adev;
488 acpi_status status;
489
490 if (acpi_bus_get_device(handle, &adev))
491 goto err_out; 488 goto err_out;
492 489
493 switch (type) { 490 if (adev->flags.hotplug_notify) {
494 case ACPI_NOTIFY_BUS_CHECK: 491 error = acpi_generic_hotplug_event(adev, src);
495 acpi_handle_debug(handle, "ACPI_NOTIFY_BUS_CHECK event\n"); 492 if (error == -EPERM) {
496 break;
497 case ACPI_NOTIFY_DEVICE_CHECK:
498 acpi_handle_debug(handle, "ACPI_NOTIFY_DEVICE_CHECK event\n");
499 break;
500 case ACPI_NOTIFY_EJECT_REQUEST:
501 acpi_handle_debug(handle, "ACPI_NOTIFY_EJECT_REQUEST event\n");
502 if (!adev->handler)
503 goto err_out;
504
505 if (!adev->handler->hotplug.enabled) {
506 acpi_handle_err(handle, "Eject disabled\n");
507 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; 493 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
508 goto err_out; 494 goto err_out;
509 } 495 }
510 acpi_evaluate_hotplug_ost(handle, ACPI_NOTIFY_EJECT_REQUEST, 496 } else {
511 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 497 int (*event)(struct acpi_device *, u32);
512 break;
513 default:
514 /* non-hotplug event; possibly handled by other handler */
515 return;
516 }
517 get_device(&adev->dev);
518 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type);
519 if (ACPI_SUCCESS(status))
520 return;
521 498
522 put_device(&adev->dev); 499 acpi_lock_hp_context();
500 event = adev->hp ? adev->hp->event : NULL;
501 acpi_unlock_hp_context();
502 /*
503 * There may be additional notify handlers for device objects
504 * without the .event() callback, so ignore them here.
505 */
506 if (event)
507 error = event(adev, src);
508 else
509 goto out;
510 }
511 if (!error)
512 ost_code = ACPI_OST_SC_SUCCESS;
523 513
524 err_out: 514 err_out:
525 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); 515 acpi_evaluate_hotplug_ost(adev->handle, src, ost_code, NULL);
516
517 out:
518 acpi_bus_put_acpi_device(adev);
519 mutex_unlock(&acpi_scan_lock);
520 unlock_device_hotplug();
526} 521}
527 522
528static ssize_t real_power_state_show(struct device *dev, 523static ssize_t real_power_state_show(struct device *dev,
@@ -570,8 +565,6 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
570 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) 565 if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable)
571 return -ENODEV; 566 return -ENODEV;
572 567
573 acpi_evaluate_hotplug_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT,
574 ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
575 get_device(&acpi_device->dev); 568 get_device(&acpi_device->dev);
576 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device, 569 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device,
577 ACPI_OST_EC_OSPM_EJECT); 570 ACPI_OST_EC_OSPM_EJECT);
@@ -1114,14 +1107,16 @@ static void acpi_scan_drop_device(acpi_handle handle, void *context)
1114 mutex_unlock(&acpi_device_del_lock); 1107 mutex_unlock(&acpi_device_del_lock);
1115} 1108}
1116 1109
1117int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device) 1110static int acpi_get_device_data(acpi_handle handle, struct acpi_device **device,
1111 void (*callback)(void *))
1118{ 1112{
1119 acpi_status status; 1113 acpi_status status;
1120 1114
1121 if (!device) 1115 if (!device)
1122 return -EINVAL; 1116 return -EINVAL;
1123 1117
1124 status = acpi_get_data(handle, acpi_scan_drop_device, (void **)device); 1118 status = acpi_get_data_full(handle, acpi_scan_drop_device,
1119 (void **)device, callback);
1125 if (ACPI_FAILURE(status) || !*device) { 1120 if (ACPI_FAILURE(status) || !*device) {
1126 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n", 1121 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
1127 handle)); 1122 handle));
@@ -1129,8 +1124,32 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
1129 } 1124 }
1130 return 0; 1125 return 0;
1131} 1126}
1127
1128int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
1129{
1130 return acpi_get_device_data(handle, device, NULL);
1131}
1132EXPORT_SYMBOL(acpi_bus_get_device); 1132EXPORT_SYMBOL(acpi_bus_get_device);
1133 1133
1134static void get_acpi_device(void *dev)
1135{
1136 if (dev)
1137 get_device(&((struct acpi_device *)dev)->dev);
1138}
1139
1140struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle)
1141{
1142 struct acpi_device *adev = NULL;
1143
1144 acpi_get_device_data(handle, &adev, get_acpi_device);
1145 return adev;
1146}
1147
1148void acpi_bus_put_acpi_device(struct acpi_device *adev)
1149{
1150 put_device(&adev->dev);
1151}
1152
1134int acpi_device_add(struct acpi_device *device, 1153int acpi_device_add(struct acpi_device *device,
1135 void (*release)(struct device *)) 1154 void (*release)(struct device *))
1136{ 1155{
@@ -1941,33 +1960,19 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val)
1941 mutex_unlock(&acpi_scan_lock); 1960 mutex_unlock(&acpi_scan_lock);
1942} 1961}
1943 1962
1944static void acpi_scan_init_hotplug(acpi_handle handle, int type) 1963static void acpi_scan_init_hotplug(struct acpi_device *adev)
1945{ 1964{
1946 struct acpi_device_pnp pnp = {};
1947 struct acpi_hardware_id *hwid; 1965 struct acpi_hardware_id *hwid;
1948 struct acpi_scan_handler *handler;
1949
1950 INIT_LIST_HEAD(&pnp.ids);
1951 acpi_set_pnp_ids(handle, &pnp, type);
1952 1966
1953 if (!pnp.type.hardware_id) 1967 list_for_each_entry(hwid, &adev->pnp.ids, list) {
1954 goto out; 1968 struct acpi_scan_handler *handler;
1955 1969
1956 /*
1957 * This relies on the fact that acpi_install_notify_handler() will not
1958 * install the same notify handler routine twice for the same handle.
1959 */
1960 list_for_each_entry(hwid, &pnp.ids, list) {
1961 handler = acpi_scan_match_handler(hwid->id, NULL); 1970 handler = acpi_scan_match_handler(hwid->id, NULL);
1962 if (handler) { 1971 if (handler) {
1963 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1972 adev->flags.hotplug_notify = true;
1964 acpi_hotplug_notify_cb, handler);
1965 break; 1973 break;
1966 } 1974 }
1967 } 1975 }
1968
1969out:
1970 acpi_free_pnp_ids(&pnp);
1971} 1976}
1972 1977
1973static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, 1978static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
@@ -1991,12 +1996,12 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1991 return AE_OK; 1996 return AE_OK;
1992 } 1997 }
1993 1998
1994 acpi_scan_init_hotplug(handle, type);
1995
1996 acpi_add_single_object(&device, handle, type, sta); 1999 acpi_add_single_object(&device, handle, type, sta);
1997 if (!device) 2000 if (!device)
1998 return AE_CTRL_DEPTH; 2001 return AE_CTRL_DEPTH;
1999 2002
2003 acpi_scan_init_hotplug(device);
2004
2000 out: 2005 out:
2001 if (!*return_value) 2006 if (!*return_value)
2002 *return_value = device; 2007 *return_value = device;
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index b6162be4df40..2b859249303b 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -93,7 +93,6 @@ struct acpiphp_slot {
93 struct list_head funcs; /* one slot may have different 93 struct list_head funcs; /* one slot may have different
94 objects (i.e. for each function) */ 94 objects (i.e. for each function) */
95 struct slot *slot; 95 struct slot *slot;
96 struct mutex crit_sect;
97 96
98 u8 device; /* pci device# */ 97 u8 device; /* pci device# */
99 u32 flags; /* see below */ 98 u32 flags; /* see below */
@@ -117,20 +116,30 @@ struct acpiphp_func {
117}; 116};
118 117
119struct acpiphp_context { 118struct acpiphp_context {
120 acpi_handle handle; 119 struct acpi_hotplug_context hp;
121 struct acpiphp_func func; 120 struct acpiphp_func func;
122 struct acpiphp_bridge *bridge; 121 struct acpiphp_bridge *bridge;
123 unsigned int refcount; 122 unsigned int refcount;
124}; 123};
125 124
125static inline struct acpiphp_context *to_acpiphp_context(struct acpi_hotplug_context *hp)
126{
127 return container_of(hp, struct acpiphp_context, hp);
128}
129
126static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func) 130static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
127{ 131{
128 return container_of(func, struct acpiphp_context, func); 132 return container_of(func, struct acpiphp_context, func);
129} 133}
130 134
135static inline struct acpi_device *func_to_acpi_device(struct acpiphp_func *func)
136{
137 return func_to_context(func)->hp.self;
138}
139
131static inline acpi_handle func_to_handle(struct acpiphp_func *func) 140static inline acpi_handle func_to_handle(struct acpiphp_func *func)
132{ 141{
133 return func_to_context(func)->handle; 142 return func_to_acpi_device(func)->handle;
134} 143}
135 144
136/* 145/*
@@ -158,7 +167,6 @@ struct acpiphp_attention_info
158 167
159#define FUNC_HAS_STA (0x00000001) 168#define FUNC_HAS_STA (0x00000001)
160#define FUNC_HAS_EJ0 (0x00000002) 169#define FUNC_HAS_EJ0 (0x00000002)
161#define FUNC_HAS_DCK (0x00000004)
162 170
163/* function prototypes */ 171/* function prototypes */
164 172
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 7c7a388c85ab..2d51bf7e9fe0 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -58,71 +58,57 @@
58 58
59static LIST_HEAD(bridge_list); 59static LIST_HEAD(bridge_list);
60static DEFINE_MUTEX(bridge_mutex); 60static DEFINE_MUTEX(bridge_mutex);
61static DEFINE_MUTEX(acpiphp_context_lock);
62 61
63static void handle_hotplug_event(acpi_handle handle, u32 type, void *data); 62static int acpiphp_hotplug_event(struct acpi_device *adev, u32 type);
64static void acpiphp_sanitize_bus(struct pci_bus *bus); 63static void acpiphp_sanitize_bus(struct pci_bus *bus);
65static void acpiphp_set_hpp_values(struct pci_bus *bus); 64static void acpiphp_set_hpp_values(struct pci_bus *bus);
66static void hotplug_event(acpi_handle handle, u32 type, void *data); 65static void hotplug_event(u32 type, struct acpiphp_context *context);
67static void free_bridge(struct kref *kref); 66static void free_bridge(struct kref *kref);
68 67
69static void acpiphp_context_handler(acpi_handle handle, void *context)
70{
71 /* Intentionally empty. */
72}
73
74/** 68/**
75 * acpiphp_init_context - Create hotplug context and grab a reference to it. 69 * acpiphp_init_context - Create hotplug context and grab a reference to it.
76 * @handle: ACPI object handle to create the context for. 70 * @adev: ACPI device object to create the context for.
77 * 71 *
78 * Call under acpiphp_context_lock. 72 * Call under acpi_hp_context_lock.
79 */ 73 */
80static struct acpiphp_context *acpiphp_init_context(acpi_handle handle) 74static struct acpiphp_context *acpiphp_init_context(struct acpi_device *adev)
81{ 75{
82 struct acpiphp_context *context; 76 struct acpiphp_context *context;
83 acpi_status status;
84 77
85 context = kzalloc(sizeof(*context), GFP_KERNEL); 78 context = kzalloc(sizeof(*context), GFP_KERNEL);
86 if (!context) 79 if (!context)
87 return NULL; 80 return NULL;
88 81
89 context->handle = handle;
90 context->refcount = 1; 82 context->refcount = 1;
91 status = acpi_attach_data(handle, acpiphp_context_handler, context); 83 acpi_set_hp_context(adev, &context->hp, acpiphp_hotplug_event);
92 if (ACPI_FAILURE(status)) {
93 kfree(context);
94 return NULL;
95 }
96 return context; 84 return context;
97} 85}
98 86
99/** 87/**
100 * acpiphp_get_context - Get hotplug context and grab a reference to it. 88 * acpiphp_get_context - Get hotplug context and grab a reference to it.
101 * @handle: ACPI object handle to get the context for. 89 * @adev: ACPI device object to get the context for.
102 * 90 *
103 * Call under acpiphp_context_lock. 91 * Call under acpi_hp_context_lock.
104 */ 92 */
105static struct acpiphp_context *acpiphp_get_context(acpi_handle handle) 93static struct acpiphp_context *acpiphp_get_context(struct acpi_device *adev)
106{ 94{
107 struct acpiphp_context *context = NULL; 95 struct acpiphp_context *context;
108 acpi_status status;
109 void *data;
110 96
111 status = acpi_get_data(handle, acpiphp_context_handler, &data); 97 if (!adev->hp)
112 if (ACPI_SUCCESS(status)) { 98 return NULL;
113 context = data; 99
114 context->refcount++; 100 context = to_acpiphp_context(adev->hp);
115 } 101 context->refcount++;
116 return context; 102 return context;
117} 103}
118 104
119/** 105/**
120 * acpiphp_put_context - Drop a reference to ACPI hotplug context. 106 * acpiphp_put_context - Drop a reference to ACPI hotplug context.
121 * @handle: ACPI object handle to put the context for. 107 * @context: ACPI hotplug context to drop a reference to.
122 * 108 *
123 * The context object is removed if there are no more references to it. 109 * The context object is removed if there are no more references to it.
124 * 110 *
125 * Call under acpiphp_context_lock. 111 * Call under acpi_hp_context_lock.
126 */ 112 */
127static void acpiphp_put_context(struct acpiphp_context *context) 113static void acpiphp_put_context(struct acpiphp_context *context)
128{ 114{
@@ -130,7 +116,7 @@ static void acpiphp_put_context(struct acpiphp_context *context)
130 return; 116 return;
131 117
132 WARN_ON(context->bridge); 118 WARN_ON(context->bridge);
133 acpi_detach_data(context->handle, acpiphp_context_handler); 119 context->hp.self->hp = NULL;
134 kfree(context); 120 kfree(context);
135} 121}
136 122
@@ -151,7 +137,7 @@ static void free_bridge(struct kref *kref)
151 struct acpiphp_slot *slot, *next; 137 struct acpiphp_slot *slot, *next;
152 struct acpiphp_func *func, *tmp; 138 struct acpiphp_func *func, *tmp;
153 139
154 mutex_lock(&acpiphp_context_lock); 140 acpi_lock_hp_context();
155 141
156 bridge = container_of(kref, struct acpiphp_bridge, ref); 142 bridge = container_of(kref, struct acpiphp_bridge, ref);
157 143
@@ -175,7 +161,7 @@ static void free_bridge(struct kref *kref)
175 pci_dev_put(bridge->pci_dev); 161 pci_dev_put(bridge->pci_dev);
176 kfree(bridge); 162 kfree(bridge);
177 163
178 mutex_unlock(&acpiphp_context_lock); 164 acpi_unlock_hp_context();
179} 165}
180 166
181/* 167/*
@@ -212,22 +198,13 @@ static void post_dock_fixups(acpi_handle not_used, u32 event, void *data)
212 198
213static void dock_event(acpi_handle handle, u32 type, void *data) 199static void dock_event(acpi_handle handle, u32 type, void *data)
214{ 200{
215 struct acpiphp_context *context; 201 struct acpi_device *adev;
216 202
217 mutex_lock(&acpiphp_context_lock); 203 adev = acpi_bus_get_acpi_device(handle);
218 context = acpiphp_get_context(handle); 204 if (adev) {
219 if (!context || WARN_ON(context->handle != handle) 205 acpiphp_hotplug_event(adev, type);
220 || context->func.parent->is_going_away) { 206 acpi_bus_put_acpi_device(adev);
221 mutex_unlock(&acpiphp_context_lock);
222 return;
223 } 207 }
224 get_bridge(context->func.parent);
225 acpiphp_put_context(context);
226 mutex_unlock(&acpiphp_context_lock);
227
228 hotplug_event(handle, type, data);
229
230 put_bridge(context->func.parent);
231} 208}
232 209
233static const struct acpi_dock_ops acpiphp_dock_ops = { 210static const struct acpi_dock_ops acpiphp_dock_ops = {
@@ -278,12 +255,19 @@ static void acpiphp_dock_release(void *data)
278 put_bridge(context->func.parent); 255 put_bridge(context->func.parent);
279} 256}
280 257
281/* callback routine to register each ACPI PCI slot object */ 258/**
282static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data, 259 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
283 void **rv) 260 * @handle: ACPI handle of the object to add a context to.
261 * @lvl: Not used.
262 * @data: The object's parent ACPIPHP bridge.
263 * @rv: Not used.
264 */
265static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
266 void **rv)
284{ 267{
285 struct acpiphp_bridge *bridge = data; 268 struct acpiphp_bridge *bridge = data;
286 struct acpiphp_context *context; 269 struct acpiphp_context *context;
270 struct acpi_device *adev;
287 struct acpiphp_slot *slot; 271 struct acpiphp_slot *slot;
288 struct acpiphp_func *newfunc; 272 struct acpiphp_func *newfunc;
289 acpi_status status = AE_OK; 273 acpi_status status = AE_OK;
@@ -293,9 +277,6 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
293 struct pci_dev *pdev = bridge->pci_dev; 277 struct pci_dev *pdev = bridge->pci_dev;
294 u32 val; 278 u32 val;
295 279
296 if (pdev && device_is_managed_by_native_pciehp(pdev))
297 return AE_OK;
298
299 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 280 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
300 if (ACPI_FAILURE(status)) { 281 if (ACPI_FAILURE(status)) {
301 if (status != AE_NOT_FOUND) 282 if (status != AE_NOT_FOUND)
@@ -303,21 +284,22 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
303 "can't evaluate _ADR (%#x)\n", status); 284 "can't evaluate _ADR (%#x)\n", status);
304 return AE_OK; 285 return AE_OK;
305 } 286 }
287 if (acpi_bus_get_device(handle, &adev))
288 return AE_OK;
306 289
307 device = (adr >> 16) & 0xffff; 290 device = (adr >> 16) & 0xffff;
308 function = adr & 0xffff; 291 function = adr & 0xffff;
309 292
310 mutex_lock(&acpiphp_context_lock); 293 acpi_lock_hp_context();
311 context = acpiphp_init_context(handle); 294 context = acpiphp_init_context(adev);
312 if (!context) { 295 if (!context) {
313 mutex_unlock(&acpiphp_context_lock); 296 acpi_unlock_hp_context();
314 acpi_handle_err(handle, "No hotplug context\n"); 297 acpi_handle_err(handle, "No hotplug context\n");
315 return AE_NOT_EXIST; 298 return AE_NOT_EXIST;
316 } 299 }
317 newfunc = &context->func; 300 newfunc = &context->func;
318 newfunc->function = function; 301 newfunc->function = function;
319 newfunc->parent = bridge; 302 newfunc->parent = bridge;
320 mutex_unlock(&acpiphp_context_lock);
321 303
322 if (acpi_has_method(handle, "_EJ0")) 304 if (acpi_has_method(handle, "_EJ0"))
323 newfunc->flags = FUNC_HAS_EJ0; 305 newfunc->flags = FUNC_HAS_EJ0;
@@ -325,8 +307,14 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
325 if (acpi_has_method(handle, "_STA")) 307 if (acpi_has_method(handle, "_STA"))
326 newfunc->flags |= FUNC_HAS_STA; 308 newfunc->flags |= FUNC_HAS_STA;
327 309
310 /*
311 * Dock stations' notify handler should be used for dock devices instead
312 * of the common one, so clear hp.event in their contexts.
313 */
328 if (acpi_has_method(handle, "_DCK")) 314 if (acpi_has_method(handle, "_DCK"))
329 newfunc->flags |= FUNC_HAS_DCK; 315 context->hp.event = NULL;
316
317 acpi_unlock_hp_context();
330 318
331 /* search for objects that share the same slot */ 319 /* search for objects that share the same slot */
332 list_for_each_entry(slot, &bridge->slots, node) 320 list_for_each_entry(slot, &bridge->slots, node)
@@ -335,19 +323,26 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
335 323
336 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); 324 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
337 if (!slot) { 325 if (!slot) {
338 status = AE_NO_MEMORY; 326 acpi_lock_hp_context();
339 goto err; 327 acpiphp_put_context(context);
328 acpi_unlock_hp_context();
329 return AE_NO_MEMORY;
340 } 330 }
341 331
342 slot->bus = bridge->pci_bus; 332 slot->bus = bridge->pci_bus;
343 slot->device = device; 333 slot->device = device;
344 INIT_LIST_HEAD(&slot->funcs); 334 INIT_LIST_HEAD(&slot->funcs);
345 mutex_init(&slot->crit_sect);
346 335
347 list_add_tail(&slot->node, &bridge->slots); 336 list_add_tail(&slot->node, &bridge->slots);
348 337
349 /* Register slots for ejectable functions only. */ 338 /*
350 if (acpi_pci_check_ejectable(pbus, handle) || is_dock_device(handle)) { 339 * Expose slots to user space for functions that have _EJ0 or _RMV or
340 * are located in dock stations. Do not expose them for devices handled
341 * by the native PCIe hotplug (PCIeHP), becuase that code is supposed to
342 * expose slots to user space in those cases.
343 */
344 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(handle))
345 && !(pdev && device_is_managed_by_native_pciehp(pdev))) {
351 unsigned long long sun; 346 unsigned long long sun;
352 int retval; 347 int retval;
353 348
@@ -393,32 +388,16 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
393 pr_debug("failed to register dock device\n"); 388 pr_debug("failed to register dock device\n");
394 } 389 }
395 390
396 /* install notify handler */
397 if (!(newfunc->flags & FUNC_HAS_DCK)) {
398 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
399 handle_hotplug_event,
400 context);
401 if (ACPI_FAILURE(status))
402 acpi_handle_err(handle,
403 "failed to install notify handler\n");
404 }
405
406 return AE_OK; 391 return AE_OK;
407
408 err:
409 mutex_lock(&acpiphp_context_lock);
410 acpiphp_put_context(context);
411 mutex_unlock(&acpiphp_context_lock);
412 return status;
413} 392}
414 393
415static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle) 394static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
416{ 395{
417 struct acpiphp_context *context; 396 struct acpiphp_context *context;
418 struct acpiphp_bridge *bridge = NULL; 397 struct acpiphp_bridge *bridge = NULL;
419 398
420 mutex_lock(&acpiphp_context_lock); 399 acpi_lock_hp_context();
421 context = acpiphp_get_context(handle); 400 context = acpiphp_get_context(adev);
422 if (context) { 401 if (context) {
423 bridge = context->bridge; 402 bridge = context->bridge;
424 if (bridge) 403 if (bridge)
@@ -426,7 +405,7 @@ static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
426 405
427 acpiphp_put_context(context); 406 acpiphp_put_context(context);
428 } 407 }
429 mutex_unlock(&acpiphp_context_lock); 408 acpi_unlock_hp_context();
430 return bridge; 409 return bridge;
431} 410}
432 411
@@ -434,22 +413,17 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
434{ 413{
435 struct acpiphp_slot *slot; 414 struct acpiphp_slot *slot;
436 struct acpiphp_func *func; 415 struct acpiphp_func *func;
437 acpi_status status;
438 416
439 list_for_each_entry(slot, &bridge->slots, node) { 417 list_for_each_entry(slot, &bridge->slots, node) {
440 list_for_each_entry(func, &slot->funcs, sibling) { 418 list_for_each_entry(func, &slot->funcs, sibling) {
441 acpi_handle handle = func_to_handle(func); 419 struct acpi_device *adev = func_to_acpi_device(func);
442 420
443 if (is_dock_device(handle)) 421 if (is_dock_device(adev->handle))
444 unregister_hotplug_dock_device(handle); 422 unregister_hotplug_dock_device(adev->handle);
445 423
446 if (!(func->flags & FUNC_HAS_DCK)) { 424 acpi_lock_hp_context();
447 status = acpi_remove_notify_handler(handle, 425 adev->hp->event = NULL;
448 ACPI_SYSTEM_NOTIFY, 426 acpi_unlock_hp_context();
449 handle_hotplug_event);
450 if (ACPI_FAILURE(status))
451 pr_err("failed to remove notify handler\n");
452 }
453 } 427 }
454 slot->flags |= SLOT_IS_GOING_AWAY; 428 slot->flags |= SLOT_IS_GOING_AWAY;
455 if (slot->slot) 429 if (slot->slot)
@@ -460,9 +434,9 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
460 list_del(&bridge->list); 434 list_del(&bridge->list);
461 mutex_unlock(&bridge_mutex); 435 mutex_unlock(&bridge_mutex);
462 436
463 mutex_lock(&acpiphp_context_lock); 437 acpi_lock_hp_context();
464 bridge->is_going_away = true; 438 bridge->is_going_away = true;
465 mutex_unlock(&acpiphp_context_lock); 439 acpi_unlock_hp_context();
466} 440}
467 441
468/** 442/**
@@ -492,33 +466,6 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
492 return max; 466 return max;
493} 467}
494 468
495/**
496 * acpiphp_bus_trim - Trim device objects in an ACPI namespace subtree.
497 * @handle: ACPI device object handle to start from.
498 */
499static void acpiphp_bus_trim(acpi_handle handle)
500{
501 struct acpi_device *adev = NULL;
502
503 acpi_bus_get_device(handle, &adev);
504 if (adev)
505 acpi_bus_trim(adev);
506}
507
508/**
509 * acpiphp_bus_add - Scan ACPI namespace subtree.
510 * @handle: ACPI object handle to start the scan from.
511 */
512static void acpiphp_bus_add(acpi_handle handle)
513{
514 struct acpi_device *adev = NULL;
515
516 acpi_bus_scan(handle);
517 acpi_bus_get_device(handle, &adev);
518 if (acpi_device_enumerated(adev))
519 acpi_device_set_power(adev, ACPI_STATE_D0);
520}
521
522static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 469static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
523{ 470{
524 struct acpiphp_func *func; 471 struct acpiphp_func *func;
@@ -558,9 +505,13 @@ static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
558{ 505{
559 struct acpiphp_func *func; 506 struct acpiphp_func *func;
560 507
561 list_for_each_entry(func, &slot->funcs, sibling) 508 list_for_each_entry(func, &slot->funcs, sibling) {
562 acpiphp_bus_add(func_to_handle(func)); 509 struct acpi_device *adev = func_to_acpi_device(func);
563 510
511 acpi_bus_scan(adev->handle);
512 if (acpi_device_enumerated(adev))
513 acpi_device_set_power(adev, ACPI_STATE_D0);
514 }
564 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0)); 515 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
565} 516}
566 517
@@ -625,32 +576,15 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
625 } 576 }
626} 577}
627 578
628/* return first device in slot, acquiring a reference on it */
629static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
630{
631 struct pci_bus *bus = slot->bus;
632 struct pci_dev *dev;
633 struct pci_dev *ret = NULL;
634
635 down_read(&pci_bus_sem);
636 list_for_each_entry(dev, &bus->devices, bus_list)
637 if (PCI_SLOT(dev->devfn) == slot->device) {
638 ret = pci_dev_get(dev);
639 break;
640 }
641 up_read(&pci_bus_sem);
642
643 return ret;
644}
645
646/** 579/**
647 * disable_slot - disable a slot 580 * disable_slot - disable a slot
648 * @slot: ACPI PHP slot 581 * @slot: ACPI PHP slot
649 */ 582 */
650static void disable_slot(struct acpiphp_slot *slot) 583static void disable_slot(struct acpiphp_slot *slot)
651{ 584{
585 struct pci_bus *bus = slot->bus;
586 struct pci_dev *dev, *prev;
652 struct acpiphp_func *func; 587 struct acpiphp_func *func;
653 struct pci_dev *pdev;
654 588
655 /* 589 /*
656 * enable_slot() enumerates all functions in this device via 590 * enable_slot() enumerates all functions in this device via
@@ -658,22 +592,18 @@ static void disable_slot(struct acpiphp_slot *slot)
658 * methods (_EJ0, etc.) or not. Therefore, we remove all functions 592 * methods (_EJ0, etc.) or not. Therefore, we remove all functions
659 * here. 593 * here.
660 */ 594 */
661 while ((pdev = dev_in_slot(slot))) { 595 list_for_each_entry_safe_reverse(dev, prev, &bus->devices, bus_list)
662 pci_stop_and_remove_bus_device(pdev); 596 if (PCI_SLOT(dev->devfn) == slot->device)
663 pci_dev_put(pdev); 597 pci_stop_and_remove_bus_device(dev);
664 }
665 598
666 list_for_each_entry(func, &slot->funcs, sibling) 599 list_for_each_entry(func, &slot->funcs, sibling)
667 acpiphp_bus_trim(func_to_handle(func)); 600 acpi_bus_trim(func_to_acpi_device(func));
668 601
669 slot->flags &= (~SLOT_ENABLED); 602 slot->flags &= (~SLOT_ENABLED);
670} 603}
671 604
672static bool acpiphp_no_hotplug(acpi_handle handle) 605static bool acpiphp_no_hotplug(struct acpi_device *adev)
673{ 606{
674 struct acpi_device *adev = NULL;
675
676 acpi_bus_get_device(handle, &adev);
677 return adev && adev->flags.no_hotplug; 607 return adev && adev->flags.no_hotplug;
678} 608}
679 609
@@ -682,7 +612,7 @@ static bool slot_no_hotplug(struct acpiphp_slot *slot)
682 struct acpiphp_func *func; 612 struct acpiphp_func *func;
683 613
684 list_for_each_entry(func, &slot->funcs, sibling) 614 list_for_each_entry(func, &slot->funcs, sibling)
685 if (acpiphp_no_hotplug(func_to_handle(func))) 615 if (acpiphp_no_hotplug(func_to_acpi_device(func)))
686 return true; 616 return true;
687 617
688 return false; 618 return false;
@@ -747,28 +677,25 @@ static inline bool device_status_valid(unsigned int sta)
747 */ 677 */
748static void trim_stale_devices(struct pci_dev *dev) 678static void trim_stale_devices(struct pci_dev *dev)
749{ 679{
750 acpi_handle handle = ACPI_HANDLE(&dev->dev); 680 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
751 struct pci_bus *bus = dev->subordinate; 681 struct pci_bus *bus = dev->subordinate;
752 bool alive = false; 682 bool alive = false;
753 683
754 if (handle) { 684 if (adev) {
755 acpi_status status; 685 acpi_status status;
756 unsigned long long sta; 686 unsigned long long sta;
757 687
758 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 688 status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
759 alive = (ACPI_SUCCESS(status) && device_status_valid(sta)) 689 alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
760 || acpiphp_no_hotplug(handle); 690 || acpiphp_no_hotplug(adev);
761 } 691 }
762 if (!alive) { 692 if (!alive)
763 u32 v; 693 alive = pci_device_is_present(dev);
764 694
765 /* Check if the device responds. */
766 alive = pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &v, 0);
767 }
768 if (!alive) { 695 if (!alive) {
769 pci_stop_and_remove_bus_device(dev); 696 pci_stop_and_remove_bus_device(dev);
770 if (handle) 697 if (adev)
771 acpiphp_bus_trim(handle); 698 acpi_bus_trim(adev);
772 } else if (bus) { 699 } else if (bus) {
773 struct pci_dev *child, *tmp; 700 struct pci_dev *child, *tmp;
774 701
@@ -800,7 +727,6 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
800 struct pci_bus *bus = slot->bus; 727 struct pci_bus *bus = slot->bus;
801 struct pci_dev *dev, *tmp; 728 struct pci_dev *dev, *tmp;
802 729
803 mutex_lock(&slot->crit_sect);
804 if (slot_no_hotplug(slot)) { 730 if (slot_no_hotplug(slot)) {
805 ; /* do nothing */ 731 ; /* do nothing */
806 } else if (device_status_valid(get_slot_status(slot))) { 732 } else if (device_status_valid(get_slot_status(slot))) {
@@ -815,7 +741,6 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
815 } else { 741 } else {
816 disable_slot(slot); 742 disable_slot(slot);
817 } 743 }
818 mutex_unlock(&slot->crit_sect);
819 } 744 }
820} 745}
821 746
@@ -855,11 +780,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
855 * ACPI event handlers 780 * ACPI event handlers
856 */ 781 */
857 782
858void acpiphp_check_host_bridge(acpi_handle handle) 783void acpiphp_check_host_bridge(struct acpi_device *adev)
859{ 784{
860 struct acpiphp_bridge *bridge; 785 struct acpiphp_bridge *bridge;
861 786
862 bridge = acpiphp_handle_to_bridge(handle); 787 bridge = acpiphp_dev_to_bridge(adev);
863 if (bridge) { 788 if (bridge) {
864 pci_lock_rescan_remove(); 789 pci_lock_rescan_remove();
865 790
@@ -872,73 +797,52 @@ void acpiphp_check_host_bridge(acpi_handle handle)
872 797
873static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot); 798static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
874 799
875static void hotplug_event(acpi_handle handle, u32 type, void *data) 800static void hotplug_event(u32 type, struct acpiphp_context *context)
876{ 801{
877 struct acpiphp_context *context = data; 802 acpi_handle handle = context->hp.self->handle;
878 struct acpiphp_func *func = &context->func; 803 struct acpiphp_func *func = &context->func;
804 struct acpiphp_slot *slot = func->slot;
879 struct acpiphp_bridge *bridge; 805 struct acpiphp_bridge *bridge;
880 char objname[64];
881 struct acpi_buffer buffer = { .length = sizeof(objname),
882 .pointer = objname };
883 806
884 mutex_lock(&acpiphp_context_lock); 807 acpi_lock_hp_context();
885 bridge = context->bridge; 808 bridge = context->bridge;
886 if (bridge) 809 if (bridge)
887 get_bridge(bridge); 810 get_bridge(bridge);
888 811
889 mutex_unlock(&acpiphp_context_lock); 812 acpi_unlock_hp_context();
890 813
891 pci_lock_rescan_remove(); 814 pci_lock_rescan_remove();
892 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
893 815
894 switch (type) { 816 switch (type) {
895 case ACPI_NOTIFY_BUS_CHECK: 817 case ACPI_NOTIFY_BUS_CHECK:
896 /* bus re-enumerate */ 818 /* bus re-enumerate */
897 pr_debug("%s: Bus check notify on %s\n", __func__, objname); 819 acpi_handle_debug(handle, "Bus check in %s()\n", __func__);
898 pr_debug("%s: re-enumerating slots under %s\n", 820 if (bridge)
899 __func__, objname);
900 if (bridge) {
901 acpiphp_check_bridge(bridge); 821 acpiphp_check_bridge(bridge);
902 } else { 822 else if (!(slot->flags & SLOT_IS_GOING_AWAY))
903 struct acpiphp_slot *slot = func->slot;
904
905 if (slot->flags & SLOT_IS_GOING_AWAY)
906 break;
907
908 mutex_lock(&slot->crit_sect);
909 enable_slot(slot); 823 enable_slot(slot);
910 mutex_unlock(&slot->crit_sect); 824
911 }
912 break; 825 break;
913 826
914 case ACPI_NOTIFY_DEVICE_CHECK: 827 case ACPI_NOTIFY_DEVICE_CHECK:
915 /* device check */ 828 /* device check */
916 pr_debug("%s: Device check notify on %s\n", __func__, objname); 829 acpi_handle_debug(handle, "Device check in %s()\n", __func__);
917 if (bridge) { 830 if (bridge) {
918 acpiphp_check_bridge(bridge); 831 acpiphp_check_bridge(bridge);
919 } else { 832 } else if (!(slot->flags & SLOT_IS_GOING_AWAY)) {
920 struct acpiphp_slot *slot = func->slot;
921 int ret;
922
923 if (slot->flags & SLOT_IS_GOING_AWAY)
924 break;
925
926 /* 833 /*
927 * Check if anything has changed in the slot and rescan 834 * Check if anything has changed in the slot and rescan
928 * from the parent if that's the case. 835 * from the parent if that's the case.
929 */ 836 */
930 mutex_lock(&slot->crit_sect); 837 if (acpiphp_rescan_slot(slot))
931 ret = acpiphp_rescan_slot(slot);
932 mutex_unlock(&slot->crit_sect);
933 if (ret)
934 acpiphp_check_bridge(func->parent); 838 acpiphp_check_bridge(func->parent);
935 } 839 }
936 break; 840 break;
937 841
938 case ACPI_NOTIFY_EJECT_REQUEST: 842 case ACPI_NOTIFY_EJECT_REQUEST:
939 /* request device eject */ 843 /* request device eject */
940 pr_debug("%s: Device eject notify on %s\n", __func__, objname); 844 acpi_handle_debug(handle, "Eject request in %s()\n", __func__);
941 acpiphp_disable_and_eject_slot(func->slot); 845 acpiphp_disable_and_eject_slot(slot);
942 break; 846 break;
943 } 847 }
944 848
@@ -947,106 +851,48 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
947 put_bridge(bridge); 851 put_bridge(bridge);
948} 852}
949 853
950static void hotplug_event_work(void *data, u32 type) 854static int acpiphp_hotplug_event(struct acpi_device *adev, u32 type)
951{
952 struct acpiphp_context *context = data;
953 acpi_handle handle = context->handle;
954
955 acpi_scan_lock_acquire();
956
957 hotplug_event(handle, type, context);
958
959 acpi_scan_lock_release();
960 acpi_evaluate_hotplug_ost(handle, type, ACPI_OST_SC_SUCCESS, NULL);
961 put_bridge(context->func.parent);
962}
963
964/**
965 * handle_hotplug_event - handle ACPI hotplug event
966 * @handle: Notify()'ed acpi_handle
967 * @type: Notify code
968 * @data: pointer to acpiphp_context structure
969 *
970 * Handles ACPI event notification on slots.
971 */
972static void handle_hotplug_event(acpi_handle handle, u32 type, void *data)
973{ 855{
974 struct acpiphp_context *context; 856 struct acpiphp_context *context;
975 u32 ost_code = ACPI_OST_SC_SUCCESS;
976 acpi_status status;
977
978 switch (type) {
979 case ACPI_NOTIFY_BUS_CHECK:
980 case ACPI_NOTIFY_DEVICE_CHECK:
981 break;
982 case ACPI_NOTIFY_EJECT_REQUEST:
983 ost_code = ACPI_OST_SC_EJECT_IN_PROGRESS;
984 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL);
985 break;
986 857
987 case ACPI_NOTIFY_DEVICE_WAKE: 858 acpi_lock_hp_context();
988 return; 859 context = acpiphp_get_context(adev);
989 860 if (!context || context->func.parent->is_going_away) {
990 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 861 acpi_unlock_hp_context();
991 acpi_handle_err(handle, "Device cannot be configured due " 862 return -ENODATA;
992 "to a frequency mismatch\n");
993 goto out;
994
995 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
996 acpi_handle_err(handle, "Device cannot be configured due "
997 "to a bus mode mismatch\n");
998 goto out;
999
1000 case ACPI_NOTIFY_POWER_FAULT:
1001 acpi_handle_err(handle, "Device has suffered a power fault\n");
1002 goto out;
1003
1004 default:
1005 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
1006 ost_code = ACPI_OST_SC_UNRECOGNIZED_NOTIFY;
1007 goto out;
1008 } 863 }
1009
1010 mutex_lock(&acpiphp_context_lock);
1011 context = acpiphp_get_context(handle);
1012 if (!context || WARN_ON(context->handle != handle)
1013 || context->func.parent->is_going_away)
1014 goto err_out;
1015
1016 get_bridge(context->func.parent); 864 get_bridge(context->func.parent);
1017 acpiphp_put_context(context); 865 acpiphp_put_context(context);
1018 status = acpi_hotplug_execute(hotplug_event_work, context, type); 866 acpi_unlock_hp_context();
1019 if (ACPI_SUCCESS(status)) {
1020 mutex_unlock(&acpiphp_context_lock);
1021 return;
1022 }
1023 put_bridge(context->func.parent);
1024 867
1025 err_out: 868 hotplug_event(type, context);
1026 mutex_unlock(&acpiphp_context_lock);
1027 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
1028 869
1029 out: 870 put_bridge(context->func.parent);
1030 acpi_evaluate_hotplug_ost(handle, type, ost_code, NULL); 871 return 0;
1031} 872}
1032 873
1033/* 874/**
1034 * Create hotplug slots for the PCI bus. 875 * acpiphp_enumerate_slots - Enumerate PCI slots for a given bus.
1035 * It should always return 0 to avoid skipping following notifiers. 876 * @bus: PCI bus to enumerate the slots for.
877 *
878 * A "slot" is an object associated with a PCI device number. All functions
879 * (PCI devices) with the same bus and device number belong to the same slot.
1036 */ 880 */
1037void acpiphp_enumerate_slots(struct pci_bus *bus) 881void acpiphp_enumerate_slots(struct pci_bus *bus)
1038{ 882{
1039 struct acpiphp_bridge *bridge; 883 struct acpiphp_bridge *bridge;
884 struct acpi_device *adev;
1040 acpi_handle handle; 885 acpi_handle handle;
1041 acpi_status status; 886 acpi_status status;
1042 887
1043 if (acpiphp_disabled) 888 if (acpiphp_disabled)
1044 return; 889 return;
1045 890
1046 handle = ACPI_HANDLE(bus->bridge); 891 adev = ACPI_COMPANION(bus->bridge);
1047 if (!handle) 892 if (!adev)
1048 return; 893 return;
1049 894
895 handle = adev->handle;
1050 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 896 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
1051 if (!bridge) { 897 if (!bridge) {
1052 acpi_handle_err(handle, "No memory for bridge object\n"); 898 acpi_handle_err(handle, "No memory for bridge object\n");
@@ -1074,10 +920,10 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1074 * parent is going to be handled by pciehp, in which case this 920 * parent is going to be handled by pciehp, in which case this
1075 * bridge is not interesting to us either. 921 * bridge is not interesting to us either.
1076 */ 922 */
1077 mutex_lock(&acpiphp_context_lock); 923 acpi_lock_hp_context();
1078 context = acpiphp_get_context(handle); 924 context = acpiphp_get_context(adev);
1079 if (!context) { 925 if (!context) {
1080 mutex_unlock(&acpiphp_context_lock); 926 acpi_unlock_hp_context();
1081 put_device(&bus->dev); 927 put_device(&bus->dev);
1082 pci_dev_put(bridge->pci_dev); 928 pci_dev_put(bridge->pci_dev);
1083 kfree(bridge); 929 kfree(bridge);
@@ -1087,17 +933,17 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1087 context->bridge = bridge; 933 context->bridge = bridge;
1088 /* Get a reference to the parent bridge. */ 934 /* Get a reference to the parent bridge. */
1089 get_bridge(context->func.parent); 935 get_bridge(context->func.parent);
1090 mutex_unlock(&acpiphp_context_lock); 936 acpi_unlock_hp_context();
1091 } 937 }
1092 938
1093 /* must be added to the list prior to calling register_slot */ 939 /* Must be added to the list prior to calling acpiphp_add_context(). */
1094 mutex_lock(&bridge_mutex); 940 mutex_lock(&bridge_mutex);
1095 list_add(&bridge->list, &bridge_list); 941 list_add(&bridge->list, &bridge_list);
1096 mutex_unlock(&bridge_mutex); 942 mutex_unlock(&bridge_mutex);
1097 943
1098 /* register all slot objects under this bridge */ 944 /* register all slot objects under this bridge */
1099 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, 945 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
1100 register_slot, NULL, bridge, NULL); 946 acpiphp_add_context, NULL, bridge, NULL);
1101 if (ACPI_FAILURE(status)) { 947 if (ACPI_FAILURE(status)) {
1102 acpi_handle_err(handle, "failed to register slots\n"); 948 acpi_handle_err(handle, "failed to register slots\n");
1103 cleanup_bridge(bridge); 949 cleanup_bridge(bridge);
@@ -1105,7 +951,10 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1105 } 951 }
1106} 952}
1107 953
1108/* Destroy hotplug slots associated with the PCI bus */ 954/**
955 * acpiphp_remove_slots - Remove slot objects associated with a given bus.
956 * @bus: PCI bus to remove the slot objects for.
957 */
1109void acpiphp_remove_slots(struct pci_bus *bus) 958void acpiphp_remove_slots(struct pci_bus *bus)
1110{ 959{
1111 struct acpiphp_bridge *bridge; 960 struct acpiphp_bridge *bridge;
@@ -1136,13 +985,10 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
1136 if (slot->flags & SLOT_IS_GOING_AWAY) 985 if (slot->flags & SLOT_IS_GOING_AWAY)
1137 return -ENODEV; 986 return -ENODEV;
1138 987
1139 mutex_lock(&slot->crit_sect);
1140 /* configure all functions */ 988 /* configure all functions */
1141 if (!(slot->flags & SLOT_ENABLED)) 989 if (!(slot->flags & SLOT_ENABLED))
1142 enable_slot(slot); 990 enable_slot(slot);
1143 991
1144 mutex_unlock(&slot->crit_sect);
1145
1146 pci_unlock_rescan_remove(); 992 pci_unlock_rescan_remove();
1147 return 0; 993 return 0;
1148} 994}
@@ -1158,8 +1004,6 @@ static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1158 if (slot->flags & SLOT_IS_GOING_AWAY) 1004 if (slot->flags & SLOT_IS_GOING_AWAY)
1159 return -ENODEV; 1005 return -ENODEV;
1160 1006
1161 mutex_lock(&slot->crit_sect);
1162
1163 /* unconfigure all functions */ 1007 /* unconfigure all functions */
1164 disable_slot(slot); 1008 disable_slot(slot);
1165 1009
@@ -1173,7 +1017,6 @@ static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1173 break; 1017 break;
1174 } 1018 }
1175 1019
1176 mutex_unlock(&slot->crit_sect);
1177 return 0; 1020 return 0;
1178} 1021}
1179 1022
@@ -1181,9 +1024,15 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
1181{ 1024{
1182 int ret; 1025 int ret;
1183 1026
1027 /*
1028 * Acquire acpi_scan_lock to ensure that the execution of _EJ0 in
1029 * acpiphp_disable_and_eject_slot() will be synchronized properly.
1030 */
1031 acpi_scan_lock_acquire();
1184 pci_lock_rescan_remove(); 1032 pci_lock_rescan_remove();
1185 ret = acpiphp_disable_and_eject_slot(slot); 1033 ret = acpiphp_disable_and_eject_slot(slot);
1186 pci_unlock_rescan_remove(); 1034 pci_unlock_rescan_remove();
1035 acpi_scan_lock_release();
1187 return ret; 1036 return ret;
1188} 1037}
1189 1038
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 8256eb4ad057..32f90c7bcb03 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -137,6 +137,16 @@ struct acpi_scan_handler {
137}; 137};
138 138
139/* 139/*
140 * ACPI Hotplug Context
141 * --------------------
142 */
143
144struct acpi_hotplug_context {
145 struct acpi_device *self;
146 int (*event)(struct acpi_device *, u32);
147};
148
149/*
140 * ACPI Driver 150 * ACPI Driver
141 * ----------- 151 * -----------
142 */ 152 */
@@ -190,7 +200,8 @@ struct acpi_device_flags {
190 u32 initialized:1; 200 u32 initialized:1;
191 u32 visited:1; 201 u32 visited:1;
192 u32 no_hotplug:1; 202 u32 no_hotplug:1;
193 u32 reserved:24; 203 u32 hotplug_notify:1;
204 u32 reserved:23;
194}; 205};
195 206
196/* File System */ 207/* File System */
@@ -329,6 +340,7 @@ struct acpi_device {
329 struct acpi_device_perf performance; 340 struct acpi_device_perf performance;
330 struct acpi_device_dir dir; 341 struct acpi_device_dir dir;
331 struct acpi_scan_handler *handler; 342 struct acpi_scan_handler *handler;
343 struct acpi_hotplug_context *hp;
332 struct acpi_driver *driver; 344 struct acpi_driver *driver;
333 void *driver_data; 345 void *driver_data;
334 struct device dev; 346 struct device dev;
@@ -351,6 +363,15 @@ static inline void acpi_set_device_status(struct acpi_device *adev, u32 sta)
351 *((u32 *)&adev->status) = sta; 363 *((u32 *)&adev->status) = sta;
352} 364}
353 365
366static inline void acpi_set_hp_context(struct acpi_device *adev,
367 struct acpi_hotplug_context *hp,
368 int (*event)(struct acpi_device *, u32))
369{
370 hp->self = adev;
371 hp->event = event;
372 adev->hp = hp;
373}
374
354/* acpi_device.dev.bus == &acpi_bus_type */ 375/* acpi_device.dev.bus == &acpi_bus_type */
355extern struct bus_type acpi_bus_type; 376extern struct bus_type acpi_bus_type;
356 377
@@ -381,6 +402,8 @@ extern int unregister_acpi_notifier(struct notifier_block *);
381 */ 402 */
382 403
383int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 404int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
405struct acpi_device *acpi_bus_get_acpi_device(acpi_handle handle);
406void acpi_bus_put_acpi_device(struct acpi_device *adev);
384acpi_status acpi_bus_get_status_handle(acpi_handle handle, 407acpi_status acpi_bus_get_status_handle(acpi_handle handle,
385 unsigned long long *sta); 408 unsigned long long *sta);
386int acpi_bus_get_status(struct acpi_device *device); 409int acpi_bus_get_status(struct acpi_device *device);
@@ -402,6 +425,8 @@ static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
402 425
403void acpi_scan_lock_acquire(void); 426void acpi_scan_lock_acquire(void);
404void acpi_scan_lock_release(void); 427void acpi_scan_lock_release(void);
428void acpi_lock_hp_context(void);
429void acpi_unlock_hp_context(void);
405int acpi_scan_add_handler(struct acpi_scan_handler *handler); 430int acpi_scan_add_handler(struct acpi_scan_handler *handler);
406int acpi_bus_register_driver(struct acpi_driver *driver); 431int acpi_bus_register_driver(struct acpi_driver *driver);
407void acpi_bus_unregister_driver(struct acpi_driver *driver); 432void acpi_bus_unregister_driver(struct acpi_driver *driver);
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index fea6773f87fc..34bad459c11b 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -230,6 +230,10 @@ acpi_attach_data(acpi_handle object, acpi_object_handler handler, void *data);
230acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler); 230acpi_status acpi_detach_data(acpi_handle object, acpi_object_handler handler);
231 231
232acpi_status 232acpi_status
233acpi_get_data_full(acpi_handle object, acpi_object_handler handler, void **data,
234 void (*callback)(void *));
235
236acpi_status
233acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data); 237acpi_get_data(acpi_handle object, acpi_object_handler handler, void **data);
234 238
235acpi_status 239acpi_status
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 5a462c4e5009..637a608ded0b 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -59,12 +59,12 @@ static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
59void acpiphp_init(void); 59void acpiphp_init(void);
60void acpiphp_enumerate_slots(struct pci_bus *bus); 60void acpiphp_enumerate_slots(struct pci_bus *bus);
61void acpiphp_remove_slots(struct pci_bus *bus); 61void acpiphp_remove_slots(struct pci_bus *bus);
62void acpiphp_check_host_bridge(acpi_handle handle); 62void acpiphp_check_host_bridge(struct acpi_device *adev);
63#else 63#else
64static inline void acpiphp_init(void) { } 64static inline void acpiphp_init(void) { }
65static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { } 65static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { }
66static inline void acpiphp_remove_slots(struct pci_bus *bus) { } 66static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
67static inline void acpiphp_check_host_bridge(acpi_handle handle) { } 67static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
68#endif 68#endif
69 69
70#else /* CONFIG_ACPI */ 70#else /* CONFIG_ACPI */