Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * pci_root.c - ACPI PCI Root Bridge Driver ($Revision: 40 $) |
| 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/module.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/proc_fs.h> |
| 31 | #include <linux/spinlock.h> |
| 32 | #include <linux/pm.h> |
| 33 | #include <linux/pci.h> |
| 34 | #include <linux/acpi.h> |
| 35 | #include <acpi/acpi_bus.h> |
| 36 | #include <acpi/acpi_drivers.h> |
| 37 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #define _COMPONENT ACPI_PCI_COMPONENT |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 39 | ACPI_MODULE_NAME("pci_root") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #define ACPI_PCI_ROOT_CLASS "pci_bridge" |
| 41 | #define ACPI_PCI_ROOT_HID "PNP0A03" |
| 42 | #define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" |
| 43 | #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 44 | static int acpi_pci_root_add(struct acpi_device *device); |
| 45 | static int acpi_pci_root_remove(struct acpi_device *device, int type); |
| 46 | static int acpi_pci_root_start(struct acpi_device *device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | static struct acpi_driver acpi_pci_root_driver = { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | .name = ACPI_PCI_ROOT_DRIVER_NAME, |
| 50 | .class = ACPI_PCI_ROOT_CLASS, |
| 51 | .ids = ACPI_PCI_ROOT_HID, |
| 52 | .ops = { |
| 53 | .add = acpi_pci_root_add, |
| 54 | .remove = acpi_pci_root_remove, |
| 55 | .start = acpi_pci_root_start, |
| 56 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | struct acpi_pci_root { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 60 | struct list_head node; |
| 61 | acpi_handle handle; |
Patrick Mochel | 32917e5 | 2006-05-19 16:54:39 -0400 | [diff] [blame] | 62 | struct acpi_device * device; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 63 | struct acpi_pci_id id; |
| 64 | struct pci_bus *bus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | static LIST_HEAD(acpi_pci_roots); |
| 68 | |
| 69 | static struct acpi_pci_driver *sub_driver; |
| 70 | |
| 71 | int acpi_pci_register_driver(struct acpi_pci_driver *driver) |
| 72 | { |
| 73 | int n = 0; |
| 74 | struct list_head *entry; |
| 75 | |
| 76 | struct acpi_pci_driver **pptr = &sub_driver; |
| 77 | while (*pptr) |
| 78 | pptr = &(*pptr)->next; |
| 79 | *pptr = driver; |
| 80 | |
| 81 | if (!driver->add) |
| 82 | return 0; |
| 83 | |
| 84 | list_for_each(entry, &acpi_pci_roots) { |
| 85 | struct acpi_pci_root *root; |
| 86 | root = list_entry(entry, struct acpi_pci_root, node); |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 87 | driver->add(root->device->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | n++; |
| 89 | } |
| 90 | |
| 91 | return n; |
| 92 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | EXPORT_SYMBOL(acpi_pci_register_driver); |
| 95 | |
| 96 | void acpi_pci_unregister_driver(struct acpi_pci_driver *driver) |
| 97 | { |
| 98 | struct list_head *entry; |
| 99 | |
| 100 | struct acpi_pci_driver **pptr = &sub_driver; |
| 101 | while (*pptr) { |
| 102 | if (*pptr != driver) |
| 103 | continue; |
| 104 | *pptr = (*pptr)->next; |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | if (!driver->remove) |
| 109 | return; |
| 110 | |
| 111 | list_for_each(entry, &acpi_pci_roots) { |
| 112 | struct acpi_pci_root *root; |
| 113 | root = list_entry(entry, struct acpi_pci_root, node); |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 114 | driver->remove(root->device->handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | EXPORT_SYMBOL(acpi_pci_unregister_driver); |
| 119 | |
| 120 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | get_root_bridge_busnr_callback(struct acpi_resource *resource, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | { |
| 123 | int *busnr = (int *)data; |
| 124 | struct acpi_resource_address64 address; |
| 125 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 126 | if (resource->type != ACPI_RESOURCE_TYPE_ADDRESS16 && |
| 127 | resource->type != ACPI_RESOURCE_TYPE_ADDRESS32 && |
| 128 | resource->type != ACPI_RESOURCE_TYPE_ADDRESS64) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | return AE_OK; |
| 130 | |
| 131 | acpi_resource_to_address64(resource, &address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | if ((address.address_length > 0) && |
| 133 | (address.resource_type == ACPI_BUS_NUMBER_RANGE)) |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 134 | *busnr = address.minimum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | return AE_OK; |
| 137 | } |
| 138 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 139 | static acpi_status try_get_root_bridge_busnr(acpi_handle handle, int *busnum) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
| 141 | acpi_status status; |
| 142 | |
| 143 | *busnum = -1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 144 | status = |
| 145 | acpi_walk_resources(handle, METHOD_NAME__CRS, |
| 146 | get_root_bridge_busnr_callback, busnum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | if (ACPI_FAILURE(status)) |
| 148 | return status; |
| 149 | /* Check if we really get a bus number from _CRS */ |
| 150 | if (*busnum == -1) |
| 151 | return AE_ERROR; |
| 152 | return AE_OK; |
| 153 | } |
| 154 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 155 | static int acpi_pci_root_add(struct acpi_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 157 | int result = 0; |
| 158 | struct acpi_pci_root *root = NULL; |
| 159 | struct acpi_pci_root *tmp; |
| 160 | acpi_status status = AE_OK; |
| 161 | unsigned long value = 0; |
| 162 | acpi_handle handle = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
| 165 | if (!device) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 166 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
| 168 | root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); |
| 169 | if (!root) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 170 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | memset(root, 0, sizeof(struct acpi_pci_root)); |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 172 | INIT_LIST_HEAD(&root->node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | root->handle = device->handle; |
Patrick Mochel | 32917e5 | 2006-05-19 16:54:39 -0400 | [diff] [blame] | 175 | root->device = device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME); |
| 177 | strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); |
| 178 | acpi_driver_data(device) = root; |
| 179 | |
| 180 | /* |
| 181 | * TBD: Doesn't the bus driver automatically set this? |
| 182 | */ |
| 183 | device->ops.bind = acpi_pci_bind; |
| 184 | |
| 185 | /* |
| 186 | * Segment |
| 187 | * ------- |
| 188 | * Obtained via _SEG, if exists, otherwise assumed to be zero (0). |
| 189 | */ |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 190 | status = acpi_evaluate_integer(device->handle, METHOD_NAME__SEG, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 191 | &value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | switch (status) { |
| 193 | case AE_OK: |
| 194 | root->id.segment = (u16) value; |
| 195 | break; |
| 196 | case AE_NOT_FOUND: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 197 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 198 | "Assuming segment 0 (no _SEG)\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | root->id.segment = 0; |
| 200 | break; |
| 201 | default: |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 202 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | result = -ENODEV; |
| 204 | goto end; |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * Bus |
| 209 | * --- |
| 210 | * Obtained via _BBN, if exists, otherwise assumed to be zero (0). |
| 211 | */ |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 212 | status = acpi_evaluate_integer(device->handle, METHOD_NAME__BBN, NULL, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | &value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | switch (status) { |
| 215 | case AE_OK: |
| 216 | root->id.bus = (u16) value; |
| 217 | break; |
| 218 | case AE_NOT_FOUND: |
| 219 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Assuming bus 0 (no _BBN)\n")); |
| 220 | root->id.bus = 0; |
| 221 | break; |
| 222 | default: |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 223 | ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | result = -ENODEV; |
| 225 | goto end; |
| 226 | } |
| 227 | |
| 228 | /* Some systems have wrong _BBN */ |
| 229 | list_for_each_entry(tmp, &acpi_pci_roots, node) { |
| 230 | if ((tmp->id.segment == root->id.segment) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 231 | && (tmp->id.bus == root->id.bus)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | int bus = 0; |
| 233 | acpi_status status; |
| 234 | |
Len Brown | 6468463 | 2006-06-26 23:41:38 -0400 | [diff] [blame] | 235 | printk(KERN_ERR PREFIX |
Thomas Renninger | a6fc672 | 2006-06-26 23:58:43 -0400 | [diff] [blame] | 236 | "Wrong _BBN value, reboot" |
Len Brown | 6468463 | 2006-06-26 23:41:38 -0400 | [diff] [blame] | 237 | " and use option 'pci=noacpi'\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 239 | status = try_get_root_bridge_busnr(device->handle, &bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | if (ACPI_FAILURE(status)) |
| 241 | break; |
| 242 | if (bus != root->id.bus) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | printk(KERN_INFO PREFIX |
| 244 | "PCI _CRS %d overrides _BBN 0\n", bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | root->id.bus = bus; |
| 246 | } |
| 247 | break; |
| 248 | } |
| 249 | } |
| 250 | /* |
| 251 | * Device & Function |
| 252 | * ----------------- |
| 253 | * Obtained from _ADR (which has already been evaluated for us). |
| 254 | */ |
| 255 | root->id.device = device->pnp.bus_address >> 16; |
| 256 | root->id.function = device->pnp.bus_address & 0xFFFF; |
| 257 | |
| 258 | /* |
| 259 | * TBD: Need PCI interface for enumeration/configuration of roots. |
| 260 | */ |
| 261 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 262 | /* TBD: Locking */ |
| 263 | list_add_tail(&root->node, &acpi_pci_roots); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 265 | printk(KERN_INFO PREFIX "%s [%s] (%04x:%02x)\n", |
| 266 | acpi_device_name(device), acpi_device_bid(device), |
| 267 | root->id.segment, root->id.bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | |
| 269 | /* |
| 270 | * Scan the Root Bridge |
| 271 | * -------------------- |
| 272 | * Must do this prior to any attempt to bind the root device, as the |
| 273 | * PCI namespace does not get created until this call is made (and |
| 274 | * thus the root bridge's pci_dev does not exist). |
| 275 | */ |
| 276 | root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); |
| 277 | if (!root->bus) { |
Len Brown | 6468463 | 2006-06-26 23:41:38 -0400 | [diff] [blame] | 278 | printk(KERN_ERR PREFIX |
| 279 | "Bus %04x:%02x not present in PCI namespace\n", |
| 280 | root->id.segment, root->id.bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | result = -ENODEV; |
| 282 | goto end; |
| 283 | } |
| 284 | |
| 285 | /* |
| 286 | * Attach ACPI-PCI Context |
| 287 | * ----------------------- |
| 288 | * Thus binding the ACPI and PCI devices. |
| 289 | */ |
| 290 | result = acpi_pci_bind_root(device, &root->id, root->bus); |
| 291 | if (result) |
| 292 | goto end; |
| 293 | |
| 294 | /* |
| 295 | * PCI Routing Table |
| 296 | * ----------------- |
| 297 | * Evaluate and parse _PRT, if exists. |
| 298 | */ |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 299 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | if (ACPI_SUCCESS(status)) |
Patrick Mochel | 2d1e0a0 | 2006-05-19 16:54:43 -0400 | [diff] [blame^] | 301 | result = acpi_pci_irq_add_prt(device->handle, root->id.segment, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 302 | root->id.bus); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 304 | end: |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 305 | if (result) { |
| 306 | if (!list_empty(&root->node)) |
| 307 | list_del(&root->node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | kfree(root); |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 309 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 311 | return result; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 314 | static int acpi_pci_root_start(struct acpi_device *device) |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 315 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | struct acpi_pci_root *root; |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 317 | |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 318 | |
| 319 | list_for_each_entry(root, &acpi_pci_roots, node) { |
| 320 | if (root->handle == device->handle) { |
| 321 | pci_bus_add_devices(root->bus); |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 322 | return 0; |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 323 | } |
| 324 | } |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 325 | return -ENODEV; |
Rajesh Shah | c431ada | 2005-04-28 00:25:45 -0700 | [diff] [blame] | 326 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 328 | static int acpi_pci_root_remove(struct acpi_device *device, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 330 | struct acpi_pci_root *root = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | if (!device || !acpi_driver_data(device)) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 334 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 336 | root = (struct acpi_pci_root *)acpi_driver_data(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
| 338 | kfree(root); |
| 339 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 340 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | static int __init acpi_pci_root_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
| 346 | if (acpi_pci_disabled) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 347 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
| 349 | /* DEBUG: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 350 | acpi_dbg_layer = ACPI_PCI_COMPONENT; |
| 351 | acpi_dbg_level = 0xFFFFFFFF; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | */ |
| 353 | |
| 354 | if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 355 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
Patrick Mochel | d550d98 | 2006-06-27 00:41:40 -0400 | [diff] [blame] | 357 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | subsys_initcall(acpi_pci_root_init); |