aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-18 07:48:30 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-18 07:48:30 -0500
commit0b3571274b8ff53c0e08bc667ecd3d8a43bd8714 (patch)
tree57fa58c4c5abe63cccf3fd842548d16fc8d792ba /drivers/acpi
parent7d1f9aeff1ee4a20b1aeb377dd0f579fe9647619 (diff)
parent5993c4670ea2453ef5abb45b312f150e994e6eb9 (diff)
Merge branch 'acpi-scan' into acpi-lpss
The following commits depend on the 'acpi-scan' material.
Diffstat (limited to 'drivers/acpi')
-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
11 files changed, 191 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 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 35da18113216..9aee4fc2b218 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -68,6 +68,9 @@ static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
68{ 68{
69 struct acpi_bus_type *tmp, *ret = NULL; 69 struct acpi_bus_type *tmp, *ret = NULL;
70 70
71 if (!type)
72 return NULL;
73
71 down_read(&bus_type_sem); 74 down_read(&bus_type_sem);
72 list_for_each_entry(tmp, &bus_type_list, list) { 75 list_for_each_entry(tmp, &bus_type_list, list) {
73 if (tmp->bus == type) { 76 if (tmp->bus == type) {
@@ -269,28 +272,39 @@ static int acpi_platform_notify(struct device *dev)
269{ 272{
270 struct acpi_bus_type *type; 273 struct acpi_bus_type *type;
271 acpi_handle handle; 274 acpi_handle handle;
272 int ret = -EINVAL; 275 int ret;
273 276
274 ret = acpi_bind_one(dev, NULL); 277 ret = acpi_bind_one(dev, NULL);
275 if (!ret) 278 if (ret && (!dev->bus || !dev->parent)) {
276 goto out;
277
278 if (!dev->bus || !dev->parent) {
279 /* bridge devices genernally haven't bus or parent */ 279 /* bridge devices genernally haven't bus or parent */
280 ret = acpi_find_bridge_device(dev, &handle); 280 ret = acpi_find_bridge_device(dev, &handle);
281 goto end; 281 if (!ret) {
282 ret = acpi_bind_one(dev, handle);
283 if (ret)
284 goto out;
285 }
282 } 286 }
287
283 type = acpi_get_bus_type(dev->bus); 288 type = acpi_get_bus_type(dev->bus);
284 if (!type) { 289 if (ret) {
285 DBG("No ACPI bus support for %s\n", dev_name(dev)); 290 if (!type || !type->find_device) {
286 ret = -EINVAL; 291 DBG("No ACPI bus support for %s\n", dev_name(dev));
287 goto end; 292 ret = -EINVAL;
293 goto out;
294 }
295
296 ret = type->find_device(dev, &handle);
297 if (ret) {
298 DBG("Unable to get handle for %s\n", dev_name(dev));
299 goto out;
300 }
301 ret = acpi_bind_one(dev, handle);
302 if (ret)
303 goto out;
288 } 304 }
289 if ((ret = type->find_device(dev, &handle)) != 0) 305
290 DBG("Can't get handler for %s\n", dev_name(dev)); 306 if (type && type->setup)
291 end: 307 type->setup(dev);
292 if (!ret)
293 acpi_bind_one(dev, handle);
294 308
295 out: 309 out:
296#if ACPI_GLUE_DEBUG 310#if ACPI_GLUE_DEBUG
@@ -309,6 +323,12 @@ static int acpi_platform_notify(struct device *dev)
309 323
310static int acpi_platform_notify_remove(struct device *dev) 324static int acpi_platform_notify_remove(struct device *dev)
311{ 325{
326 struct acpi_bus_type *type;
327
328 type = acpi_get_bus_type(dev->bus);
329 if (type && type->cleanup)
330 type->cleanup(dev);
331
312 acpi_unbind_one(dev); 332 acpi_unbind_one(dev);
313 return 0; 333 return 0;
314} 334}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 3c407cdc1ec1..e050254ae143 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -67,6 +67,7 @@ struct acpi_ec {
67 67
68extern struct acpi_ec *first_ec; 68extern struct acpi_ec *first_ec;
69 69
70int acpi_pci_root_init(void);
70int acpi_ec_init(void); 71int acpi_ec_init(void);
71int acpi_ec_ecdt_probe(void); 72int acpi_ec_ecdt_probe(void);
72int acpi_boot_ec_enable(void); 73int acpi_boot_ec_enable(void);
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
deleted file mode 100644
index a1dee29beed3..000000000000
--- a/drivers/acpi/pci_bind.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)
3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#include <linux/kernel.h>
27#include <linux/types.h>
28#include <linux/pci.h>
29#include <linux/pci-acpi.h>
30#include <linux/acpi.h>
31#include <linux/pm_runtime.h>
32#include <acpi/acpi_bus.h>
33#include <acpi/acpi_drivers.h>
34
35#define _COMPONENT ACPI_PCI_COMPONENT
36ACPI_MODULE_NAME("pci_bind");
37
38static int acpi_pci_unbind(struct acpi_device *device)
39{
40 struct pci_dev *dev;
41
42 dev = acpi_get_pci_dev(device->handle);
43 if (!dev)
44 goto out;
45
46 device_set_run_wake(&dev->dev, false);
47 pci_acpi_remove_pm_notifier(device);
48 acpi_power_resource_unregister_device(&dev->dev, device->handle);
49
50 if (!dev->subordinate)
51 goto out;
52
53 acpi_pci_irq_del_prt(pci_domain_nr(dev->bus), dev->subordinate->number);
54
55 device->ops.bind = NULL;
56 device->ops.unbind = NULL;
57
58out:
59 pci_dev_put(dev);
60 return 0;
61}
62
63static int acpi_pci_bind(struct acpi_device *device)
64{
65 acpi_status status;
66 acpi_handle handle;
67 unsigned char bus;
68 struct pci_dev *dev;
69
70 dev = acpi_get_pci_dev(device->handle);
71 if (!dev)
72 return 0;
73
74 pci_acpi_add_pm_notifier(device, dev);
75 acpi_power_resource_register_device(&dev->dev, device->handle);
76 if (device->wakeup.flags.run_wake)
77 device_set_run_wake(&dev->dev, true);
78
79 /*
80 * Install the 'bind' function to facilitate callbacks for
81 * children of the P2P bridge.
82 */
83 if (dev->subordinate) {
84 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
85 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
86 pci_domain_nr(dev->bus), dev->bus->number,
87 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));
88 device->ops.bind = acpi_pci_bind;
89 device->ops.unbind = acpi_pci_unbind;
90 }
91
92 /*
93 * Evaluate and parse _PRT, if exists. This code allows parsing of
94 * _PRT objects within the scope of non-bridge devices. Note that
95 * _PRTs within the scope of a PCI bridge assume the bridge's
96 * subordinate bus number.
97 *
98 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
99 */
100 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
101 if (ACPI_FAILURE(status))
102 goto out;
103
104 if (dev->subordinate)
105 bus = dev->subordinate->number;
106 else
107 bus = dev->bus->number;
108
109 acpi_pci_irq_add_prt(device->handle, pci_domain_nr(dev->bus), bus);
110
111out:
112 pci_dev_put(dev);
113 return 0;
114}
115
116int acpi_pci_bind_root(struct acpi_device *device)
117{
118 device->ops.bind = acpi_pci_bind;
119 device->ops.unbind = acpi_pci_unbind;
120
121 return 0;
122}
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 7928d4dc7056..22a8458b4ec9 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -47,7 +47,6 @@ ACPI_MODULE_NAME("pci_root");
47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 47#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
48static int acpi_pci_root_add(struct acpi_device *device); 48static int acpi_pci_root_add(struct acpi_device *device);
49static int acpi_pci_root_remove(struct acpi_device *device, int type); 49static int acpi_pci_root_remove(struct acpi_device *device, int type);
50static int acpi_pci_root_start(struct acpi_device *device);
51 50
52#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 51#define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \
53 | OSC_ACTIVE_STATE_PWR_SUPPORT \ 52 | OSC_ACTIVE_STATE_PWR_SUPPORT \
@@ -67,7 +66,6 @@ static struct acpi_driver acpi_pci_root_driver = {
67 .ops = { 66 .ops = {
68 .add = acpi_pci_root_add, 67 .add = acpi_pci_root_add,
69 .remove = acpi_pci_root_remove, 68 .remove = acpi_pci_root_remove,
70 .start = acpi_pci_root_start,
71 }, 69 },
72}; 70};
73 71
@@ -188,21 +186,6 @@ static acpi_status try_get_root_bridge_busnr(acpi_handle handle,
188 return AE_OK; 186 return AE_OK;
189} 187}
190 188
191static void acpi_pci_bridge_scan(struct acpi_device *device)
192{
193 int status;
194 struct acpi_device *child = NULL;
195
196 if (device->flags.bus_address)
197 if (device->parent && device->parent->ops.bind) {
198 status = device->parent->ops.bind(device);
199 if (!status) {
200 list_for_each_entry(child, &device->children, node)
201 acpi_pci_bridge_scan(child);
202 }
203 }
204}
205
206static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; 189static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
207 190
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 191static acpi_status acpi_pci_run_osc(acpi_handle handle,
@@ -452,7 +435,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
452 int result; 435 int result;
453 struct acpi_pci_root *root; 436 struct acpi_pci_root *root;
454 acpi_handle handle; 437 acpi_handle handle;
455 struct acpi_device *child; 438 struct acpi_pci_driver *driver;
456 u32 flags, base_flags; 439 u32 flags, base_flags;
457 bool is_osc_granted = false; 440 bool is_osc_granted = false;
458 441
@@ -603,21 +586,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
603 goto out_del_root; 586 goto out_del_root;
604 } 587 }
605 588
606 /*
607 * Attach ACPI-PCI Context
608 * -----------------------
609 * Thus binding the ACPI and PCI devices.
610 */
611 result = acpi_pci_bind_root(device);
612 if (result)
613 goto out_del_root;
614
615 /*
616 * Scan and bind all _ADR-Based Devices
617 */
618 list_for_each_entry(child, &device->children, node)
619 acpi_pci_bridge_scan(child);
620
621 /* ASPM setting */ 589 /* ASPM setting */
622 if (is_osc_granted) { 590 if (is_osc_granted) {
623 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) 591 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM)
@@ -632,24 +600,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
632 if (device->wakeup.flags.run_wake) 600 if (device->wakeup.flags.run_wake)
633 device_set_run_wake(root->bus->bridge, true); 601 device_set_run_wake(root->bus->bridge, true);
634 602
635 return 0;
636
637out_del_root:
638 mutex_lock(&acpi_pci_root_lock);
639 list_del(&root->node);
640 mutex_unlock(&acpi_pci_root_lock);
641
642 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
643end:
644 kfree(root);
645 return result;
646}
647
648static int acpi_pci_root_start(struct acpi_device *device)
649{
650 struct acpi_pci_root *root = acpi_driver_data(device);
651 struct acpi_pci_driver *driver;
652
653 if (system_state != SYSTEM_BOOTING) 603 if (system_state != SYSTEM_BOOTING)
654 pci_assign_unassigned_bus_resources(root->bus); 604 pci_assign_unassigned_bus_resources(root->bus);
655 605
@@ -664,8 +614,17 @@ static int acpi_pci_root_start(struct acpi_device *device)
664 pci_enable_bridges(root->bus); 614 pci_enable_bridges(root->bus);
665 615
666 pci_bus_add_devices(root->bus); 616 pci_bus_add_devices(root->bus);
667
668 return 0; 617 return 0;
618
619out_del_root:
620 mutex_lock(&acpi_pci_root_lock);
621 list_del(&root->node);
622 mutex_unlock(&acpi_pci_root_lock);
623
624 acpi_pci_irq_del_prt(root->segment, root->secondary.start);
625end:
626 kfree(root);
627 return result;
669} 628}
670 629
671static int acpi_pci_root_remove(struct acpi_device *device, int type) 630static int acpi_pci_root_remove(struct acpi_device *device, int type)
@@ -699,7 +658,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
699 return 0; 658 return 0;
700} 659}
701 660
702static int __init acpi_pci_root_init(void) 661int __init acpi_pci_root_init(void)
703{ 662{
704 acpi_hest_init(); 663 acpi_hest_init();
705 664
@@ -712,5 +671,3 @@ static int __init acpi_pci_root_init(void)
712 671
713 return 0; 672 return 0;
714} 673}
715
716subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e83311bf1ebd..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