aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-22 15:55:20 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-11-22 15:55:20 -0500
commit3338db0057ed9f554050bd06863731c515d79672 (patch)
tree6837d33aa7deba306990e8c89413a38d44f77368 /drivers/acpi/scan.c
parentc27b2c33b6215eeb3d5c290ac889ab6d543f6207 (diff)
ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code
Rework the common ACPI device hotplug code so that it is suitable for PCI host bridge hotplug and switch the PCI host bridge scan handler to using the common hotplug code. This allows quite a few lines of code that are not necessary any more to be dropped from the PCI host bridge scan handler and removes arbitrary differences in behavior between PCI host bridge hotplug and ACPI-based hotplug of other components, like CPUs and memory. Also acpi_device_hotplug() can be static now. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index dd0ff9de9277..18865c86c463 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -283,17 +283,6 @@ static int acpi_scan_device_check(struct acpi_device *adev)
283{ 283{
284 int error; 284 int error;
285 285
286 /*
287 * This function is only called for device objects for which matching
288 * scan handlers exist. The only situation in which the scan handler is
289 * not attached to this device object yet is when the device has just
290 * appeared (either it wasn't present at all before or it was removed
291 * and then added again).
292 */
293 if (adev->handler) {
294 dev_warn(&adev->dev, "Already enumerated\n");
295 return -EBUSY;
296 }
297 error = acpi_bus_scan(adev->handle); 286 error = acpi_bus_scan(adev->handle);
298 if (error) { 287 if (error) {
299 dev_warn(&adev->dev, "Namespace scan failure\n"); 288 dev_warn(&adev->dev, "Namespace scan failure\n");
@@ -309,10 +298,11 @@ static int acpi_scan_device_check(struct acpi_device *adev)
309 return 0; 298 return 0;
310} 299}
311 300
312void acpi_device_hotplug(void *data, u32 src) 301static void acpi_device_hotplug(void *data, u32 src)
313{ 302{
314 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 303 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
315 struct acpi_device *adev = data; 304 struct acpi_device *adev = data;
305 struct acpi_scan_handler *handler;
316 int error; 306 int error;
317 307
318 lock_device_hotplug(); 308 lock_device_hotplug();
@@ -326,12 +316,32 @@ void acpi_device_hotplug(void *data, u32 src)
326 if (adev->handle == INVALID_ACPI_HANDLE) 316 if (adev->handle == INVALID_ACPI_HANDLE)
327 goto out; 317 goto out;
328 318
319 handler = adev->handler;
320
329 switch (src) { 321 switch (src) {
330 case ACPI_NOTIFY_BUS_CHECK: 322 case ACPI_NOTIFY_BUS_CHECK:
331 error = acpi_bus_scan(adev->handle); 323 if (handler) {
324 error = handler->hotplug.scan_dependent ?
325 handler->hotplug.scan_dependent(adev) :
326 acpi_bus_scan(adev->handle);
327 } else {
328 error = acpi_scan_device_check(adev);
329 }
332 break; 330 break;
333 case ACPI_NOTIFY_DEVICE_CHECK: 331 case ACPI_NOTIFY_DEVICE_CHECK:
334 error = acpi_scan_device_check(adev); 332 /*
333 * This code is only run for device objects for which matching
334 * scan handlers exist. The only situation in which the scan
335 * handler is not attached to this device object yet is when the
336 * device has just appeared (either it wasn't present at all
337 * before or it was removed and then added again).
338 */
339 if (adev->handler) {
340 dev_warn(&adev->dev, "Already enumerated\n");
341 error = -EBUSY;
342 } else {
343 error = acpi_scan_device_check(adev);
344 }
335 break; 345 break;
336 case ACPI_NOTIFY_EJECT_REQUEST: 346 case ACPI_NOTIFY_EJECT_REQUEST:
337 case ACPI_OST_EC_OSPM_EJECT: 347 case ACPI_OST_EC_OSPM_EJECT:
@@ -1805,7 +1815,7 @@ static void acpi_scan_init_hotplug(acpi_handle handle, int type)
1805 */ 1815 */
1806 list_for_each_entry(hwid, &pnp.ids, list) { 1816 list_for_each_entry(hwid, &pnp.ids, list) {
1807 handler = acpi_scan_match_handler(hwid->id, NULL); 1817 handler = acpi_scan_match_handler(hwid->id, NULL);
1808 if (handler && !handler->hotplug.ignore) { 1818 if (handler) {
1809 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 1819 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
1810 acpi_hotplug_notify_cb, handler); 1820 acpi_hotplug_notify_cb, handler);
1811 break; 1821 break;
@@ -2083,8 +2093,6 @@ int __init acpi_scan_init(void)
2083 2093
2084 acpi_update_all_gpes(); 2094 acpi_update_all_gpes();
2085 2095
2086 acpi_pci_root_hp_init();
2087
2088 out: 2096 out:
2089 mutex_unlock(&acpi_scan_lock); 2097 mutex_unlock(&acpi_scan_lock);
2090 return result; 2098 return result;