aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/acpi_memhotplug.c24
-rw-r--r--drivers/acpi/container.c31
-rw-r--r--drivers/acpi/device_pm.c2
-rw-r--r--drivers/acpi/dock.c15
-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.c30
-rw-r--r--drivers/acpi/scan.c208
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c40
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c6
-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.h18
-rw-r--r--include/linux/acpi.h5
19 files changed, 232 insertions, 479 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 eb30e5ab4cab..327ab4459558 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);
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 f09dc987cf17..e4f6ac95595c 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..9e31b2bd93d3 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}
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 01551840d236..ac00b882e75d 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -63,6 +63,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
63{ 63{
64 struct acpi_bus_type *tmp, *ret = NULL; 64 struct acpi_bus_type *tmp, *ret = NULL;
65 65
66 if (!type)
67 return NULL;
68
66 down_read(&bus_type_sem); 69 down_read(&bus_type_sem);
67 list_for_each_entry(tmp, &bus_type_list, list) { 70 list_for_each_entry(tmp, &bus_type_list, list) {
68 if (tmp->bus == type) { 71 if (tmp->bus == type) {
@@ -264,28 +267,39 @@ static int acpi_platform_notify(struct device *dev)
264{ 267{
265 struct acpi_bus_type *type; 268 struct acpi_bus_type *type;
266 acpi_handle handle; 269 acpi_handle handle;
267 int ret = -EINVAL; 270 int ret;
268 271
269 ret = acpi_bind_one(dev, NULL); 272 ret = acpi_bind_one(dev, NULL);
270 if (!ret) 273 if (ret && (!dev->bus || !dev->parent)) {
271 goto out;
272
273 if (!dev->bus || !dev->parent) {
274 /* bridge devices genernally haven't bus or parent */ 274 /* bridge devices genernally haven't bus or parent */
275 ret = acpi_find_bridge_device(dev, &handle); 275 ret = acpi_find_bridge_device(dev, &handle);
276 goto end; 276 if (!ret) {
277 ret = acpi_bind_one(dev, handle);
278 if (ret)
279 goto out;
280 }
277 } 281 }
282
278 type = acpi_get_bus_type(dev->bus); 283 type = acpi_get_bus_type(dev->bus);
279 if (!type) { 284 if (ret) {
280 DBG("No ACPI bus support for %s\n", dev_name(dev)); 285 if (!type || !type->find_device) {
281 ret = -EINVAL; 286 DBG("No ACPI bus support for %s\n", dev_name(dev));
282 goto end; 287 ret = -EINVAL;
288 goto out;
289 }
290
291 ret = type->find_device(dev, &handle);
292 if (ret) {
293 DBG("Unable to get handle for %s\n", dev_name(dev));
294 goto out;
295 }
296 ret = acpi_bind_one(dev, handle);
297 if (ret)
298 goto out;
283 } 299 }
284 if ((ret = type->find_device(dev, &handle)) != 0) 300
285 DBG("Can't get handler for %s\n", dev_name(dev)); 301 if (type && type->setup)
286 end: 302 type->setup(dev);
287 if (!ret)
288 acpi_bind_one(dev, handle);
289 303
290 out: 304 out:
291#if ACPI_GLUE_DEBUG 305#if ACPI_GLUE_DEBUG
@@ -304,6 +318,12 @@ static int acpi_platform_notify(struct device *dev)
304 318
305static int acpi_platform_notify_remove(struct device *dev) 319static int acpi_platform_notify_remove(struct device *dev)
306{ 320{
321 struct acpi_bus_type *type;
322
323 type = acpi_get_bus_type(dev->bus);
324 if (type && type->cleanup)
325 type->cleanup(dev);
326
307 acpi_unbind_one(dev); 327 acpi_unbind_one(dev);
308 return 0; 328 return 0;
309} 329}
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 dcbe9660e756..471b2dcb1c67 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 pcibios_resource_survey_bus(root->bus); 604 pcibios_resource_survey_bus(root->bus);
655 pci_assign_unassigned_bus_resources(root->bus); 605 pci_assign_unassigned_bus_resources(root->bus);
@@ -666,8 +616,17 @@ static int acpi_pci_root_start(struct acpi_device *device)
666 pci_enable_bridges(root->bus); 616 pci_enable_bridges(root->bus);
667 617
668 pci_bus_add_devices(root->bus); 618 pci_bus_add_devices(root->bus);
669
670 return 0; 619 return 0;
620
621out_del_root:
622 mutex_lock(&acpi_pci_root_lock);
623 list_del(&root->node);
624 mutex_unlock(&acpi_pci_root_lock);
625
626 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
627end:
628 kfree(root);
629 return result;
671} 630}
672 631
673static int acpi_pci_root_remove(struct acpi_device *device, int type) 632static int acpi_pci_root_remove(struct acpi_device *device, int type)
@@ -701,7 +660,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
701 return 0; 660 return 0;
702} 661}
703 662
704static int __init acpi_pci_root_init(void) 663int __init acpi_pci_root_init(void)
705{ 664{
706 acpi_hest_init(); 665 acpi_hest_init();
707 666
@@ -714,5 +673,3 @@ static int __init acpi_pci_root_init(void)
714 673
715 return 0; 674 return 0;
716} 675}
717
718subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1ebd..0777663f443e 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
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 53502d1bbf26..e380345b643a 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -494,7 +494,8 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
494 struct acpi_device *acpi_dev = to_acpi_device(dev); 494 struct acpi_device *acpi_dev = to_acpi_device(dev);
495 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 495 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
496 496
497 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids); 497 return acpi_dev->flags.match_driver
498 && !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
498} 499}
499 500
500static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 501static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
@@ -570,7 +571,6 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
570} 571}
571 572
572static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 573static 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) 574static int acpi_device_probe(struct device * dev)
575{ 575{
576 struct acpi_device *acpi_dev = to_acpi_device(dev); 576 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -579,9 +579,6 @@ static int acpi_device_probe(struct device * dev)
579 579
580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
581 if (!ret) { 581 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) { 582 if (acpi_drv->ops.notify) {
586 ret = acpi_device_install_notify_handler(acpi_dev); 583 ret = acpi_device_install_notify_handler(acpi_dev);
587 if (ret) { 584 if (ret) {
@@ -760,24 +757,6 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
760 return 0; 757 return 0;
761} 758}
762 759
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/** 760/**
782 * acpi_bus_register_driver - register a driver with the ACPI bus 761 * acpi_bus_register_driver - register a driver with the ACPI bus
783 * @driver: driver being registered 762 * @driver: driver being registered
@@ -1406,13 +1385,6 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1406 if (!rmdevice) 1385 if (!rmdevice)
1407 return 0; 1386 return 0;
1408 1387
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); 1388 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
1417 1389
1418 return 0; 1390 return 0;
@@ -1420,8 +1392,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1420 1392
1421static int acpi_add_single_object(struct acpi_device **child, 1393static int acpi_add_single_object(struct acpi_device **child,
1422 acpi_handle handle, int type, 1394 acpi_handle handle, int type,
1423 unsigned long long sta, 1395 unsigned long long sta, bool match_driver)
1424 struct acpi_bus_ops *ops)
1425{ 1396{
1426 int result; 1397 int result;
1427 struct acpi_device *device; 1398 struct acpi_device *device;
@@ -1437,7 +1408,6 @@ static int acpi_add_single_object(struct acpi_device **child,
1437 device->device_type = type; 1408 device->device_type = type;
1438 device->handle = handle; 1409 device->handle = handle;
1439 device->parent = acpi_bus_get_parent(handle); 1410 device->parent = acpi_bus_get_parent(handle);
1440 device->bus_ops = *ops; /* workround for not call .start */
1441 STRUCT_TO_INT(device->status) = sta; 1411 STRUCT_TO_INT(device->status) = sta;
1442 1412
1443 acpi_device_get_busid(device); 1413 acpi_device_get_busid(device);
@@ -1488,16 +1458,9 @@ static int acpi_add_single_object(struct acpi_device **child,
1488 if ((result = acpi_device_set_context(device))) 1458 if ((result = acpi_device_set_context(device)))
1489 goto end; 1459 goto end;
1490 1460
1461 device->flags.match_driver = match_driver;
1491 result = acpi_device_register(device); 1462 result = acpi_device_register(device);
1492 1463
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: 1464end:
1502 if (!result) { 1465 if (!result) {
1503 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 1466 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
@@ -1519,16 +1482,12 @@ end:
1519 1482
1520static void acpi_bus_add_power_resource(acpi_handle handle) 1483static void acpi_bus_add_power_resource(acpi_handle handle)
1521{ 1484{
1522 struct acpi_bus_ops ops = {
1523 .acpi_op_add = 1,
1524 .acpi_op_start = 1,
1525 };
1526 struct acpi_device *device = NULL; 1485 struct acpi_device *device = NULL;
1527 1486
1528 acpi_bus_get_device(handle, &device); 1487 acpi_bus_get_device(handle, &device);
1529 if (!device) 1488 if (!device)
1530 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, 1489 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER,
1531 ACPI_STA_DEFAULT, &ops); 1490 ACPI_STA_DEFAULT, true);
1532} 1491}
1533 1492
1534static int acpi_bus_type_and_status(acpi_handle handle, int *type, 1493static int acpi_bus_type_and_status(acpi_handle handle, int *type,
@@ -1570,16 +1529,19 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1570 return 0; 1529 return 0;
1571} 1530}
1572 1531
1573static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1532static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1574 void *context, void **return_value) 1533 void *not_used, void **return_value)
1575{ 1534{
1576 struct acpi_bus_ops *ops = context; 1535 struct acpi_device *device = NULL;
1577 int type; 1536 int type;
1578 unsigned long long sta; 1537 unsigned long long sta;
1579 struct acpi_device *device;
1580 acpi_status status; 1538 acpi_status status;
1581 int result; 1539 int result;
1582 1540
1541 acpi_bus_get_device(handle, &device);
1542 if (device)
1543 goto out;
1544
1583 result = acpi_bus_type_and_status(handle, &type, &sta); 1545 result = acpi_bus_type_and_status(handle, &type, &sta);
1584 if (result) 1546 if (result)
1585 return AE_OK; 1547 return AE_OK;
@@ -1596,97 +1558,89 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1596 return AE_CTRL_DEPTH; 1558 return AE_CTRL_DEPTH;
1597 } 1559 }
1598 1560
1599 /* 1561 acpi_add_single_object(&device, handle, type, sta,
1600 * We may already have an acpi_device from a previous enumeration. If 1562 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) 1563 if (!device)
1614 return AE_CTRL_DEPTH; 1564 return AE_CTRL_DEPTH;
1615 1565
1616 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1566 device->flags.match_driver = true;
1617 status = acpi_start_single_object(device);
1618 if (ACPI_FAILURE(status))
1619 return AE_CTRL_DEPTH;
1620 }
1621 1567
1568 out:
1622 if (!*return_value) 1569 if (!*return_value)
1623 *return_value = device; 1570 *return_value = device;
1571
1624 return AE_OK; 1572 return AE_OK;
1625} 1573}
1626 1574
1627static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1575static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
1628 struct acpi_device **child) 1576 void *not_used, void **ret_not_used)
1629{ 1577{
1630 acpi_status status; 1578 acpi_status status = AE_OK;
1631 void *device = NULL; 1579 struct acpi_device *device;
1580 unsigned long long sta_not_used;
1581 int type_not_used;
1632 1582
1633 status = acpi_bus_check_add(handle, 0, ops, &device); 1583 /*
1634 if (ACPI_SUCCESS(status)) 1584 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
1635 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1585 * namespace walks prematurely.
1636 acpi_bus_check_add, NULL, ops, &device); 1586 */
1587 if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used))
1588 return AE_OK;
1637 1589
1638 if (child) 1590 if (acpi_bus_get_device(handle, &device))
1639 *child = device; 1591 return AE_CTRL_DEPTH;
1640 1592
1641 if (device) 1593 if (!acpi_match_device_ids(device, acpi_platform_device_ids)) {
1642 return 0; 1594 /* This is a known good platform device. */
1643 else 1595 acpi_create_platform_device(device);
1644 return -ENODEV; 1596 } else if (device_attach(&device->dev)) {
1597 status = AE_CTRL_DEPTH;
1598 }
1599 return status;
1645} 1600}
1646 1601
1647/* 1602static int acpi_bus_scan(acpi_handle handle)
1648 * acpi_bus_add and acpi_bus_start
1649 *
1650 * scan a given ACPI tree and (probably recently hot-plugged)
1651 * create and add or starts found devices.
1652 *
1653 * If no devices were found -ENODEV is returned which does not
1654 * mean that this is a real error, there just have been no suitable
1655 * ACPI objects in the table trunk from which the kernel could create
1656 * a device and add/start an appropriate driver.
1657 */
1658
1659int
1660acpi_bus_add(struct acpi_device **child,
1661 struct acpi_device *parent, acpi_handle handle, int type)
1662{ 1603{
1663 struct acpi_bus_ops ops; 1604 void *device = NULL;
1664 1605
1665 memset(&ops, 0, sizeof(ops)); 1606 if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
1666 ops.acpi_op_add = 1; 1607 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1608 acpi_bus_check_add, NULL, NULL, &device);
1667 1609
1668 return acpi_bus_scan(handle, &ops, child); 1610 if (!device)
1669} 1611 return -ENODEV;
1670EXPORT_SYMBOL(acpi_bus_add);
1671 1612
1672int acpi_bus_start(struct acpi_device *device) 1613 if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
1673{ 1614 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1674 struct acpi_bus_ops ops; 1615 acpi_bus_device_attach, NULL, NULL, NULL);
1675 int result;
1676 1616
1677 if (!device) 1617 return 0;
1678 return -EINVAL; 1618}
1679 1619
1680 memset(&ops, 0, sizeof(ops)); 1620/**
1681 ops.acpi_op_start = 1; 1621 * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
1622 * @handle: Root of the namespace scope to scan.
1623 *
1624 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
1625 * found devices.
1626 *
1627 * If no devices were found, -ENODEV is returned, but it does not mean that
1628 * there has been a real error. There just have been no suitable ACPI objects
1629 * in the table trunk from which the kernel could create a device and add an
1630 * appropriate driver.
1631 */
1632int acpi_bus_add(acpi_handle handle)
1633{
1634 int err;
1682 1635
1683 result = acpi_bus_scan(device->handle, &ops, NULL); 1636 err = acpi_bus_scan(handle);
1637 if (err)
1638 return err;
1684 1639
1685 acpi_update_all_gpes(); 1640 acpi_update_all_gpes();
1686 1641 return 0;
1687 return result;
1688} 1642}
1689EXPORT_SYMBOL(acpi_bus_start); 1643EXPORT_SYMBOL(acpi_bus_add);
1690 1644
1691int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1645int acpi_bus_trim(struct acpi_device *start, int rmdevice)
1692{ 1646{
@@ -1747,11 +1701,6 @@ static int acpi_bus_scan_fixed(void)
1747{ 1701{
1748 int result = 0; 1702 int result = 0;
1749 struct acpi_device *device = NULL; 1703 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 1704
1756 /* 1705 /*
1757 * Enumerate all fixed-feature devices. 1706 * Enumerate all fixed-feature devices.
@@ -1759,16 +1708,14 @@ static int acpi_bus_scan_fixed(void)
1759 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1708 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
1760 result = acpi_add_single_object(&device, NULL, 1709 result = acpi_add_single_object(&device, NULL,
1761 ACPI_BUS_TYPE_POWER_BUTTON, 1710 ACPI_BUS_TYPE_POWER_BUTTON,
1762 ACPI_STA_DEFAULT, 1711 ACPI_STA_DEFAULT, true);
1763 &ops);
1764 device_init_wakeup(&device->dev, true); 1712 device_init_wakeup(&device->dev, true);
1765 } 1713 }
1766 1714
1767 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1715 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
1768 result = acpi_add_single_object(&device, NULL, 1716 result = acpi_add_single_object(&device, NULL,
1769 ACPI_BUS_TYPE_SLEEP_BUTTON, 1717 ACPI_BUS_TYPE_SLEEP_BUTTON,
1770 ACPI_STA_DEFAULT, 1718 ACPI_STA_DEFAULT, true);
1771 &ops);
1772 } 1719 }
1773 1720
1774 return result; 1721 return result;
@@ -1777,11 +1724,6 @@ static int acpi_bus_scan_fixed(void)
1777int __init acpi_scan_init(void) 1724int __init acpi_scan_init(void)
1778{ 1725{
1779 int result; 1726 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 1727
1786 result = bus_register(&acpi_bus_type); 1728 result = bus_register(&acpi_bus_type);
1787 if (result) { 1729 if (result) {
@@ -1790,12 +1732,16 @@ int __init acpi_scan_init(void)
1790 } 1732 }
1791 1733
1792 acpi_power_init(); 1734 acpi_power_init();
1735 acpi_pci_root_init();
1793 1736
1794 /* 1737 /*
1795 * Enumerate devices in the ACPI namespace. 1738 * Enumerate devices in the ACPI namespace.
1796 */ 1739 */
1797 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1740 result = acpi_bus_scan(ACPI_ROOT_OBJECT);
1741 if (result)
1742 return result;
1798 1743
1744 result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
1799 if (!result) 1745 if (!result)
1800 result = acpi_bus_scan_fixed(); 1746 result = acpi_bus_scan_fixed();
1801 1747
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3d6d4fd1e3c5..91b5ad875c53 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -734,15 +734,9 @@ 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
@@ -752,16 +746,13 @@ static int acpiphp_bus_add(struct acpiphp_func *func)
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
@@ -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..f3c419256d2a 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 }
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..a9e1421cd007 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -95,17 +95,10 @@ typedef int (*acpi_op_bind) (struct acpi_device * device);
95typedef int (*acpi_op_unbind) (struct acpi_device * device); 95typedef int (*acpi_op_unbind) (struct acpi_device * device);
96typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); 96typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);
97 97
98struct acpi_bus_ops {
99 u32 acpi_op_add:1;
100 u32 acpi_op_start:1;
101};
102
103struct acpi_device_ops { 98struct acpi_device_ops {
104 acpi_op_add add; 99 acpi_op_add add;
105 acpi_op_remove remove; 100 acpi_op_remove remove;
106 acpi_op_start start; 101 acpi_op_start start;
107 acpi_op_bind bind;
108 acpi_op_unbind unbind;
109 acpi_op_notify notify; 102 acpi_op_notify notify;
110}; 103};
111 104
@@ -148,7 +141,8 @@ struct acpi_device_flags {
148 u32 power_manageable:1; 141 u32 power_manageable:1;
149 u32 performance_manageable:1; 142 u32 performance_manageable:1;
150 u32 eject_pending:1; 143 u32 eject_pending:1;
151 u32 reserved:24; 144 u32 match_driver:1;
145 u32 reserved:23;
152}; 146};
153 147
154/* File System */ 148/* File System */
@@ -283,7 +277,6 @@ struct acpi_device {
283 struct acpi_driver *driver; 277 struct acpi_driver *driver;
284 void *driver_data; 278 void *driver_data;
285 struct device dev; 279 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 */ 280 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */
288 u8 physical_node_count; 281 u8 physical_node_count;
289 struct list_head physical_node_list; 282 struct list_head physical_node_list;
@@ -356,11 +349,9 @@ static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 ty
356#endif 349#endif
357int acpi_bus_register_driver(struct acpi_driver *driver); 350int acpi_bus_register_driver(struct acpi_driver *driver);
358void acpi_bus_unregister_driver(struct acpi_driver *driver); 351void acpi_bus_unregister_driver(struct acpi_driver *driver);
359int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, 352int acpi_bus_add(acpi_handle handle);
360 acpi_handle handle, int type);
361void acpi_bus_hot_remove_device(void *context); 353void acpi_bus_hot_remove_device(void *context);
362int acpi_bus_trim(struct acpi_device *start, int rmdevice); 354int acpi_bus_trim(struct acpi_device *start, int rmdevice);
363int acpi_bus_start(struct acpi_device *device);
364acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 355acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
365int acpi_match_device_ids(struct acpi_device *device, 356int acpi_match_device_ids(struct acpi_device *device,
366 const struct acpi_device_id *ids); 357 const struct acpi_device_id *ids);
@@ -390,6 +381,8 @@ struct acpi_bus_type {
390 int (*find_device) (struct device *, acpi_handle *); 381 int (*find_device) (struct device *, acpi_handle *);
391 /* For bridges, such as PCI root bridge, IDE controller */ 382 /* For bridges, such as PCI root bridge, IDE controller */
392 int (*find_bridge) (struct device *, acpi_handle *); 383 int (*find_bridge) (struct device *, acpi_handle *);
384 void (*setup)(struct device *);
385 void (*cleanup)(struct device *);
393}; 386};
394int register_acpi_bus_type(struct acpi_bus_type *); 387int register_acpi_bus_type(struct acpi_bus_type *);
395int unregister_acpi_bus_type(struct acpi_bus_type *); 388int unregister_acpi_bus_type(struct acpi_bus_type *);
@@ -397,7 +390,6 @@ int unregister_acpi_bus_type(struct acpi_bus_type *);
397struct acpi_pci_root { 390struct acpi_pci_root {
398 struct list_head node; 391 struct list_head node;
399 struct acpi_device * device; 392 struct acpi_device * device;
400 struct acpi_pci_id id;
401 struct pci_bus *bus; 393 struct pci_bus *bus;
402 u16 segment; 394 u16 segment;
403 struct resource secondary; /* downstream bus range */ 395 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;