aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpi_memhotplug.c26
-rw-r--r--drivers/acpi/container.c31
-rw-r--r--drivers/acpi/device_pm.c2
-rw-r--r--drivers/acpi/dock.c23
-rw-r--r--drivers/acpi/glue.c50
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/pci_bind.c122
-rw-r--r--drivers/acpi/pci_root.c67
-rw-r--r--drivers/acpi/processor_driver.c32
-rw-r--r--drivers/acpi/scan.c340
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c50
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c10
-rw-r--r--drivers/pci/pci-acpi.c58
-rw-r--r--drivers/pci/pci.c26
-rw-r--r--drivers/pci/pci.h5
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--include/acpi/acpi_bus.h25
-rw-r--r--include/linux/acpi.h5
19 files changed, 288 insertions, 588 deletions
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 2a4502becd13..4ee2e753306a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -37,7 +37,7 @@ acpi-y += resource.o
37acpi-y += processor_core.o 37acpi-y += processor_core.o
38acpi-y += ec.o 38acpi-y += ec.o
39acpi-$(CONFIG_ACPI_DOCK) += dock.o 39acpi-$(CONFIG_ACPI_DOCK) += dock.o
40acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 40acpi-y += pci_root.o pci_link.o pci_irq.o
41acpi-y += acpi_platform.o 41acpi-y += acpi_platform.o
42acpi-y += power.o 42acpi-y += power.o
43acpi-y += event.o 43acpi-y += event.o
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index b679bf8478f7..03d18f290118 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -157,38 +157,26 @@ static int
157acpi_memory_get_device(acpi_handle handle, 157acpi_memory_get_device(acpi_handle handle,
158 struct acpi_memory_device **mem_device) 158 struct acpi_memory_device **mem_device)
159{ 159{
160 acpi_status status;
161 acpi_handle phandle;
162 struct acpi_device *device = NULL; 160 struct acpi_device *device = NULL;
163 struct acpi_device *pdevice = NULL;
164 int result; 161 int result;
165 162
166
167 if (!acpi_bus_get_device(handle, &device) && device) 163 if (!acpi_bus_get_device(handle, &device) && device)
168 goto end; 164 goto end;
169 165
170 status = acpi_get_parent(handle, &phandle);
171 if (ACPI_FAILURE(status)) {
172 ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
173 return -EINVAL;
174 }
175
176 /* Get the parent device */
177 result = acpi_bus_get_device(phandle, &pdevice);
178 if (result) {
179 acpi_handle_warn(phandle, "Cannot get acpi bus device\n");
180 return -EINVAL;
181 }
182
183 /* 166 /*
184 * Now add the notified device. This creates the acpi_device 167 * Now add the notified device. This creates the acpi_device
185 * and invokes .add function 168 * and invokes .add function
186 */ 169 */
187 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 170 result = acpi_bus_scan(handle);
188 if (result) { 171 if (result) {
189 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 172 acpi_handle_warn(handle, "Cannot add acpi bus\n");
190 return -EINVAL; 173 return -EINVAL;
191 } 174 }
175 result = acpi_bus_get_device(handle, &device);
176 if (result) {
177 acpi_handle_warn(handle, "Missing device object\n");
178 return -EINVAL;
179 }
192 180
193 end: 181 end:
194 *mem_device = acpi_driver_data(device); 182 *mem_device = acpi_driver_data(device);
@@ -355,7 +343,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
355 break; 343 break;
356 } 344 }
357 345
358 ej_event->handle = handle; 346 ej_event->device = device;
359 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 347 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
360 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 348 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
361 (void *)ej_event); 349 (void *)ej_event);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 811910b50b75..cc79d3e53a39 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -135,30 +135,6 @@ static int acpi_container_remove(struct acpi_device *device, int type)
135 return status; 135 return status;
136} 136}
137 137
138static int container_device_add(struct acpi_device **device, acpi_handle handle)
139{
140 acpi_handle phandle;
141 struct acpi_device *pdev;
142 int result;
143
144
145 if (acpi_get_parent(handle, &phandle)) {
146 return -ENODEV;
147 }
148
149 if (acpi_bus_get_device(phandle, &pdev)) {
150 return -ENODEV;
151 }
152
153 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
154 return -ENODEV;
155 }
156
157 result = acpi_bus_start(*device);
158
159 return result;
160}
161
162static void container_notify_cb(acpi_handle handle, u32 type, void *context) 138static void container_notify_cb(acpi_handle handle, u32 type, void *context)
163{ 139{
164 struct acpi_device *device = NULL; 140 struct acpi_device *device = NULL;
@@ -190,11 +166,16 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
190 if (!ACPI_FAILURE(status) || device) 166 if (!ACPI_FAILURE(status) || device)
191 break; 167 break;
192 168
193 result = container_device_add(&device, handle); 169 result = acpi_bus_scan(handle);
194 if (result) { 170 if (result) {
195 acpi_handle_warn(handle, "Failed to add container\n"); 171 acpi_handle_warn(handle, "Failed to add container\n");
196 break; 172 break;
197 } 173 }
174 result = acpi_bus_get_device(handle, &device);
175 if (result) {
176 acpi_handle_warn(handle, "Missing device object\n");
177 break;
178 }
198 179
199 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); 180 kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
200 ost_code = ACPI_OST_SC_SUCCESS; 181 ost_code = ACPI_OST_SC_SUCCESS;
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index c6ff606c6d5b..995019063f64 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -353,7 +353,7 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
353 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. 353 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device.
354 * @dev: Device to get the ACPI node for. 354 * @dev: Device to get the ACPI node for.
355 */ 355 */
356static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 356struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
357{ 357{
358 acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 358 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
359 struct acpi_device *adev; 359 struct acpi_device *adev;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index f32bd47b35e0..78648f811049 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -310,8 +310,6 @@ static int dock_present(struct dock_station *ds)
310static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 310static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
311{ 311{
312 struct acpi_device *device; 312 struct acpi_device *device;
313 struct acpi_device *parent_device;
314 acpi_handle parent;
315 int ret; 313 int ret;
316 314
317 if (acpi_bus_get_device(handle, &device)) { 315 if (acpi_bus_get_device(handle, &device)) {
@@ -319,16 +317,11 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
319 * no device created for this object, 317 * no device created for this object,
320 * so we should create one. 318 * so we should create one.
321 */ 319 */
322 acpi_get_parent(handle, &parent); 320 ret = acpi_bus_scan(handle);
323 if (acpi_bus_get_device(parent, &parent_device)) 321 if (ret)
324 parent_device = NULL;
325
326 ret = acpi_bus_add(&device, parent_device, handle,
327 ACPI_BUS_TYPE_DEVICE);
328 if (ret) {
329 pr_debug("error adding bus, %x\n", -ret); 322 pr_debug("error adding bus, %x\n", -ret);
330 return NULL; 323
331 } 324 acpi_bus_get_device(handle, &device);
332 } 325 }
333 return device; 326 return device;
334} 327}
@@ -343,13 +336,9 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
343static void dock_remove_acpi_device(acpi_handle handle) 336static void dock_remove_acpi_device(acpi_handle handle)
344{ 337{
345 struct acpi_device *device; 338 struct acpi_device *device;
346 int ret;
347 339
348 if (!acpi_bus_get_device(handle, &device)) { 340 if (!acpi_bus_get_device(handle, &device))
349 ret = acpi_bus_trim(device, 1); 341 acpi_bus_trim(device);
350 if (ret)
351 pr_debug("error removing bus, %x\n", -ret);
352 }
353} 342}
354 343
355/** 344/**
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 35da18113216..9aee4fc2b218 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -68,6 +68,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
68{ 68{
69 struct acpi_bus_type *tmp, *ret = NULL; 69 struct acpi_bus_type *tmp, *ret = NULL;
70 70
71 if (!type)
72 return NULL;
73
71 down_read(&bus_type_sem); 74 down_read(&bus_type_sem);
72 list_for_each_entry(tmp, &bus_type_list, list) { 75 list_for_each_entry(tmp, &bus_type_list, list) {
73 if (tmp->bus == type) { 76 if (tmp->bus == type) {
@@ -269,28 +272,39 @@ static int acpi_platform_notify(struct device *dev)
269{ 272{
270 struct acpi_bus_type *type; 273 struct acpi_bus_type *type;
271 acpi_handle handle; 274 acpi_handle handle;
272 int ret = -EINVAL; 275 int ret;
273 276
274 ret = acpi_bind_one(dev, NULL); 277 ret = acpi_bind_one(dev, NULL);
275 if (!ret) 278 if (ret && (!dev->bus || !dev->parent)) {
276 goto out;
277
278 if (!dev->bus || !dev->parent) {
279 /* bridge devices genernally haven't bus or parent */ 279 /* bridge devices genernally haven't bus or parent */
280 ret = acpi_find_bridge_device(dev, &handle); 280 ret = acpi_find_bridge_device(dev, &handle);
281 goto end; 281 if (!ret) {
282 ret = acpi_bind_one(dev, handle);
283 if (ret)
284 goto out;
285 }
282 } 286 }
287
283 type = acpi_get_bus_type(dev->bus); 288 type = acpi_get_bus_type(dev->bus);
284 if (!type) { 289 if (ret) {
285 DBG("No ACPI bus support for %s\n", dev_name(dev)); 290 if (!type || !type->find_device) {
286 ret = -EINVAL; 291 DBG("No ACPI bus support for %s\n", dev_name(dev));
287 goto end; 292 ret = -EINVAL;
293 goto out;
294 }
295
296 ret = type->find_device(dev, &handle);
297 if (ret) {
298 DBG("Unable to get handle for %s\n", dev_name(dev));
299 goto out;
300 }
301 ret = acpi_bind_one(dev, handle);
302 if (ret)
303 goto out;
288 } 304 }
289 if ((ret = type->find_device(dev, &handle)) != 0) 305
290 DBG("Can't get handler for %s\n", dev_name(dev)); 306 if (type && type->setup)
291 end: 307 type->setup(dev);
292 if (!ret)
293 acpi_bind_one(dev, handle);
294 308
295 out: 309 out:
296#if ACPI_GLUE_DEBUG 310#if ACPI_GLUE_DEBUG
@@ -309,6 +323,12 @@ static int acpi_platform_notify(struct device *dev)
309 323
310static int acpi_platform_notify_remove(struct device *dev) 324static int acpi_platform_notify_remove(struct device *dev)
311{ 325{
326 struct acpi_bus_type *type;
327
328 type = acpi_get_bus_type(dev->bus);
329 if (type && type->cleanup)
330 type->cleanup(dev);
331
312 acpi_unbind_one(dev); 332 acpi_unbind_one(dev);
313 return 0; 333 return 0;
314} 334}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3c407cdc1ec1..e050254ae143 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -67,6 +67,7 @@ struct acpi_ec {
67 67
68extern struct acpi_ec *first_ec; 68extern struct acpi_ec *first_ec;
69 69
70int acpi_pci_root_init(void);
70int acpi_ec_init(void); 71int acpi_ec_init(void);
71int acpi_ec_ecdt_probe(void); 72int acpi_ec_ecdt_probe(void);
72int acpi_boot_ec_enable(void); 73int acpi_boot_ec_enable(void);
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
deleted file mode 100644
index a1dee29beed3..000000000000
--- a/drivers/acpi/pci_bind.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/kernel.h>
27#include <linux/types.h>
28#include <linux/pci.h>
29#include <linux/pci-acpi.h>
30#include <linux/acpi.h>
31#include <linux/pm_runtime.h>
32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h>
34
35#define _COMPONENT ACPI_PCI_COMPONENT
36ACPI_MODULE_NAME("pci_bind");
37
38static int acpi_pci_unbind(struct acpi_device *device)
39{
40 struct pci_dev *dev;
41
42 dev = acpi_get_pci_dev(device->handle);
43 if (!dev)
44 goto out;
45
46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device);
48 acpi_power_resource_unregister_device(&dev->dev, device->handle);
49
50 if (!dev->subordinate)
51 goto out;
52
53 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
54
55 device->ops.bind = NULL;
56 device->ops.unbind = NULL;
57
58out:
59 pci_dev_put(dev);
60 return 0;
61}
62
63static int acpi_pci_bind(struct acpi_device *device)
64{
65 acpi_status status;
66 acpi_handle handle;
67 unsigned char bus;
68 struct pci_dev *dev;
69
70 dev = acpi_get_pci_dev(device->handle);
71 if (!dev)
72 return 0;
73
74 pci_acpi_add_pm_notifier(device, dev);
75 acpi_power_resource_register_device(&dev->dev, device->handle);
76 if (device->wakeup.flags.run_wake)
77 device_set_run_wake(&dev->dev, true);
78
79 /*
80 * Install the 'bind' function to facilitate callbacks for
81 * children of the P2P bridge.
82 */
83 if (dev->subordinate) {
84 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
85 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
86 pci_domain_nr(dev->bus), dev->bus->number,
87 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));
88 device->ops.bind = acpi_pci_bind;
89 device->ops.unbind = acpi_pci_unbind;
90 }
91
92 /*
93 * Evaluate and parse _PRT, if exists. This code allows parsing of
94 * _PRT objects within the scope of non-bridge devices. Note that
95 * _PRTs within the scope of a PCI bridge assume the bridge's
96 * subordinate bus number.
97 *
98 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
99 */
100 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
101 if (ACPI_FAILURE(status))
102 goto out;
103
104 if (dev->subordinate)
105 bus = dev->subordinate->number;
106 else
107 bus = dev->bus->number;
108
109 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
110
111out:
112 pci_dev_put(dev);
113 return 0;
114}
115
116int acpi_pci_bind_root(struct acpi_device *device)
117{
118 device->ops.bind = acpi_pci_bind;
119 device->ops.unbind = acpi_pci_unbind;
120
121 return 0;
122}
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7928d4dc7056..22a8458b4ec9 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -47,7 +47,6 @@ ACPI_MODULE_NAME("pci_root");
47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
48static int acpi_pci_root_add(struct acpi_device *device); 48static int acpi_pci_root_add(struct acpi_device *device);
49static int acpi_pci_root_remove(struct acpi_device *device, int type); 49static int acpi_pci_root_remove(struct acpi_device *device, int type);
50static int acpi_pci_root_start(struct acpi_device *device);
51 50
52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 51#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \
53 | OSC_ACTIVE_STATE_PWR_SUPPORT \ 52 | OSC_ACTIVE_STATE_PWR_SUPPORT \
@@ -67,7 +66,6 @@ static struct acpi_driver acpi_pci_root_driver = {
67 .ops = { 66 .ops = {
68 .add = acpi_pci_root_add, 67 .add = acpi_pci_root_add,
69 .remove = acpi_pci_root_remove, 68 .remove = acpi_pci_root_remove,
70 .start = acpi_pci_root_start,
71 }, 69 },
72}; 70};
73 71
@@ -188,21 +186,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
188 return AE_OK; 186 return AE_OK;
189} 187}
190 188
191static void acpi_pci_bridge_scan(struct acpi_device *device)
192{
193 int status;
194 struct acpi_device *child = NULL;
195
196 if (device->flags.bus_address)
197 if (device->parent && device->parent->ops.bind) {
198 status = device->parent->ops.bind(device);
199 if (!status) {
200 list_for_each_entry(child, &device->children, node)
201 acpi_pci_bridge_scan(child);
202 }
203 }
204}
205
206static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; 189static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
207 190
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 191static acpi_status acpi_pci_run_osc(acpi_handle handle,
@@ -452,7 +435,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
452 int result; 435 int result;
453 struct acpi_pci_root *root; 436 struct acpi_pci_root *root;
454 acpi_handle handle; 437 acpi_handle handle;
455 struct acpi_device *child; 438 struct acpi_pci_driver *driver;
456 u32 flags, base_flags; 439 u32 flags, base_flags;
457 bool is_osc_granted = false; 440 bool is_osc_granted = false;
458 441
@@ -603,21 +586,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
603 goto out_del_root; 586 goto out_del_root;
604 } 587 }
605 588
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */ 589 /* ASPM setting */
622 if (is_osc_granted) { 590 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) 591 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
@@ -632,24 +600,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
632 if (device->wakeup.flags.run_wake) 600 if (device->wakeup.flags.run_wake)
633 device_set_run_wake(root->bus->bridge, true); 601 device_set_run_wake(root->bus->bridge, true);
634 602
635 return 0;
636
637out_del_root:
638 mutex_lock(&acpi_pci_root_lock);
639 list_del(&root->node);
640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
643end:
644 kfree(root);
645 return result;
646}
647
648static int acpi_pci_root_start(struct acpi_device *device)
649{
650 struct acpi_pci_root *root = acpi_driver_data(device);
651 struct acpi_pci_driver *driver;
652
653 if (system_state != SYSTEM_BOOTING) 603 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus); 604 pci_assign_unassigned_bus_resources(root->bus);
655 605
@@ -664,8 +614,17 @@ static int acpi_pci_root_start(struct acpi_device *device)
664 pci_enable_bridges(root->bus); 614 pci_enable_bridges(root->bus);
665 615
666 pci_bus_add_devices(root->bus); 616 pci_bus_add_devices(root->bus);
667
668 return 0; 617 return 0;
618
619out_del_root:
620 mutex_lock(&acpi_pci_root_lock);
621 list_del(&root->node);
622 mutex_unlock(&acpi_pci_root_lock);
623
624 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
625end:
626 kfree(root);
627 return result;
669} 628}
670 629
671static int acpi_pci_root_remove(struct acpi_device *device, int type) 630static int acpi_pci_root_remove(struct acpi_device *device, int type)
@@ -699,7 +658,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
699 return 0; 658 return 0;
700} 659}
701 660
702static int __init acpi_pci_root_init(void) 661int __init acpi_pci_root_init(void)
703{ 662{
704 acpi_hest_init(); 663 acpi_hest_init();
705 664
@@ -712,5 +671,3 @@ static int __init acpi_pci_root_init(void)
712 671
713 return 0; 672 return 0;
714} 673}
715
716subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1ebd..9c5929a17d3a 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -677,28 +677,6 @@ static int is_processor_present(acpi_handle handle)
677 return 0; 677 return 0;
678} 678}
679 679
680static
681int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
682{
683 acpi_handle phandle;
684 struct acpi_device *pdev;
685
686
687 if (acpi_get_parent(handle, &phandle)) {
688 return -ENODEV;
689 }
690
691 if (acpi_bus_get_device(phandle, &pdev)) {
692 return -ENODEV;
693 }
694
695 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
696 return -ENODEV;
697 }
698
699 return 0;
700}
701
702static void acpi_processor_hotplug_notify(acpi_handle handle, 680static void acpi_processor_hotplug_notify(acpi_handle handle,
703 u32 event, void *data) 681 u32 event, void *data)
704{ 682{
@@ -721,12 +699,16 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
721 if (!acpi_bus_get_device(handle, &device)) 699 if (!acpi_bus_get_device(handle, &device))
722 break; 700 break;
723 701
724 result = acpi_processor_device_add(handle, &device); 702 result = acpi_bus_scan(handle);
725 if (result) { 703 if (result) {
726 acpi_handle_err(handle, "Unable to add the device\n"); 704 acpi_handle_err(handle, "Unable to add the device\n");
727 break; 705 break;
728 } 706 }
729 707 result = acpi_bus_get_device(handle, &device);
708 if (result) {
709 acpi_handle_err(handle, "Missing device object\n");
710 break;
711 }
730 ost_code = ACPI_OST_SC_SUCCESS; 712 ost_code = ACPI_OST_SC_SUCCESS;
731 break; 713 break;
732 714
@@ -751,7 +733,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
751 break; 733 break;
752 } 734 }
753 735
754 ej_event->handle = handle; 736 ej_event->device = device;
755 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 737 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
756 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 738 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
757 (void *)ej_event); 739 (void *)ej_event);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c88be6c37c30..83fe3bf4cdc8 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -52,6 +52,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
52 52
53static LIST_HEAD(acpi_device_list); 53static LIST_HEAD(acpi_device_list);
54static LIST_HEAD(acpi_bus_id_list); 54static LIST_HEAD(acpi_bus_id_list);
55static DEFINE_MUTEX(acpi_scan_lock);
55DEFINE_MUTEX(acpi_device_lock); 56DEFINE_MUTEX(acpi_device_lock);
56LIST_HEAD(acpi_wakeup_device_list); 57LIST_HEAD(acpi_wakeup_device_list);
57 58
@@ -116,30 +117,19 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
116void acpi_bus_hot_remove_device(void *context) 117void acpi_bus_hot_remove_device(void *context)
117{ 118{
118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; 119 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
119 struct acpi_device *device; 120 struct acpi_device *device = ej_event->device;
120 acpi_handle handle = ej_event->handle; 121 acpi_handle handle = device->handle;
121 acpi_handle temp; 122 acpi_handle temp;
122 struct acpi_object_list arg_list; 123 struct acpi_object_list arg_list;
123 union acpi_object arg; 124 union acpi_object arg;
124 acpi_status status = AE_OK; 125 acpi_status status = AE_OK;
125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 126 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
126 127
127 if (acpi_bus_get_device(handle, &device))
128 goto err_out;
129
130 if (!device)
131 goto err_out;
132
133 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 128 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
134 "Hot-removing device %s...\n", dev_name(&device->dev))); 129 "Hot-removing device %s...\n", dev_name(&device->dev)));
135 130
136 if (acpi_bus_trim(device, 1)) { 131 acpi_bus_trim(device);
137 printk(KERN_ERR PREFIX 132 /* Device node has been released. */
138 "Removing device failed\n");
139 goto err_out;
140 }
141
142 /* device has been freed */
143 device = NULL; 133 device = NULL;
144 134
145 /* power off device */ 135 /* power off device */
@@ -215,7 +205,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
215 goto err; 205 goto err;
216 } 206 }
217 207
218 ej_event->handle = acpi_device->handle; 208 ej_event->device = acpi_device;
219 if (acpi_device->flags.eject_pending) { 209 if (acpi_device->flags.eject_pending) {
220 /* event originated from ACPI eject notification */ 210 /* event originated from ACPI eject notification */
221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 211 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
@@ -223,7 +213,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
223 } else { 213 } else {
224 /* event originated from user */ 214 /* event originated from user */
225 ej_event->event = ACPI_OST_EC_OSPM_EJECT; 215 ej_event->event = ACPI_OST_EC_OSPM_EJECT;
226 (void) acpi_evaluate_hotplug_ost(ej_event->handle, 216 (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 217 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
228 } 218 }
229 219
@@ -454,9 +444,9 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
454 const struct device *dev) 444 const struct device *dev)
455{ 445{
456 struct acpi_device *adev; 446 struct acpi_device *adev;
447 acpi_handle handle = ACPI_HANDLE(dev);
457 448
458 if (!ids || !ACPI_HANDLE(dev) 449 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
459 || ACPI_FAILURE(acpi_bus_get_device(ACPI_HANDLE(dev), &adev)))
460 return NULL; 450 return NULL;
461 451
462 return __acpi_match_device(adev, ids); 452 return __acpi_match_device(adev, ids);
@@ -494,7 +484,8 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
494 struct acpi_device *acpi_dev = to_acpi_device(dev); 484 struct acpi_device *acpi_dev = to_acpi_device(dev);
495 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 485 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
496 486
497 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); 487 return acpi_dev->flags.match_driver
488 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
498} 489}
499 490
500static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 491static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
@@ -570,7 +561,6 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
570} 561}
571 562
572static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 563static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *);
573static int acpi_start_single_object(struct acpi_device *);
574static int acpi_device_probe(struct device * dev) 564static int acpi_device_probe(struct device * dev)
575{ 565{
576 struct acpi_device *acpi_dev = to_acpi_device(dev); 566 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -579,9 +569,6 @@ static int acpi_device_probe(struct device * dev)
579 569
580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 570 ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
581 if (!ret) { 571 if (!ret) {
582 if (acpi_dev->bus_ops.acpi_op_start)
583 acpi_start_single_object(acpi_dev);
584
585 if (acpi_drv->ops.notify) { 572 if (acpi_drv->ops.notify) {
586 ret = acpi_device_install_notify_handler(acpi_dev); 573 ret = acpi_device_install_notify_handler(acpi_dev);
587 if (ret) { 574 if (ret) {
@@ -704,7 +691,7 @@ end:
704 return result; 691 return result;
705} 692}
706 693
707static void acpi_device_unregister(struct acpi_device *device, int type) 694static void acpi_device_unregister(struct acpi_device *device)
708{ 695{
709 mutex_lock(&acpi_device_lock); 696 mutex_lock(&acpi_device_lock);
710 if (device->parent) 697 if (device->parent)
@@ -760,24 +747,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
760 return 0; 747 return 0;
761} 748}
762 749
763static int acpi_start_single_object(struct acpi_device *device)
764{
765 int result = 0;
766 struct acpi_driver *driver;
767
768
769 if (!(driver = device->driver))
770 return 0;
771
772 if (driver->ops.start) {
773 result = driver->ops.start(device);
774 if (result && driver->ops.remove)
775 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
776 }
777
778 return result;
779}
780
781/** 750/**
782 * acpi_bus_register_driver - register a driver with the ACPI bus 751 * acpi_bus_register_driver - register a driver with the ACPI bus
783 * @driver: driver being registered 752 * @driver: driver being registered
@@ -1395,33 +1364,9 @@ static int acpi_device_set_context(struct acpi_device *device)
1395 return -ENODEV; 1364 return -ENODEV;
1396} 1365}
1397 1366
1398static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1399{
1400 if (!dev)
1401 return -EINVAL;
1402
1403 dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
1404 device_release_driver(&dev->dev);
1405
1406 if (!rmdevice)
1407 return 0;
1408
1409 /*
1410 * unbind _ADR-Based Devices when hot removal
1411 */
1412 if (dev->flags.bus_address) {
1413 if ((dev->parent) && (dev->parent->ops.unbind))
1414 dev->parent->ops.unbind(dev);
1415 }
1416 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
1417
1418 return 0;
1419}
1420
1421static int acpi_add_single_object(struct acpi_device **child, 1367static int acpi_add_single_object(struct acpi_device **child,
1422 acpi_handle handle, int type, 1368 acpi_handle handle, int type,
1423 unsigned long long sta, 1369 unsigned long long sta, bool match_driver)
1424 struct acpi_bus_ops *ops)
1425{ 1370{
1426 int result; 1371 int result;
1427 struct acpi_device *device; 1372 struct acpi_device *device;
@@ -1437,7 +1382,6 @@ static int acpi_add_single_object(struct acpi_device **child,
1437 device->device_type = type; 1382 device->device_type = type;
1438 device->handle = handle; 1383 device->handle = handle;
1439 device->parent = acpi_bus_get_parent(handle); 1384 device->parent = acpi_bus_get_parent(handle);
1440 device->bus_ops = *ops; /* workround for not call .start */
1441 STRUCT_TO_INT(device->status) = sta; 1385 STRUCT_TO_INT(device->status) = sta;
1442 1386
1443 acpi_device_get_busid(device); 1387 acpi_device_get_busid(device);
@@ -1488,16 +1432,9 @@ static int acpi_add_single_object(struct acpi_device **child,
1488 if ((result = acpi_device_set_context(device))) 1432 if ((result = acpi_device_set_context(device)))
1489 goto end; 1433 goto end;
1490 1434
1435 device->flags.match_driver = match_driver;
1491 result = acpi_device_register(device); 1436 result = acpi_device_register(device);
1492 1437
1493 /*
1494 * Bind _ADR-Based Devices when hot add
1495 */
1496 if (device->flags.bus_address) {
1497 if (device->parent && device->parent->ops.bind)
1498 device->parent->ops.bind(device);
1499 }
1500
1501end: 1438end:
1502 if (!result) { 1439 if (!result) {
1503 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 1440 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
@@ -1519,16 +1456,12 @@ end:
1519 1456
1520static void acpi_bus_add_power_resource(acpi_handle handle) 1457static void acpi_bus_add_power_resource(acpi_handle handle)
1521{ 1458{
1522 struct acpi_bus_ops ops = {
1523 .acpi_op_add = 1,
1524 .acpi_op_start = 1,
1525 };
1526 struct acpi_device *device = NULL; 1459 struct acpi_device *device = NULL;
1527 1460
1528 acpi_bus_get_device(handle, &device); 1461 acpi_bus_get_device(handle, &device);
1529 if (!device) 1462 if (!device)
1530 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, 1463 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER,
1531 ACPI_STA_DEFAULT, &ops); 1464 ACPI_STA_DEFAULT, true);
1532} 1465}
1533 1466
1534static int acpi_bus_type_and_status(acpi_handle handle, int *type, 1467static int acpi_bus_type_and_status(acpi_handle handle, int *type,
@@ -1570,16 +1503,19 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1570 return 0; 1503 return 0;
1571} 1504}
1572 1505
1573static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1506static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1574 void *context, void **return_value) 1507 void *not_used, void **return_value)
1575{ 1508{
1576 struct acpi_bus_ops *ops = context; 1509 struct acpi_device *device = NULL;
1577 int type; 1510 int type;
1578 unsigned long long sta; 1511 unsigned long long sta;
1579 struct acpi_device *device;
1580 acpi_status status; 1512 acpi_status status;
1581 int result; 1513 int result;
1582 1514
1515 acpi_bus_get_device(handle, &device);
1516 if (device)
1517 goto out;
1518
1583 result = acpi_bus_type_and_status(handle, &type, &sta); 1519 result = acpi_bus_type_and_status(handle, &type, &sta);
1584 if (result) 1520 if (result)
1585 return AE_OK; 1521 return AE_OK;
@@ -1596,150 +1532,124 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1596 return AE_CTRL_DEPTH; 1532 return AE_CTRL_DEPTH;
1597 } 1533 }
1598 1534
1599 /* 1535 acpi_add_single_object(&device, handle, type, sta,
1600 * We may already have an acpi_device from a previous enumeration. If 1536 type == ACPI_BUS_TYPE_POWER);
1601 * so, we needn't add it again, but we may still have to start it.
1602 */
1603 device = NULL;
1604 acpi_bus_get_device(handle, &device);
1605 if (ops->acpi_op_add && !device) {
1606 acpi_add_single_object(&device, handle, type, sta, ops);
1607 /* Is the device a known good platform device? */
1608 if (device
1609 && !acpi_match_device_ids(device, acpi_platform_device_ids))
1610 acpi_create_platform_device(device);
1611 }
1612
1613 if (!device) 1537 if (!device)
1614 return AE_CTRL_DEPTH; 1538 return AE_CTRL_DEPTH;
1615 1539
1616 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1540 device->flags.match_driver = true;
1617 status = acpi_start_single_object(device);
1618 if (ACPI_FAILURE(status))
1619 return AE_CTRL_DEPTH;
1620 }
1621 1541
1542 out:
1622 if (!*return_value) 1543 if (!*return_value)
1623 *return_value = device; 1544 *return_value = device;
1545
1624 return AE_OK; 1546 return AE_OK;
1625} 1547}
1626 1548
1627static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1549static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1628 struct acpi_device **child) 1550 void *not_used, void **ret_not_used)
1629{ 1551{
1630 acpi_status status; 1552 acpi_status status = AE_OK;
1631 void *device = NULL; 1553 struct acpi_device *device;
1554 unsigned long long sta_not_used;
1555 int type_not_used;
1632 1556
1633 status = acpi_bus_check_add(handle, 0, ops, &device); 1557 /*
1634 if (ACPI_SUCCESS(status)) 1558 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
1635 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1559 * namespace walks prematurely.
1636 acpi_bus_check_add, NULL, ops, &device); 1560 */
1561 if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used))
1562 return AE_OK;
1637 1563
1638 if (child) 1564 if (acpi_bus_get_device(handle, &device))
1639 *child = device; 1565 return AE_CTRL_DEPTH;
1640 1566
1641 if (device) 1567 if (!acpi_match_device_ids(device, acpi_platform_device_ids)) {
1642 return 0; 1568 /* This is a known good platform device. */
1643 else 1569 acpi_create_platform_device(device);
1644 return -ENODEV; 1570 } else if (device_attach(&device->dev) < 0) {
1571 status = AE_CTRL_DEPTH;
1572 }
1573 return status;
1645} 1574}
1646 1575
1647/* 1576/**
1648 * acpi_bus_add and acpi_bus_start 1577 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
1578 * @handle: Root of the namespace scope to scan.
1649 * 1579 *
1650 * scan a given ACPI tree and (probably recently hot-plugged) 1580 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1651 * create and add or starts found devices. 1581 * found devices.
1652 * 1582 *
1653 * If no devices were found -ENODEV is returned which does not 1583 * If no devices were found, -ENODEV is returned, but it does not mean that
1654 * mean that this is a real error, there just have been no suitable 1584 * there has been a real error. There just have been no suitable ACPI objects
1655 * ACPI objects in the table trunk from which the kernel could create 1585 * in the table trunk from which the kernel could create a device and add an
1656 * a device and add/start an appropriate driver. 1586 * appropriate driver.
1657 */ 1587 */
1658 1588int acpi_bus_scan(acpi_handle handle)
1659int
1660acpi_bus_add(struct acpi_device **child,
1661 struct acpi_device *parent, acpi_handle handle, int type)
1662{ 1589{
1663 struct acpi_bus_ops ops; 1590 void *device = NULL;
1664 1591 int error = 0;
1665 memset(&ops, 0, sizeof(ops));
1666 ops.acpi_op_add = 1;
1667 1592
1668 return acpi_bus_scan(handle, &ops, child); 1593 mutex_lock(&acpi_scan_lock);
1669}
1670EXPORT_SYMBOL(acpi_bus_add);
1671 1594
1672int acpi_bus_start(struct acpi_device *device) 1595 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1673{ 1596 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1674 struct acpi_bus_ops ops; 1597 acpi_bus_check_add, NULL, NULL, &device);
1675 int result;
1676 1598
1677 if (!device) 1599 if (!device)
1678 return -EINVAL; 1600 error = -ENODEV;
1679 1601 else if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1680 memset(&ops, 0, sizeof(ops)); 1602 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1681 ops.acpi_op_start = 1; 1603 acpi_bus_device_attach, NULL, NULL, NULL);
1682 1604
1683 result = acpi_bus_scan(device->handle, &ops, NULL); 1605 mutex_unlock(&acpi_scan_lock);
1606 return error;
1607}
1608EXPORT_SYMBOL(acpi_bus_scan);
1684 1609
1685 acpi_update_all_gpes(); 1610static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1611 void *not_used, void **ret_not_used)
1612{
1613 struct acpi_device *device = NULL;
1686 1614
1687 return result; 1615 if (!acpi_bus_get_device(handle, &device)) {
1616 device->removal_type = ACPI_BUS_REMOVAL_EJECT;
1617 device_release_driver(&device->dev);
1618 }
1619 return AE_OK;
1688} 1620}
1689EXPORT_SYMBOL(acpi_bus_start);
1690 1621
1691int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1622static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
1623 void *not_used, void **ret_not_used)
1692{ 1624{
1693 acpi_status status; 1625 struct acpi_device *device = NULL;
1694 struct acpi_device *parent, *child;
1695 acpi_handle phandle, chandle;
1696 acpi_object_type type;
1697 u32 level = 1;
1698 int err = 0;
1699 1626
1700 parent = start; 1627 if (!acpi_bus_get_device(handle, &device))
1701 phandle = start->handle; 1628 acpi_device_unregister(device);
1702 child = chandle = NULL;
1703 1629
1704 while ((level > 0) && parent && (!err)) { 1630 return AE_OK;
1705 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1631}
1706 chandle, &chandle);
1707 1632
1708 /* 1633void acpi_bus_trim(struct acpi_device *start)
1709 * If this scope is exhausted then move our way back up. 1634{
1710 */ 1635 mutex_lock(&acpi_scan_lock);
1711 if (ACPI_FAILURE(status)) {
1712 level--;
1713 chandle = phandle;
1714 acpi_get_parent(phandle, &phandle);
1715 child = parent;
1716 parent = parent->parent;
1717
1718 if (level == 0)
1719 err = acpi_bus_remove(child, rmdevice);
1720 else
1721 err = acpi_bus_remove(child, 1);
1722 1636
1723 continue; 1637 /*
1724 } 1638 * Execute acpi_bus_device_detach() as a post-order callback to detach
1639 * all ACPI drivers from the device nodes being removed.
1640 */
1641 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1642 acpi_bus_device_detach, NULL, NULL);
1643 acpi_bus_device_detach(start->handle, 0, NULL, NULL);
1644 /*
1645 * Execute acpi_bus_remove() as a post-order callback to remove device
1646 * nodes in the given namespace scope.
1647 */
1648 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1649 acpi_bus_remove, NULL, NULL);
1650 acpi_bus_remove(start->handle, 0, NULL, NULL);
1725 1651
1726 status = acpi_get_type(chandle, &type); 1652 mutex_unlock(&acpi_scan_lock);
1727 if (ACPI_FAILURE(status)) {
1728 continue;
1729 }
1730 /*
1731 * If there is a device corresponding to chandle then
1732 * parse it (depth-first).
1733 */
1734 if (acpi_bus_get_device(chandle, &child) == 0) {
1735 level++;
1736 phandle = chandle;
1737 chandle = NULL;
1738 parent = child;
1739 }
1740 continue;
1741 }
1742 return err;
1743} 1653}
1744EXPORT_SYMBOL_GPL(acpi_bus_trim); 1654EXPORT_SYMBOL_GPL(acpi_bus_trim);
1745 1655
@@ -1747,11 +1657,6 @@ static int acpi_bus_scan_fixed(void)
1747{ 1657{
1748 int result = 0; 1658 int result = 0;
1749 struct acpi_device *device = NULL; 1659 struct acpi_device *device = NULL;
1750 struct acpi_bus_ops ops;
1751
1752 memset(&ops, 0, sizeof(ops));
1753 ops.acpi_op_add = 1;
1754 ops.acpi_op_start = 1;
1755 1660
1756 /* 1661 /*
1757 * Enumerate all fixed-feature devices. 1662 * Enumerate all fixed-feature devices.
@@ -1759,16 +1664,14 @@ static int acpi_bus_scan_fixed(void)
1759 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1664 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
1760 result = acpi_add_single_object(&device, NULL, 1665 result = acpi_add_single_object(&device, NULL,
1761 ACPI_BUS_TYPE_POWER_BUTTON, 1666 ACPI_BUS_TYPE_POWER_BUTTON,
1762 ACPI_STA_DEFAULT, 1667 ACPI_STA_DEFAULT, true);
1763 &ops);
1764 device_init_wakeup(&device->dev, true); 1668 device_init_wakeup(&device->dev, true);
1765 } 1669 }
1766 1670
1767 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1671 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
1768 result = acpi_add_single_object(&device, NULL, 1672 result = acpi_add_single_object(&device, NULL,
1769 ACPI_BUS_TYPE_SLEEP_BUTTON, 1673 ACPI_BUS_TYPE_SLEEP_BUTTON,
1770 ACPI_STA_DEFAULT, 1674 ACPI_STA_DEFAULT, true);
1771 &ops);
1772 } 1675 }
1773 1676
1774 return result; 1677 return result;
@@ -1777,11 +1680,6 @@ static int acpi_bus_scan_fixed(void)
1777int __init acpi_scan_init(void) 1680int __init acpi_scan_init(void)
1778{ 1681{
1779 int result; 1682 int result;
1780 struct acpi_bus_ops ops;
1781
1782 memset(&ops, 0, sizeof(ops));
1783 ops.acpi_op_add = 1;
1784 ops.acpi_op_start = 1;
1785 1683
1786 result = bus_register(&acpi_bus_type); 1684 result = bus_register(&acpi_bus_type);
1787 if (result) { 1685 if (result) {
@@ -1790,19 +1688,25 @@ int __init acpi_scan_init(void)
1790 } 1688 }
1791 1689
1792 acpi_power_init(); 1690 acpi_power_init();
1691 acpi_pci_root_init();
1793 1692
1794 /* 1693 /*
1795 * Enumerate devices in the ACPI namespace. 1694 * Enumerate devices in the ACPI namespace.
1796 */ 1695 */
1797 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1696 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
1798 1697 if (result)
1799 if (!result) 1698 return result;
1800 result = acpi_bus_scan_fixed();
1801 1699
1700 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1802 if (result) 1701 if (result)
1803 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1702 return result;
1804 else
1805 acpi_update_all_gpes();
1806 1703
1807 return result; 1704 result = acpi_bus_scan_fixed();
1705 if (result) {
1706 acpi_device_unregister(acpi_root);
1707 return result;
1708 }
1709
1710 acpi_update_all_gpes();
1711 return 0;
1808} 1712}
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3d6d4fd1e3c5..d1a6f4a25da8 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -734,34 +734,24 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
734 */ 734 */
735static int acpiphp_bus_add(struct acpiphp_func *func) 735static int acpiphp_bus_add(struct acpiphp_func *func)
736{ 736{
737 acpi_handle phandle; 737 struct acpi_device *device;
738 struct acpi_device *device, *pdevice;
739 int ret_val; 738 int ret_val;
740 739
741 acpi_get_parent(func->handle, &phandle);
742 if (acpi_bus_get_device(phandle, &pdevice)) {
743 dbg("no parent device, assuming NULL\n");
744 pdevice = NULL;
745 }
746 if (!acpi_bus_get_device(func->handle, &device)) { 740 if (!acpi_bus_get_device(func->handle, &device)) {
747 dbg("bus exists... trim\n"); 741 dbg("bus exists... trim\n");
748 /* this shouldn't be in here, so remove 742 /* this shouldn't be in here, so remove
749 * the bus then re-add it... 743 * the bus then re-add it...
750 */ 744 */
751 ret_val = acpi_bus_trim(device, 1); 745 acpi_bus_trim(device);
752 dbg("acpi_bus_trim return %x\n", ret_val);
753 } 746 }
754 747
755 ret_val = acpi_bus_add(&device, pdevice, func->handle, 748 ret_val = acpi_bus_scan(func->handle);
756 ACPI_BUS_TYPE_DEVICE); 749 if (!ret_val)
757 if (ret_val) { 750 ret_val = acpi_bus_get_device(func->handle, &device);
758 dbg("error adding bus, %x\n", 751
759 -ret_val); 752 if (ret_val)
760 goto acpiphp_bus_add_out; 753 dbg("error adding bus, %x\n", -ret_val);
761 }
762 ret_val = acpi_bus_start(device);
763 754
764acpiphp_bus_add_out:
765 return ret_val; 755 return ret_val;
766} 756}
767 757
@@ -781,11 +771,8 @@ static int acpiphp_bus_trim(acpi_handle handle)
781 return retval; 771 return retval;
782 } 772 }
783 773
784 retval = acpi_bus_trim(device, 1); 774 acpi_bus_trim(device);
785 if (retval) 775 return 0;
786 err("cannot remove from acpi list\n");
787
788 return retval;
789} 776}
790 777
791static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 778static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
@@ -1130,8 +1117,7 @@ static int acpiphp_configure_bridge (acpi_handle handle)
1130 1117
1131static void handle_bridge_insertion(acpi_handle handle, u32 type) 1118static void handle_bridge_insertion(acpi_handle handle, u32 type)
1132{ 1119{
1133 struct acpi_device *device, *pdevice; 1120 struct acpi_device *device;
1134 acpi_handle phandle;
1135 1121
1136 if ((type != ACPI_NOTIFY_BUS_CHECK) && 1122 if ((type != ACPI_NOTIFY_BUS_CHECK) &&
1137 (type != ACPI_NOTIFY_DEVICE_CHECK)) { 1123 (type != ACPI_NOTIFY_DEVICE_CHECK)) {
@@ -1139,17 +1125,15 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
1139 return; 1125 return;
1140 } 1126 }
1141 1127
1142 acpi_get_parent(handle, &phandle); 1128 if (acpi_bus_scan(handle)) {
1143 if (acpi_bus_get_device(phandle, &pdevice)) {
1144 dbg("no parent device, assuming NULL\n");
1145 pdevice = NULL;
1146 }
1147 if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) {
1148 err("cannot add bridge to acpi list\n"); 1129 err("cannot add bridge to acpi list\n");
1149 return; 1130 return;
1150 } 1131 }
1151 if (!acpiphp_configure_bridge(handle) && 1132 if (acpi_bus_get_device(handle, &device)) {
1152 !acpi_bus_start(device)) 1133 err("ACPI device object missing\n");
1134 return;
1135 }
1136 if (!acpiphp_configure_bridge(handle))
1153 add_bridge(handle); 1137 add_bridge(handle);
1154 else 1138 else
1155 err("cannot configure and start bridge\n"); 1139 err("cannot configure and start bridge\n");
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index f64ca92253da..ae606b3e991e 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -412,7 +412,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
412 if (SN_ACPI_BASE_SUPPORT() && ssdt) { 412 if (SN_ACPI_BASE_SUPPORT() && ssdt) {
413 unsigned long long adr; 413 unsigned long long adr;
414 struct acpi_device *pdevice; 414 struct acpi_device *pdevice;
415 struct acpi_device *device;
416 acpi_handle phandle; 415 acpi_handle phandle;
417 acpi_handle chandle = NULL; 416 acpi_handle chandle = NULL;
418 acpi_handle rethandle; 417 acpi_handle rethandle;
@@ -448,17 +447,14 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
448 if (ACPI_SUCCESS(ret) && 447 if (ACPI_SUCCESS(ret) &&
449 (adr>>16) == (slot->device_num + 1)) { 448 (adr>>16) == (slot->device_num + 1)) {
450 449
451 ret = acpi_bus_add(&device, pdevice, chandle, 450 ret = acpi_bus_scan(chandle);
452 ACPI_BUS_TYPE_DEVICE);
453 if (ACPI_FAILURE(ret)) { 451 if (ACPI_FAILURE(ret)) {
454 printk(KERN_ERR "%s: acpi_bus_add " 452 printk(KERN_ERR "%s: acpi_bus_scan "
455 "failed (0x%x) for slot %d " 453 "failed (0x%x) for slot %d "
456 "func %d\n", __func__, 454 "func %d\n", __func__,
457 ret, (int)(adr>>16), 455 ret, (int)(adr>>16),
458 (int)(adr&0xffff)); 456 (int)(adr&0xffff));
459 /* try to continue on */ 457 /* try to continue on */
460 } else {
461 acpi_bus_start(device);
462 } 458 }
463 } 459 }
464 } 460 }
@@ -539,7 +535,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
539 ret = acpi_bus_get_device(chandle, 535 ret = acpi_bus_get_device(chandle,
540 &device); 536 &device);
541 if (ACPI_SUCCESS(ret)) 537 if (ACPI_SUCCESS(ret))
542 acpi_bus_trim(device, 1); 538 acpi_bus_trim(device);
543 } 539 }
544 } 540 }
545 541
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 1af4008182fd..42736e213f25 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -283,7 +283,6 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
283 .is_manageable = acpi_pci_power_manageable, 283 .is_manageable = acpi_pci_power_manageable,
284 .set_state = acpi_pci_set_power_state, 284 .set_state = acpi_pci_set_power_state,
285 .choose_state = acpi_pci_choose_state, 285 .choose_state = acpi_pci_choose_state,
286 .can_wakeup = acpi_pci_can_wakeup,
287 .sleep_wake = acpi_pci_sleep_wake, 286 .sleep_wake = acpi_pci_sleep_wake,
288 .run_wake = acpi_pci_run_wake, 287 .run_wake = acpi_pci_run_wake,
289}; 288};
@@ -321,10 +320,67 @@ static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle)
321 return 0; 320 return 0;
322} 321}
323 322
323static void pci_acpi_setup(struct device *dev)
324{
325 struct pci_dev *pci_dev = to_pci_dev(dev);
326 acpi_handle handle = ACPI_HANDLE(dev);
327 struct acpi_device *adev;
328 acpi_status status;
329 acpi_handle dummy;
330
331 /*
332 * Evaluate and parse _PRT, if exists. This code allows parsing of
333 * _PRT objects within the scope of non-bridge devices. Note that
334 * _PRTs within the scope of a PCI bridge assume the bridge's
335 * subordinate bus number.
336 *
337 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
338 */
339 status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy);
340 if (ACPI_SUCCESS(status)) {
341 unsigned char bus;
342
343 bus = pci_dev->subordinate ?
344 pci_dev->subordinate->number : pci_dev->bus->number;
345 acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus);
346 }
347
348 acpi_power_resource_register_device(dev, handle);
349 if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid)
350 return;
351
352 device_set_wakeup_capable(dev, true);
353 acpi_pci_sleep_wake(pci_dev, false);
354
355 pci_acpi_add_pm_notifier(adev, pci_dev);
356 if (adev->wakeup.flags.run_wake)
357 device_set_run_wake(dev, true);
358}
359
360static void pci_acpi_cleanup(struct device *dev)
361{
362 struct pci_dev *pci_dev = to_pci_dev(dev);
363 acpi_handle handle = ACPI_HANDLE(dev);
364 struct acpi_device *adev;
365
366 if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) {
367 device_set_wakeup_capable(dev, false);
368 device_set_run_wake(dev, false);
369 pci_acpi_remove_pm_notifier(adev);
370 }
371 acpi_power_resource_unregister_device(dev, handle);
372
373 if (pci_dev->subordinate)
374 acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus),
375 pci_dev->subordinate->number);
376}
377
324static struct acpi_bus_type acpi_pci_bus = { 378static struct acpi_bus_type acpi_pci_bus = {
325 .bus = &pci_bus_type, 379 .bus = &pci_bus_type,
326 .find_device = acpi_pci_find_device, 380 .find_device = acpi_pci_find_device,
327 .find_bridge = acpi_pci_find_root_bridge, 381 .find_bridge = acpi_pci_find_root_bridge,
382 .setup = pci_acpi_setup,
383 .cleanup = pci_acpi_cleanup,
328}; 384};
329 385
330static int __init acpi_pci_init(void) 386static int __init acpi_pci_init(void)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 5cb5820fae40..0c4f641b7be1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -450,7 +450,7 @@ static struct pci_platform_pm_ops *pci_platform_pm;
450int pci_set_platform_pm(struct pci_platform_pm_ops *ops) 450int pci_set_platform_pm(struct pci_platform_pm_ops *ops)
451{ 451{
452 if (!ops->is_manageable || !ops->set_state || !ops->choose_state 452 if (!ops->is_manageable || !ops->set_state || !ops->choose_state
453 || !ops->sleep_wake || !ops->can_wakeup) 453 || !ops->sleep_wake)
454 return -EINVAL; 454 return -EINVAL;
455 pci_platform_pm = ops; 455 pci_platform_pm = ops;
456 return 0; 456 return 0;
@@ -473,11 +473,6 @@ static inline pci_power_t platform_pci_choose_state(struct pci_dev *dev)
473 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; 473 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR;
474} 474}
475 475
476static inline bool platform_pci_can_wakeup(struct pci_dev *dev)
477{
478 return pci_platform_pm ? pci_platform_pm->can_wakeup(dev) : false;
479}
480
481static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable) 476static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
482{ 477{
483 return pci_platform_pm ? 478 return pci_platform_pm ?
@@ -1985,25 +1980,6 @@ void pci_pm_init(struct pci_dev *dev)
1985 } 1980 }
1986} 1981}
1987 1982
1988/**
1989 * platform_pci_wakeup_init - init platform wakeup if present
1990 * @dev: PCI device
1991 *
1992 * Some devices don't have PCI PM caps but can still generate wakeup
1993 * events through platform methods (like ACPI events). If @dev supports
1994 * platform wakeup events, set the device flag to indicate as much. This
1995 * may be redundant if the device also supports PCI PM caps, but double
1996 * initialization should be safe in that case.
1997 */
1998void platform_pci_wakeup_init(struct pci_dev *dev)
1999{
2000 if (!platform_pci_can_wakeup(dev))
2001 return;
2002
2003 device_set_wakeup_capable(&dev->dev, true);
2004 platform_pci_sleep_wake(dev, false);
2005}
2006
2007static void pci_add_saved_cap(struct pci_dev *pci_dev, 1983static void pci_add_saved_cap(struct pci_dev *pci_dev,
2008 struct pci_cap_saved_state *new_cap) 1984 struct pci_cap_saved_state *new_cap)
2009{ 1985{
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index e8518292826f..adfd172c5b9b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -43,9 +43,6 @@ int pci_probe_reset_function(struct pci_dev *dev);
43 * platform; to be used during system-wide transitions from a 43 * platform; to be used during system-wide transitions from a
44 * sleeping state to the working state and vice versa 44 * sleeping state to the working state and vice versa
45 * 45 *
46 * @can_wakeup: returns 'true' if given device is capable of waking up the
47 * system from a sleeping state
48 *
49 * @sleep_wake: enables/disables the system wake up capability of given device 46 * @sleep_wake: enables/disables the system wake up capability of given device
50 * 47 *
51 * @run_wake: enables/disables the platform to generate run-time wake-up events 48 * @run_wake: enables/disables the platform to generate run-time wake-up events
@@ -59,7 +56,6 @@ struct pci_platform_pm_ops {
59 bool (*is_manageable)(struct pci_dev *dev); 56 bool (*is_manageable)(struct pci_dev *dev);
60 int (*set_state)(struct pci_dev *dev, pci_power_t state); 57 int (*set_state)(struct pci_dev *dev, pci_power_t state);
61 pci_power_t (*choose_state)(struct pci_dev *dev); 58 pci_power_t (*choose_state)(struct pci_dev *dev);
62 bool (*can_wakeup)(struct pci_dev *dev);
63 int (*sleep_wake)(struct pci_dev *dev, bool enable); 59 int (*sleep_wake)(struct pci_dev *dev, bool enable);
64 int (*run_wake)(struct pci_dev *dev, bool enable); 60 int (*run_wake)(struct pci_dev *dev, bool enable);
65}; 61};
@@ -74,7 +70,6 @@ extern void pci_wakeup_bus(struct pci_bus *bus);
74extern void pci_config_pm_runtime_get(struct pci_dev *dev); 70extern void pci_config_pm_runtime_get(struct pci_dev *dev);
75extern void pci_config_pm_runtime_put(struct pci_dev *dev); 71extern void pci_config_pm_runtime_put(struct pci_dev *dev);
76extern void pci_pm_init(struct pci_dev *dev); 72extern void pci_pm_init(struct pci_dev *dev);
77extern void platform_pci_wakeup_init(struct pci_dev *dev);
78extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 73extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
79void pci_free_cap_save_buffers(struct pci_dev *dev); 74void pci_free_cap_save_buffers(struct pci_dev *dev);
80 75
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6186f03d84f3..2dcd22d9c816 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1280,7 +1280,6 @@ static void pci_init_capabilities(struct pci_dev *dev)
1280 1280
1281 /* Power Management */ 1281 /* Power Management */
1282 pci_pm_init(dev); 1282 pci_pm_init(dev);
1283 platform_pci_wakeup_init(dev);
1284 1283
1285 /* Vital Product Data */ 1284 /* Vital Product Data */
1286 pci_vpd_pci22_init(dev); 1285 pci_vpd_pci22_init(dev);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 7ced5dc20dd3..da7fb61ba868 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -91,21 +91,12 @@ struct acpi_device;
91typedef int (*acpi_op_add) (struct acpi_device * device); 91typedef int (*acpi_op_add) (struct acpi_device * device);
92typedef int (*acpi_op_remove) (struct acpi_device * device, int type); 92typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
93typedef int (*acpi_op_start) (struct acpi_device * device); 93typedef int (*acpi_op_start) (struct acpi_device * device);
94typedef int (*acpi_op_bind) (struct acpi_device * device);
95typedef int (*acpi_op_unbind) (struct acpi_device * device);
96typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); 94typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
97 95
98struct acpi_bus_ops {
99 u32 acpi_op_add:1;
100 u32 acpi_op_start:1;
101};
102
103struct acpi_device_ops { 96struct acpi_device_ops {
104 acpi_op_add add; 97 acpi_op_add add;
105 acpi_op_remove remove; 98 acpi_op_remove remove;
106 acpi_op_start start; 99 acpi_op_start start;
107 acpi_op_bind bind;
108 acpi_op_unbind unbind;
109 acpi_op_notify notify; 100 acpi_op_notify notify;
110}; 101};
111 102
@@ -148,7 +139,8 @@ struct acpi_device_flags {
148 u32 power_manageable:1; 139 u32 power_manageable:1;
149 u32 performance_manageable:1; 140 u32 performance_manageable:1;
150 u32 eject_pending:1; 141 u32 eject_pending:1;
151 u32 reserved:24; 142 u32 match_driver:1;
143 u32 reserved:23;
152}; 144};
153 145
154/* File System */ 146/* File System */
@@ -279,11 +271,9 @@ struct acpi_device {
279 struct acpi_device_wakeup wakeup; 271 struct acpi_device_wakeup wakeup;
280 struct acpi_device_perf performance; 272 struct acpi_device_perf performance;
281 struct acpi_device_dir dir; 273 struct acpi_device_dir dir;
282 struct acpi_device_ops ops;
283 struct acpi_driver *driver; 274 struct acpi_driver *driver;
284 void *driver_data; 275 void *driver_data;
285 struct device dev; 276 struct device dev;
286 struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */
287 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ 277 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */
288 u8 physical_node_count; 278 u8 physical_node_count;
289 struct list_head physical_node_list; 279 struct list_head physical_node_list;
@@ -316,7 +306,7 @@ struct acpi_bus_event {
316}; 306};
317 307
318struct acpi_eject_event { 308struct acpi_eject_event {
319 acpi_handle handle; 309 struct acpi_device *device;
320 u32 event; 310 u32 event;
321}; 311};
322 312
@@ -356,11 +346,9 @@ static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 ty
356#endif 346#endif
357int acpi_bus_register_driver(struct acpi_driver *driver); 347int acpi_bus_register_driver(struct acpi_driver *driver);
358void acpi_bus_unregister_driver(struct acpi_driver *driver); 348void acpi_bus_unregister_driver(struct acpi_driver *driver);
359int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, 349int acpi_bus_scan(acpi_handle handle);
360 acpi_handle handle, int type);
361void acpi_bus_hot_remove_device(void *context); 350void acpi_bus_hot_remove_device(void *context);
362int acpi_bus_trim(struct acpi_device *start, int rmdevice); 351void acpi_bus_trim(struct acpi_device *start);
363int acpi_bus_start(struct acpi_device *device);
364acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 352acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
365int acpi_match_device_ids(struct acpi_device *device, 353int acpi_match_device_ids(struct acpi_device *device,
366 const struct acpi_device_id *ids); 354 const struct acpi_device_id *ids);
@@ -390,6 +378,8 @@ struct acpi_bus_type {
390 int (*find_device) (struct device *, acpi_handle *); 378 int (*find_device) (struct device *, acpi_handle *);
391 /* For bridges, such as PCI root bridge, IDE controller */ 379 /* For bridges, such as PCI root bridge, IDE controller */
392 int (*find_bridge) (struct device *, acpi_handle *); 380 int (*find_bridge) (struct device *, acpi_handle *);
381 void (*setup)(struct device *);
382 void (*cleanup)(struct device *);
393}; 383};
394int register_acpi_bus_type(struct acpi_bus_type *); 384int register_acpi_bus_type(struct acpi_bus_type *);
395int unregister_acpi_bus_type(struct acpi_bus_type *); 385int unregister_acpi_bus_type(struct acpi_bus_type *);
@@ -397,7 +387,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *);
397struct acpi_pci_root { 387struct acpi_pci_root {
398 struct list_head node; 388 struct list_head node;
399 struct acpi_device * device; 389 struct acpi_device * device;
400 struct acpi_pci_id id;
401 struct pci_bus *bus; 390 struct pci_bus *bus;
402 u16 segment; 391 u16 segment;
403 struct resource secondary; /* downstream bus range */ 392 struct resource secondary; /* downstream bus range */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3994d7790b23..8c1d6f2a2193 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -526,9 +526,14 @@ static inline int acpi_subsys_resume_early(struct device *dev) { return 0; }
526#endif 526#endif
527 527
528#if defined(CONFIG_ACPI) && defined(CONFIG_PM) 528#if defined(CONFIG_ACPI) && defined(CONFIG_PM)
529struct acpi_device *acpi_dev_pm_get_node(struct device *dev);
529int acpi_dev_pm_attach(struct device *dev, bool power_on); 530int acpi_dev_pm_attach(struct device *dev, bool power_on);
530void acpi_dev_pm_detach(struct device *dev, bool power_off); 531void acpi_dev_pm_detach(struct device *dev, bool power_off);
531#else 532#else
533static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev)
534{
535 return NULL;
536}
532static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) 537static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
533{ 538{
534 return -ENODEV; 539 return -ENODEV;