aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:10:27 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-17 08:10:27 -0500
commit6a8dd80821c215bc49bf6b108e85c1738c82bf43 (patch)
tree3c8a42ca07fd69f9e11e0093e9eb041cad82c1c6
parent9931faca02c604c22335f5a935a501bb2ace6e20 (diff)
parent5993c4670ea2453ef5abb45b312f150e994e6eb9 (diff)
Merge branch 'acpi-scan' into acpi-pm
The following commits depend on the 'acpi-scan' material.
-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.c17
-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.c320
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c44
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c8
-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, 279 insertions, 563 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..d2a0656c3604 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_add(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..f8fb2281f34a 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_add(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..4a56a8b2e51e 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_add(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}
@@ -346,7 +339,7 @@ static void dock_remove_acpi_device(acpi_handle handle)
346 int ret; 339 int ret;
347 340
348 if (!acpi_bus_get_device(handle, &device)) { 341 if (!acpi_bus_get_device(handle, &device)) {
349 ret = acpi_bus_trim(device, 1); 342 ret = acpi_bus_trim(device);
350 if (ret) 343 if (ret)
351 pr_debug("error removing bus, %x\n", -ret); 344 pr_debug("error removing bus, %x\n", -ret);
352 } 345 }
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 95af6f674a6c..ba8e2c09cceb 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..a24ee43e06e4 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_add(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..7d164a966b0d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -116,24 +116,18 @@ static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
116void acpi_bus_hot_remove_device(void *context) 116void acpi_bus_hot_remove_device(void *context)
117{ 117{
118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; 118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context;
119 struct acpi_device *device; 119 struct acpi_device *device = ej_event->device;
120 acpi_handle handle = ej_event->handle; 120 acpi_handle handle = device->handle;
121 acpi_handle temp; 121 acpi_handle temp;
122 struct acpi_object_list arg_list; 122 struct acpi_object_list arg_list;
123 union acpi_object arg; 123 union acpi_object arg;
124 acpi_status status = AE_OK; 124 acpi_status status = AE_OK;
125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 125 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
126 126
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, 127 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
134 "Hot-removing device %s...\n", dev_name(&device->dev))); 128 "Hot-removing device %s...\n", dev_name(&device->dev)));
135 129
136 if (acpi_bus_trim(device, 1)) { 130 if (acpi_bus_trim(device)) {
137 printk(KERN_ERR PREFIX 131 printk(KERN_ERR PREFIX
138 "Removing device failed\n"); 132 "Removing device failed\n");
139 goto err_out; 133 goto err_out;
@@ -215,7 +209,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
215 goto err; 209 goto err;
216 } 210 }
217 211
218 ej_event->handle = acpi_device->handle; 212 ej_event->device = acpi_device;
219 if (acpi_device->flags.eject_pending) { 213 if (acpi_device->flags.eject_pending) {
220 /* event originated from ACPI eject notification */ 214 /* event originated from ACPI eject notification */
221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 215 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
@@ -223,7 +217,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
223 } else { 217 } else {
224 /* event originated from user */ 218 /* event originated from user */
225 ej_event->event = ACPI_OST_EC_OSPM_EJECT; 219 ej_event->event = ACPI_OST_EC_OSPM_EJECT;
226 (void) acpi_evaluate_hotplug_ost(ej_event->handle, 220 (void) acpi_evaluate_hotplug_ost(acpi_device->handle,
227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 221 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL);
228 } 222 }
229 223
@@ -494,7 +488,8 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
494 struct acpi_device *acpi_dev = to_acpi_device(dev); 488 struct acpi_device *acpi_dev = to_acpi_device(dev);
495 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 489 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
496 490
497 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); 491 return acpi_dev->flags.match_driver
492 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
498} 493}
499 494
500static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 495static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
@@ -570,7 +565,6 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
570} 565}
571 566
572static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 567static 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) 568static int acpi_device_probe(struct device * dev)
575{ 569{
576 struct acpi_device *acpi_dev = to_acpi_device(dev); 570 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -579,9 +573,6 @@ static int acpi_device_probe(struct device * dev)
579 573
580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 574 ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
581 if (!ret) { 575 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) { 576 if (acpi_drv->ops.notify) {
586 ret = acpi_device_install_notify_handler(acpi_dev); 577 ret = acpi_device_install_notify_handler(acpi_dev);
587 if (ret) { 578 if (ret) {
@@ -704,7 +695,7 @@ end:
704 return result; 695 return result;
705} 696}
706 697
707static void acpi_device_unregister(struct acpi_device *device, int type) 698static void acpi_device_unregister(struct acpi_device *device)
708{ 699{
709 mutex_lock(&acpi_device_lock); 700 mutex_lock(&acpi_device_lock);
710 if (device->parent) 701 if (device->parent)
@@ -760,24 +751,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
760 return 0; 751 return 0;
761} 752}
762 753
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/** 754/**
782 * acpi_bus_register_driver - register a driver with the ACPI bus 755 * acpi_bus_register_driver - register a driver with the ACPI bus
783 * @driver: driver being registered 756 * @driver: driver being registered
@@ -1395,33 +1368,9 @@ static int acpi_device_set_context(struct acpi_device *device)
1395 return -ENODEV; 1368 return -ENODEV;
1396} 1369}
1397 1370
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, 1371static int acpi_add_single_object(struct acpi_device **child,
1422 acpi_handle handle, int type, 1372 acpi_handle handle, int type,
1423 unsigned long long sta, 1373 unsigned long long sta, bool match_driver)
1424 struct acpi_bus_ops *ops)
1425{ 1374{
1426 int result; 1375 int result;
1427 struct acpi_device *device; 1376 struct acpi_device *device;
@@ -1437,7 +1386,6 @@ static int acpi_add_single_object(struct acpi_device **child,
1437 device->device_type = type; 1386 device->device_type = type;
1438 device->handle = handle; 1387 device->handle = handle;
1439 device->parent = acpi_bus_get_parent(handle); 1388 device->parent = acpi_bus_get_parent(handle);
1440 device->bus_ops = *ops; /* workround for not call .start */
1441 STRUCT_TO_INT(device->status) = sta; 1389 STRUCT_TO_INT(device->status) = sta;
1442 1390
1443 acpi_device_get_busid(device); 1391 acpi_device_get_busid(device);
@@ -1488,16 +1436,9 @@ static int acpi_add_single_object(struct acpi_device **child,
1488 if ((result = acpi_device_set_context(device))) 1436 if ((result = acpi_device_set_context(device)))
1489 goto end; 1437 goto end;
1490 1438
1439 device->flags.match_driver = match_driver;
1491 result = acpi_device_register(device); 1440 result = acpi_device_register(device);
1492 1441
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: 1442end:
1502 if (!result) { 1443 if (!result) {
1503 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 1444 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
@@ -1519,16 +1460,12 @@ end:
1519 1460
1520static void acpi_bus_add_power_resource(acpi_handle handle) 1461static void acpi_bus_add_power_resource(acpi_handle handle)
1521{ 1462{
1522 struct acpi_bus_ops ops = {
1523 .acpi_op_add = 1,
1524 .acpi_op_start = 1,
1525 };
1526 struct acpi_device *device = NULL; 1463 struct acpi_device *device = NULL;
1527 1464
1528 acpi_bus_get_device(handle, &device); 1465 acpi_bus_get_device(handle, &device);
1529 if (!device) 1466 if (!device)
1530 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, 1467 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER,
1531 ACPI_STA_DEFAULT, &ops); 1468 ACPI_STA_DEFAULT, true);
1532} 1469}
1533 1470
1534static int acpi_bus_type_and_status(acpi_handle handle, int *type, 1471static int acpi_bus_type_and_status(acpi_handle handle, int *type,
@@ -1570,16 +1507,19 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1570 return 0; 1507 return 0;
1571} 1508}
1572 1509
1573static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1510static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1574 void *context, void **return_value) 1511 void *not_used, void **return_value)
1575{ 1512{
1576 struct acpi_bus_ops *ops = context; 1513 struct acpi_device *device = NULL;
1577 int type; 1514 int type;
1578 unsigned long long sta; 1515 unsigned long long sta;
1579 struct acpi_device *device;
1580 acpi_status status; 1516 acpi_status status;
1581 int result; 1517 int result;
1582 1518
1519 acpi_bus_get_device(handle, &device);
1520 if (device)
1521 goto out;
1522
1583 result = acpi_bus_type_and_status(handle, &type, &sta); 1523 result = acpi_bus_type_and_status(handle, &type, &sta);
1584 if (result) 1524 if (result)
1585 return AE_OK; 1525 return AE_OK;
@@ -1596,150 +1536,130 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1596 return AE_CTRL_DEPTH; 1536 return AE_CTRL_DEPTH;
1597 } 1537 }
1598 1538
1599 /* 1539 acpi_add_single_object(&device, handle, type, sta,
1600 * We may already have an acpi_device from a previous enumeration. If 1540 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) 1541 if (!device)
1614 return AE_CTRL_DEPTH; 1542 return AE_CTRL_DEPTH;
1615 1543
1616 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1544 device->flags.match_driver = true;
1617 status = acpi_start_single_object(device);
1618 if (ACPI_FAILURE(status))
1619 return AE_CTRL_DEPTH;
1620 }
1621 1545
1546 out:
1622 if (!*return_value) 1547 if (!*return_value)
1623 *return_value = device; 1548 *return_value = device;
1549
1624 return AE_OK; 1550 return AE_OK;
1625} 1551}
1626 1552
1627static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1553static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1628 struct acpi_device **child) 1554 void *not_used, void **ret_not_used)
1555{
1556 acpi_status status = AE_OK;
1557 struct acpi_device *device;
1558 unsigned long long sta_not_used;
1559 int type_not_used;
1560
1561 /*
1562 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
1563 * namespace walks prematurely.
1564 */
1565 if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used))
1566 return AE_OK;
1567
1568 if (acpi_bus_get_device(handle, &device))
1569 return AE_CTRL_DEPTH;
1570
1571 if (!acpi_match_device_ids(device, acpi_platform_device_ids)) {
1572 /* This is a known good platform device. */
1573 acpi_create_platform_device(device);
1574 } else if (device_attach(&device->dev) < 0) {
1575 status = AE_CTRL_DEPTH;
1576 }
1577 return status;
1578}
1579
1580static int acpi_bus_scan(acpi_handle handle)
1629{ 1581{
1630 acpi_status status;
1631 void *device = NULL; 1582 void *device = NULL;
1632 1583
1633 status = acpi_bus_check_add(handle, 0, ops, &device); 1584 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1634 if (ACPI_SUCCESS(status))
1635 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1585 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1636 acpi_bus_check_add, NULL, ops, &device); 1586 acpi_bus_check_add, NULL, NULL, &device);
1637 1587
1638 if (child) 1588 if (!device)
1639 *child = device;
1640
1641 if (device)
1642 return 0;
1643 else
1644 return -ENODEV; 1589 return -ENODEV;
1590
1591 if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1592 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1593 acpi_bus_device_attach, NULL, NULL, NULL);
1594
1595 return 0;
1645} 1596}
1646 1597
1647/* 1598/**
1648 * acpi_bus_add and acpi_bus_start 1599 * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
1600 * @handle: Root of the namespace scope to scan.
1649 * 1601 *
1650 * scan a given ACPI tree and (probably recently hot-plugged) 1602 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1651 * create and add or starts found devices. 1603 * found devices.
1652 * 1604 *
1653 * If no devices were found -ENODEV is returned which does not 1605 * 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 1606 * 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 1607 * in the table trunk from which the kernel could create a device and add an
1656 * a device and add/start an appropriate driver. 1608 * appropriate driver.
1657 */ 1609 */
1658 1610int acpi_bus_add(acpi_handle handle)
1659int
1660acpi_bus_add(struct acpi_device **child,
1661 struct acpi_device *parent, acpi_handle handle, int type)
1662{ 1611{
1663 struct acpi_bus_ops ops; 1612 int err;
1664 1613
1665 memset(&ops, 0, sizeof(ops)); 1614 err = acpi_bus_scan(handle);
1666 ops.acpi_op_add = 1; 1615 if (err)
1616 return err;
1667 1617
1668 return acpi_bus_scan(handle, &ops, child); 1618 acpi_update_all_gpes();
1619 return 0;
1669} 1620}
1670EXPORT_SYMBOL(acpi_bus_add); 1621EXPORT_SYMBOL(acpi_bus_add);
1671 1622
1672int acpi_bus_start(struct acpi_device *device) 1623static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
1624 void *not_used, void **ret_not_used)
1673{ 1625{
1674 struct acpi_bus_ops ops; 1626 struct acpi_device *device = NULL;
1675 int result;
1676
1677 if (!device)
1678 return -EINVAL;
1679
1680 memset(&ops, 0, sizeof(ops));
1681 ops.acpi_op_start = 1;
1682
1683 result = acpi_bus_scan(device->handle, &ops, NULL);
1684
1685 acpi_update_all_gpes();
1686 1627
1687 return result; 1628 if (!acpi_bus_get_device(handle, &device)) {
1629 device->removal_type = ACPI_BUS_REMOVAL_EJECT;
1630 device_release_driver(&device->dev);
1631 }
1632 return AE_OK;
1688} 1633}
1689EXPORT_SYMBOL(acpi_bus_start);
1690 1634
1691int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1635static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
1636 void *not_used, void **ret_not_used)
1692{ 1637{
1693 acpi_status status; 1638 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
1700 parent = start;
1701 phandle = start->handle;
1702 child = chandle = NULL;
1703
1704 while ((level > 0) && parent && (!err)) {
1705 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle,
1706 chandle, &chandle);
1707 1639
1708 /* 1640 if (!acpi_bus_get_device(handle, &device))
1709 * If this scope is exhausted then move our way back up. 1641 acpi_device_unregister(device);
1710 */
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 1642
1723 continue; 1643 return AE_OK;
1724 } 1644}
1725 1645
1726 status = acpi_get_type(chandle, &type); 1646int acpi_bus_trim(struct acpi_device *start)
1727 if (ACPI_FAILURE(status)) { 1647{
1728 continue; 1648 /*
1729 } 1649 * Execute acpi_bus_device_detach() as a post-order callback to detach
1730 /* 1650 * all ACPI drivers from the device nodes being removed.
1731 * If there is a device corresponding to chandle then 1651 */
1732 * parse it (depth-first). 1652 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1733 */ 1653 acpi_bus_device_detach, NULL, NULL);
1734 if (acpi_bus_get_device(chandle, &child) == 0) { 1654 acpi_bus_device_detach(start->handle, 0, NULL, NULL);
1735 level++; 1655 /*
1736 phandle = chandle; 1656 * Execute acpi_bus_remove() as a post-order callback to remove device
1737 chandle = NULL; 1657 * nodes in the given namespace scope.
1738 parent = child; 1658 */
1739 } 1659 acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
1740 continue; 1660 acpi_bus_remove, NULL, NULL);
1741 } 1661 acpi_bus_remove(start->handle, 0, NULL, NULL);
1742 return err; 1662 return 0;
1743} 1663}
1744EXPORT_SYMBOL_GPL(acpi_bus_trim); 1664EXPORT_SYMBOL_GPL(acpi_bus_trim);
1745 1665
@@ -1747,11 +1667,6 @@ static int acpi_bus_scan_fixed(void)
1747{ 1667{
1748 int result = 0; 1668 int result = 0;
1749 struct acpi_device *device = NULL; 1669 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 1670
1756 /* 1671 /*
1757 * Enumerate all fixed-feature devices. 1672 * Enumerate all fixed-feature devices.
@@ -1759,16 +1674,14 @@ static int acpi_bus_scan_fixed(void)
1759 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1674 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
1760 result = acpi_add_single_object(&device, NULL, 1675 result = acpi_add_single_object(&device, NULL,
1761 ACPI_BUS_TYPE_POWER_BUTTON, 1676 ACPI_BUS_TYPE_POWER_BUTTON,
1762 ACPI_STA_DEFAULT, 1677 ACPI_STA_DEFAULT, true);
1763 &ops);
1764 device_init_wakeup(&device->dev, true); 1678 device_init_wakeup(&device->dev, true);
1765 } 1679 }
1766 1680
1767 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1681 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
1768 result = acpi_add_single_object(&device, NULL, 1682 result = acpi_add_single_object(&device, NULL,
1769 ACPI_BUS_TYPE_SLEEP_BUTTON, 1683 ACPI_BUS_TYPE_SLEEP_BUTTON,
1770 ACPI_STA_DEFAULT, 1684 ACPI_STA_DEFAULT, true);
1771 &ops);
1772 } 1685 }
1773 1686
1774 return result; 1687 return result;
@@ -1777,11 +1690,6 @@ static int acpi_bus_scan_fixed(void)
1777int __init acpi_scan_init(void) 1690int __init acpi_scan_init(void)
1778{ 1691{
1779 int result; 1692 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 1693
1786 result = bus_register(&acpi_bus_type); 1694 result = bus_register(&acpi_bus_type);
1787 if (result) { 1695 if (result) {
@@ -1790,17 +1698,21 @@ int __init acpi_scan_init(void)
1790 } 1698 }
1791 1699
1792 acpi_power_init(); 1700 acpi_power_init();
1701 acpi_pci_root_init();
1793 1702
1794 /* 1703 /*
1795 * Enumerate devices in the ACPI namespace. 1704 * Enumerate devices in the ACPI namespace.
1796 */ 1705 */
1797 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1706 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
1707 if (result)
1708 return result;
1798 1709
1710 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1799 if (!result) 1711 if (!result)
1800 result = acpi_bus_scan_fixed(); 1712 result = acpi_bus_scan_fixed();
1801 1713
1802 if (result) 1714 if (result)
1803 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1715 acpi_device_unregister(acpi_root);
1804 else 1716 else
1805 acpi_update_all_gpes(); 1717 acpi_update_all_gpes();
1806 1718
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3d6d4fd1e3c5..22006f2d9dd5 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -734,34 +734,25 @@ 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 ret_val = acpi_bus_trim(device);
752 dbg("acpi_bus_trim return %x\n", ret_val); 746 dbg("acpi_bus_trim return %x\n", ret_val);
753 } 747 }
754 748
755 ret_val = acpi_bus_add(&device, pdevice, func->handle, 749 ret_val = acpi_bus_add(func->handle);
756 ACPI_BUS_TYPE_DEVICE); 750 if (!ret_val)
757 if (ret_val) { 751 ret_val = acpi_bus_get_device(func->handle, &device);
758 dbg("error adding bus, %x\n", 752
759 -ret_val); 753 if (ret_val)
760 goto acpiphp_bus_add_out; 754 dbg("error adding bus, %x\n", -ret_val);
761 }
762 ret_val = acpi_bus_start(device);
763 755
764acpiphp_bus_add_out:
765 return ret_val; 756 return ret_val;
766} 757}
767 758
@@ -781,7 +772,7 @@ static int acpiphp_bus_trim(acpi_handle handle)
781 return retval; 772 return retval;
782 } 773 }
783 774
784 retval = acpi_bus_trim(device, 1); 775 retval = acpi_bus_trim(device);
785 if (retval) 776 if (retval)
786 err("cannot remove from acpi list\n"); 777 err("cannot remove from acpi list\n");
787 778
@@ -1130,8 +1121,7 @@ static int acpiphp_configure_bridge (acpi_handle handle)
1130 1121
1131static void handle_bridge_insertion(acpi_handle handle, u32 type) 1122static void handle_bridge_insertion(acpi_handle handle, u32 type)
1132{ 1123{
1133 struct acpi_device *device, *pdevice; 1124 struct acpi_device *device;
1134 acpi_handle phandle;
1135 1125
1136 if ((type != ACPI_NOTIFY_BUS_CHECK) && 1126 if ((type != ACPI_NOTIFY_BUS_CHECK) &&
1137 (type != ACPI_NOTIFY_DEVICE_CHECK)) { 1127 (type != ACPI_NOTIFY_DEVICE_CHECK)) {
@@ -1139,17 +1129,15 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
1139 return; 1129 return;
1140 } 1130 }
1141 1131
1142 acpi_get_parent(handle, &phandle); 1132 if (acpi_bus_add(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"); 1133 err("cannot add bridge to acpi list\n");
1149 return; 1134 return;
1150 } 1135 }
1151 if (!acpiphp_configure_bridge(handle) && 1136 if (acpi_bus_get_device(handle, &device)) {
1152 !acpi_bus_start(device)) 1137 err("ACPI device object missing\n");
1138 return;
1139 }
1140 if (!acpiphp_configure_bridge(handle))
1153 add_bridge(handle); 1141 add_bridge(handle);
1154 else 1142 else
1155 err("cannot configure and start bridge\n"); 1143 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..2e006ee5738b 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,8 +447,7 @@ 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_add(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_add "
455 "failed (0x%x) for slot %d " 453 "failed (0x%x) for slot %d "
@@ -457,8 +455,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
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..567851b4f043 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_add(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); 351int 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;