Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'acpi-scan' into acpi-cleanup

The following commits depend on the 'acpi-scan' material.

+289 -583
+1 -1
drivers/acpi/Makefile
··· 37 37 acpi-y += processor_core.o 38 38 acpi-y += ec.o 39 39 acpi-$(CONFIG_ACPI_DOCK) += dock.o 40 - acpi-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 40 + acpi-y += pci_root.o pci_link.o pci_irq.o 41 41 acpi-y += acpi_platform.o 42 42 acpi-y += power.o 43 43 acpi-y += event.o
+7 -19
drivers/acpi/acpi_memhotplug.c
··· 157 157 acpi_memory_get_device(acpi_handle handle, 158 158 struct acpi_memory_device **mem_device) 159 159 { 160 - acpi_status status; 161 - acpi_handle phandle; 162 160 struct acpi_device *device = NULL; 163 - struct acpi_device *pdevice = NULL; 164 161 int result; 165 - 166 162 167 163 if (!acpi_bus_get_device(handle, &device) && device) 168 164 goto end; 169 - 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 165 183 166 /* 184 167 * Now add the notified device. This creates the acpi_device 185 168 * and invokes .add function 186 169 */ 187 - result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 170 + result = acpi_bus_scan(handle); 188 171 if (result) { 189 172 acpi_handle_warn(handle, "Cannot add acpi bus\n"); 173 + return -EINVAL; 174 + } 175 + result = acpi_bus_get_device(handle, &device); 176 + if (result) { 177 + acpi_handle_warn(handle, "Missing device object\n"); 190 178 return -EINVAL; 191 179 } 192 180 ··· 343 355 break; 344 356 } 345 357 346 - ej_event->handle = handle; 358 + ej_event->device = device; 347 359 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 348 360 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 349 361 (void *)ej_event);
+6 -25
drivers/acpi/container.c
··· 135 135 return status; 136 136 } 137 137 138 - static 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 - 162 138 static void container_notify_cb(acpi_handle handle, u32 type, void *context) 163 139 { 164 140 struct acpi_device *device = NULL; ··· 166 190 if (!ACPI_FAILURE(status) || device) 167 191 break; 168 192 169 - result = container_device_add(&device, handle); 193 + result = acpi_bus_scan(handle); 170 194 if (result) { 171 195 acpi_handle_warn(handle, "Failed to add container\n"); 196 + break; 197 + } 198 + result = acpi_bus_get_device(handle, &device); 199 + if (result) { 200 + acpi_handle_warn(handle, "Missing device object\n"); 172 201 break; 173 202 } 174 203
+1 -1
drivers/acpi/device_pm.c
··· 353 353 * acpi_dev_pm_get_node - Get ACPI device node for the given physical device. 354 354 * @dev: Device to get the ACPI node for. 355 355 */ 356 - static struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 356 + struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 357 357 { 358 358 acpi_handle handle = DEVICE_ACPI_HANDLE(dev); 359 359 struct acpi_device *adev;
+5 -12
drivers/acpi/dock.c
··· 310 310 static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 311 311 { 312 312 struct acpi_device *device; 313 - struct acpi_device *parent_device; 314 - acpi_handle parent; 315 313 int ret; 316 314 317 315 if (acpi_bus_get_device(handle, &device)) { ··· 317 319 * no device created for this object, 318 320 * so we should create one. 319 321 */ 320 - acpi_get_parent(handle, &parent); 321 - if (acpi_bus_get_device(parent, &parent_device)) 322 - parent_device = NULL; 323 - 324 - ret = acpi_bus_add(&device, parent_device, handle, 325 - ACPI_BUS_TYPE_DEVICE); 326 - if (ret) { 322 + ret = acpi_bus_scan(handle); 323 + if (ret) 327 324 pr_debug("error adding bus, %x\n", -ret); 328 - return NULL; 329 - } 325 + 326 + acpi_bus_get_device(handle, &device); 330 327 } 331 328 return device; 332 329 } ··· 339 346 int ret; 340 347 341 348 if (!acpi_bus_get_device(handle, &device)) { 342 - ret = acpi_bus_trim(device, 1); 349 + ret = acpi_bus_trim(device); 343 350 if (ret) 344 351 pr_debug("error removing bus, %x\n", -ret); 345 352 }
+35 -15
drivers/acpi/glue.c
··· 68 68 { 69 69 struct acpi_bus_type *tmp, *ret = NULL; 70 70 71 + if (!type) 72 + return NULL; 73 + 71 74 down_read(&bus_type_sem); 72 75 list_for_each_entry(tmp, &bus_type_list, list) { 73 76 if (tmp->bus == type) { ··· 272 269 { 273 270 struct acpi_bus_type *type; 274 271 acpi_handle handle; 275 - int ret = -EINVAL; 272 + int ret; 276 273 277 274 ret = acpi_bind_one(dev, NULL); 278 - if (!ret) 279 - goto out; 280 - 281 - if (!dev->bus || !dev->parent) { 275 + if (ret && (!dev->bus || !dev->parent)) { 282 276 /* bridge devices genernally haven't bus or parent */ 283 277 ret = acpi_find_bridge_device(dev, &handle); 284 - goto end; 278 + if (!ret) { 279 + ret = acpi_bind_one(dev, handle); 280 + if (ret) 281 + goto out; 282 + } 285 283 } 284 + 286 285 type = acpi_get_bus_type(dev->bus); 287 - if (!type) { 288 - DBG("No ACPI bus support for %s\n", dev_name(dev)); 289 - ret = -EINVAL; 290 - goto end; 286 + if (ret) { 287 + if (!type || !type->find_device) { 288 + DBG("No ACPI bus support for %s\n", dev_name(dev)); 289 + ret = -EINVAL; 290 + goto out; 291 + } 292 + 293 + ret = type->find_device(dev, &handle); 294 + if (ret) { 295 + DBG("Unable to get handle for %s\n", dev_name(dev)); 296 + goto out; 297 + } 298 + ret = acpi_bind_one(dev, handle); 299 + if (ret) 300 + goto out; 291 301 } 292 - if ((ret = type->find_device(dev, &handle)) != 0) 293 - DBG("Can't get handler for %s\n", dev_name(dev)); 294 - end: 295 - if (!ret) 296 - acpi_bind_one(dev, handle); 302 + 303 + if (type && type->setup) 304 + type->setup(dev); 297 305 298 306 out: 299 307 #if ACPI_GLUE_DEBUG ··· 323 309 324 310 static int acpi_platform_notify_remove(struct device *dev) 325 311 { 312 + struct acpi_bus_type *type; 313 + 314 + type = acpi_get_bus_type(dev->bus); 315 + if (type && type->cleanup) 316 + type->cleanup(dev); 317 + 326 318 acpi_unbind_one(dev); 327 319 return 0; 328 320 }
+1
drivers/acpi/internal.h
··· 67 67 68 68 extern struct acpi_ec *first_ec; 69 69 70 + int acpi_pci_root_init(void); 70 71 int acpi_ec_init(void); 71 72 int acpi_ec_ecdt_probe(void); 72 73 int acpi_boot_ec_enable(void);
-122
drivers/acpi/pci_bind.c
··· 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 36 - ACPI_MODULE_NAME("pci_bind"); 37 - 38 - static 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 - 58 - out: 59 - pci_dev_put(dev); 60 - return 0; 61 - } 62 - 63 - static 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 - 111 - out: 112 - pci_dev_put(dev); 113 - return 0; 114 - } 115 - 116 - int 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 - }
+12 -55
drivers/acpi/pci_root.c
··· 47 47 #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 48 48 static int acpi_pci_root_add(struct acpi_device *device); 49 49 static int acpi_pci_root_remove(struct acpi_device *device, int type); 50 - static int acpi_pci_root_start(struct acpi_device *device); 51 50 52 51 #define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \ 53 52 | OSC_ACTIVE_STATE_PWR_SUPPORT \ ··· 66 67 .ops = { 67 68 .add = acpi_pci_root_add, 68 69 .remove = acpi_pci_root_remove, 69 - .start = acpi_pci_root_start, 70 70 }, 71 71 }; 72 72 ··· 184 186 if (res->start == -1) 185 187 return AE_ERROR; 186 188 return AE_OK; 187 - } 188 - 189 - static void acpi_pci_bridge_scan(struct acpi_device *device) 190 - { 191 - int status; 192 - struct acpi_device *child = NULL; 193 - 194 - if (device->flags.bus_address) 195 - if (device->parent && device->parent->ops.bind) { 196 - status = device->parent->ops.bind(device); 197 - if (!status) { 198 - list_for_each_entry(child, &device->children, node) 199 - acpi_pci_bridge_scan(child); 200 - } 201 - } 202 189 } 203 190 204 191 static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; ··· 435 452 int result; 436 453 struct acpi_pci_root *root; 437 454 acpi_handle handle; 438 - struct acpi_device *child; 455 + struct acpi_pci_driver *driver; 439 456 u32 flags, base_flags; 440 457 bool is_osc_granted = false; 441 458 ··· 586 603 goto out_del_root; 587 604 } 588 605 589 - /* 590 - * Attach ACPI-PCI Context 591 - * ----------------------- 592 - * Thus binding the ACPI and PCI devices. 593 - */ 594 - result = acpi_pci_bind_root(device); 595 - if (result) 596 - goto out_del_root; 597 - 598 - /* 599 - * Scan and bind all _ADR-Based Devices 600 - */ 601 - list_for_each_entry(child, &device->children, node) 602 - acpi_pci_bridge_scan(child); 603 - 604 606 /* ASPM setting */ 605 607 if (is_osc_granted) { 606 608 if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) ··· 599 631 pci_acpi_add_bus_pm_notifier(device, root->bus); 600 632 if (device->wakeup.flags.run_wake) 601 633 device_set_run_wake(root->bus->bridge, true); 602 - 603 - return 0; 604 - 605 - out_del_root: 606 - mutex_lock(&acpi_pci_root_lock); 607 - list_del(&root->node); 608 - mutex_unlock(&acpi_pci_root_lock); 609 - 610 - acpi_pci_irq_del_prt(root->segment, root->secondary.start); 611 - end: 612 - kfree(root); 613 - return result; 614 - } 615 - 616 - static int acpi_pci_root_start(struct acpi_device *device) 617 - { 618 - struct acpi_pci_root *root = acpi_driver_data(device); 619 - struct acpi_pci_driver *driver; 620 634 621 635 if (system_state != SYSTEM_BOOTING) 622 636 pci_assign_unassigned_bus_resources(root->bus); ··· 614 664 pci_enable_bridges(root->bus); 615 665 616 666 pci_bus_add_devices(root->bus); 617 - 618 667 return 0; 668 + 669 + out_del_root: 670 + mutex_lock(&acpi_pci_root_lock); 671 + list_del(&root->node); 672 + mutex_unlock(&acpi_pci_root_lock); 673 + 674 + acpi_pci_irq_del_prt(root->segment, root->secondary.start); 675 + end: 676 + kfree(root); 677 + return result; 619 678 } 620 679 621 680 static int acpi_pci_root_remove(struct acpi_device *device, int type) ··· 658 699 return 0; 659 700 } 660 701 661 - static int __init acpi_pci_root_init(void) 702 + int __init acpi_pci_root_init(void) 662 703 { 663 704 acpi_hest_init(); 664 705 ··· 671 712 672 713 return 0; 673 714 } 674 - 675 - subsys_initcall(acpi_pci_root_init);
+7 -25
drivers/acpi/processor_driver.c
··· 677 677 return 0; 678 678 } 679 679 680 - static 681 - int 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 - 702 680 static void acpi_processor_hotplug_notify(acpi_handle handle, 703 681 u32 event, void *data) 704 682 { ··· 699 721 if (!acpi_bus_get_device(handle, &device)) 700 722 break; 701 723 702 - result = acpi_processor_device_add(handle, &device); 724 + result = acpi_bus_scan(handle); 703 725 if (result) { 704 726 acpi_handle_err(handle, "Unable to add the device\n"); 705 727 break; 706 728 } 707 - 729 + result = acpi_bus_get_device(handle, &device); 730 + if (result) { 731 + acpi_handle_err(handle, "Missing device object\n"); 732 + break; 733 + } 708 734 ost_code = ACPI_OST_SC_SUCCESS; 709 735 break; 710 736 ··· 733 751 break; 734 752 } 735 753 736 - ej_event->handle = handle; 754 + ej_event->device = device; 737 755 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; 738 756 acpi_os_hotplug_execute(acpi_bus_hot_remove_device, 739 757 (void *)ej_event);
+125 -223
drivers/acpi/scan.c
··· 116 116 void acpi_bus_hot_remove_device(void *context) 117 117 { 118 118 struct acpi_eject_event *ej_event = (struct acpi_eject_event *) context; 119 - struct acpi_device *device; 120 - acpi_handle handle = ej_event->handle; 119 + struct acpi_device *device = ej_event->device; 120 + acpi_handle handle = device->handle; 121 121 acpi_handle temp; 122 122 struct acpi_object_list arg_list; 123 123 union acpi_object arg; 124 124 acpi_status status = AE_OK; 125 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 127 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 134 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 131 printk(KERN_ERR PREFIX 138 132 "Removing device failed\n"); 139 133 goto err_out; ··· 209 215 goto err; 210 216 } 211 217 212 - ej_event->handle = acpi_device->handle; 218 + ej_event->device = acpi_device; 213 219 if (acpi_device->flags.eject_pending) { 214 220 /* event originated from ACPI eject notification */ 215 221 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST; ··· 217 223 } else { 218 224 /* event originated from user */ 219 225 ej_event->event = ACPI_OST_EC_OSPM_EJECT; 220 - (void) acpi_evaluate_hotplug_ost(ej_event->handle, 226 + (void) acpi_evaluate_hotplug_ost(acpi_device->handle, 221 227 ej_event->event, ACPI_OST_SC_EJECT_IN_PROGRESS, NULL); 222 228 } 223 229 ··· 488 494 struct acpi_device *acpi_dev = to_acpi_device(dev); 489 495 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 490 496 491 - 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); 492 499 } 493 500 494 501 static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) ··· 565 570 } 566 571 567 572 static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *); 568 - static int acpi_start_single_object(struct acpi_device *); 569 573 static int acpi_device_probe(struct device * dev) 570 574 { 571 575 struct acpi_device *acpi_dev = to_acpi_device(dev); ··· 573 579 574 580 ret = acpi_bus_driver_init(acpi_dev, acpi_drv); 575 581 if (!ret) { 576 - if (acpi_dev->bus_ops.acpi_op_start) 577 - acpi_start_single_object(acpi_dev); 578 - 579 582 if (acpi_drv->ops.notify) { 580 583 ret = acpi_device_install_notify_handler(acpi_dev); 581 584 if (ret) { ··· 695 704 return result; 696 705 } 697 706 698 - static void acpi_device_unregister(struct acpi_device *device, int type) 707 + static void acpi_device_unregister(struct acpi_device *device) 699 708 { 700 709 mutex_lock(&acpi_device_lock); 701 710 if (device->parent) ··· 749 758 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 750 759 "Driver successfully bound to device\n")); 751 760 return 0; 752 - } 753 - 754 - static int acpi_start_single_object(struct acpi_device *device) 755 - { 756 - int result = 0; 757 - struct acpi_driver *driver; 758 - 759 - 760 - if (!(driver = device->driver)) 761 - return 0; 762 - 763 - if (driver->ops.start) { 764 - result = driver->ops.start(device); 765 - if (result && driver->ops.remove) 766 - driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); 767 - } 768 - 769 - return result; 770 761 } 771 762 772 763 /** ··· 1368 1395 return -ENODEV; 1369 1396 } 1370 1397 1371 - static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) 1372 - { 1373 - if (!dev) 1374 - return -EINVAL; 1375 - 1376 - dev->removal_type = ACPI_BUS_REMOVAL_EJECT; 1377 - device_release_driver(&dev->dev); 1378 - 1379 - if (!rmdevice) 1380 - return 0; 1381 - 1382 - /* 1383 - * unbind _ADR-Based Devices when hot removal 1384 - */ 1385 - if (dev->flags.bus_address) { 1386 - if ((dev->parent) && (dev->parent->ops.unbind)) 1387 - dev->parent->ops.unbind(dev); 1388 - } 1389 - acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 1390 - 1391 - return 0; 1392 - } 1393 - 1394 1398 static int acpi_add_single_object(struct acpi_device **child, 1395 1399 acpi_handle handle, int type, 1396 - unsigned long long sta, 1397 - struct acpi_bus_ops *ops) 1400 + unsigned long long sta, bool match_driver) 1398 1401 { 1399 1402 int result; 1400 1403 struct acpi_device *device; ··· 1386 1437 device->device_type = type; 1387 1438 device->handle = handle; 1388 1439 device->parent = acpi_bus_get_parent(handle); 1389 - device->bus_ops = *ops; /* workround for not call .start */ 1390 1440 STRUCT_TO_INT(device->status) = sta; 1391 1441 1392 1442 acpi_device_get_busid(device); ··· 1436 1488 if ((result = acpi_device_set_context(device))) 1437 1489 goto end; 1438 1490 1491 + device->flags.match_driver = match_driver; 1439 1492 result = acpi_device_register(device); 1440 - 1441 - /* 1442 - * Bind _ADR-Based Devices when hot add 1443 - */ 1444 - if (device->flags.bus_address) { 1445 - if (device->parent && device->parent->ops.bind) 1446 - device->parent->ops.bind(device); 1447 - } 1448 1493 1449 1494 end: 1450 1495 if (!result) { ··· 1460 1519 1461 1520 static void acpi_bus_add_power_resource(acpi_handle handle) 1462 1521 { 1463 - struct acpi_bus_ops ops = { 1464 - .acpi_op_add = 1, 1465 - .acpi_op_start = 1, 1466 - }; 1467 1522 struct acpi_device *device = NULL; 1468 1523 1469 1524 acpi_bus_get_device(handle, &device); 1470 1525 if (!device) 1471 1526 acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER, 1472 - ACPI_STA_DEFAULT, &ops); 1527 + ACPI_STA_DEFAULT, true); 1473 1528 } 1474 1529 1475 1530 static int acpi_bus_type_and_status(acpi_handle handle, int *type, ··· 1507 1570 return 0; 1508 1571 } 1509 1572 1510 - static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl, 1511 - void *context, void **return_value) 1573 + static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used, 1574 + void *not_used, void **return_value) 1512 1575 { 1513 - struct acpi_bus_ops *ops = context; 1576 + struct acpi_device *device = NULL; 1514 1577 int type; 1515 1578 unsigned long long sta; 1516 - struct acpi_device *device; 1517 1579 acpi_status status; 1518 1580 int result; 1581 + 1582 + acpi_bus_get_device(handle, &device); 1583 + if (device) 1584 + goto out; 1519 1585 1520 1586 result = acpi_bus_type_and_status(handle, &type, &sta); 1521 1587 if (result) ··· 1536 1596 return AE_CTRL_DEPTH; 1537 1597 } 1538 1598 1539 - /* 1540 - * We may already have an acpi_device from a previous enumeration. If 1541 - * so, we needn't add it again, but we may still have to start it. 1542 - */ 1543 - device = NULL; 1544 - acpi_bus_get_device(handle, &device); 1545 - if (ops->acpi_op_add && !device) { 1546 - acpi_add_single_object(&device, handle, type, sta, ops); 1547 - /* Is the device a known good platform device? */ 1548 - if (device 1549 - && !acpi_match_device_ids(device, acpi_platform_device_ids)) 1550 - acpi_create_platform_device(device); 1551 - } 1552 - 1599 + acpi_add_single_object(&device, handle, type, sta, 1600 + type == ACPI_BUS_TYPE_POWER); 1553 1601 if (!device) 1554 1602 return AE_CTRL_DEPTH; 1555 1603 1556 - if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1557 - status = acpi_start_single_object(device); 1558 - if (ACPI_FAILURE(status)) 1559 - return AE_CTRL_DEPTH; 1560 - } 1604 + device->flags.match_driver = true; 1561 1605 1606 + out: 1562 1607 if (!*return_value) 1563 1608 *return_value = device; 1609 + 1564 1610 return AE_OK; 1565 1611 } 1566 1612 1567 - static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops, 1568 - struct acpi_device **child) 1613 + static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used, 1614 + void *not_used, void **ret_not_used) 1569 1615 { 1570 - acpi_status status; 1616 + acpi_status status = AE_OK; 1617 + struct acpi_device *device; 1618 + unsigned long long sta_not_used; 1619 + int type_not_used; 1620 + 1621 + /* 1622 + * Ignore errors ignored by acpi_bus_check_add() to avoid terminating 1623 + * namespace walks prematurely. 1624 + */ 1625 + if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used)) 1626 + return AE_OK; 1627 + 1628 + if (acpi_bus_get_device(handle, &device)) 1629 + return AE_CTRL_DEPTH; 1630 + 1631 + if (!acpi_match_device_ids(device, acpi_platform_device_ids)) { 1632 + /* This is a known good platform device. */ 1633 + acpi_create_platform_device(device); 1634 + } else if (device_attach(&device->dev) < 0) { 1635 + status = AE_CTRL_DEPTH; 1636 + } 1637 + return status; 1638 + } 1639 + 1640 + /** 1641 + * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. 1642 + * @handle: Root of the namespace scope to scan. 1643 + * 1644 + * Scan a given ACPI tree (probably recently hot-plugged) and create and add 1645 + * found devices. 1646 + * 1647 + * If no devices were found, -ENODEV is returned, but it does not mean that 1648 + * there has been a real error. There just have been no suitable ACPI objects 1649 + * in the table trunk from which the kernel could create a device and add an 1650 + * appropriate driver. 1651 + */ 1652 + int acpi_bus_scan(acpi_handle handle) 1653 + { 1571 1654 void *device = NULL; 1572 1655 1573 - status = acpi_bus_check_add(handle, 0, ops, &device); 1574 - if (ACPI_SUCCESS(status)) 1656 + if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device))) 1575 1657 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1576 - acpi_bus_check_add, NULL, ops, &device); 1577 - 1578 - if (child) 1579 - *child = device; 1580 - 1581 - if (device) 1582 - return 0; 1583 - else 1584 - return -ENODEV; 1585 - } 1586 - 1587 - /* 1588 - * acpi_bus_add and acpi_bus_start 1589 - * 1590 - * scan a given ACPI tree and (probably recently hot-plugged) 1591 - * create and add or starts found devices. 1592 - * 1593 - * If no devices were found -ENODEV is returned which does not 1594 - * mean that this is a real error, there just have been no suitable 1595 - * ACPI objects in the table trunk from which the kernel could create 1596 - * a device and add/start an appropriate driver. 1597 - */ 1598 - 1599 - int 1600 - acpi_bus_add(struct acpi_device **child, 1601 - struct acpi_device *parent, acpi_handle handle, int type) 1602 - { 1603 - struct acpi_bus_ops ops; 1604 - 1605 - memset(&ops, 0, sizeof(ops)); 1606 - ops.acpi_op_add = 1; 1607 - 1608 - return acpi_bus_scan(handle, &ops, child); 1609 - } 1610 - EXPORT_SYMBOL(acpi_bus_add); 1611 - 1612 - int acpi_bus_start(struct acpi_device *device) 1613 - { 1614 - struct acpi_bus_ops ops; 1615 - int result; 1658 + acpi_bus_check_add, NULL, NULL, &device); 1616 1659 1617 1660 if (!device) 1618 - return -EINVAL; 1661 + return -ENODEV; 1619 1662 1620 - memset(&ops, 0, sizeof(ops)); 1621 - ops.acpi_op_start = 1; 1663 + if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL))) 1664 + acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 1665 + acpi_bus_device_attach, NULL, NULL, NULL); 1622 1666 1623 - result = acpi_bus_scan(device->handle, &ops, NULL); 1624 - 1625 - acpi_update_all_gpes(); 1626 - 1627 - return result; 1667 + return 0; 1628 1668 } 1629 - EXPORT_SYMBOL(acpi_bus_start); 1669 + EXPORT_SYMBOL(acpi_bus_scan); 1630 1670 1631 - int acpi_bus_trim(struct acpi_device *start, int rmdevice) 1671 + static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used, 1672 + void *not_used, void **ret_not_used) 1632 1673 { 1633 - acpi_status status; 1634 - struct acpi_device *parent, *child; 1635 - acpi_handle phandle, chandle; 1636 - acpi_object_type type; 1637 - u32 level = 1; 1638 - int err = 0; 1674 + struct acpi_device *device = NULL; 1639 1675 1640 - parent = start; 1641 - phandle = start->handle; 1642 - child = chandle = NULL; 1643 - 1644 - while ((level > 0) && parent && (!err)) { 1645 - status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1646 - chandle, &chandle); 1647 - 1648 - /* 1649 - * If this scope is exhausted then move our way back up. 1650 - */ 1651 - if (ACPI_FAILURE(status)) { 1652 - level--; 1653 - chandle = phandle; 1654 - acpi_get_parent(phandle, &phandle); 1655 - child = parent; 1656 - parent = parent->parent; 1657 - 1658 - if (level == 0) 1659 - err = acpi_bus_remove(child, rmdevice); 1660 - else 1661 - err = acpi_bus_remove(child, 1); 1662 - 1663 - continue; 1664 - } 1665 - 1666 - status = acpi_get_type(chandle, &type); 1667 - if (ACPI_FAILURE(status)) { 1668 - continue; 1669 - } 1670 - /* 1671 - * If there is a device corresponding to chandle then 1672 - * parse it (depth-first). 1673 - */ 1674 - if (acpi_bus_get_device(chandle, &child) == 0) { 1675 - level++; 1676 - phandle = chandle; 1677 - chandle = NULL; 1678 - parent = child; 1679 - } 1680 - continue; 1676 + if (!acpi_bus_get_device(handle, &device)) { 1677 + device->removal_type = ACPI_BUS_REMOVAL_EJECT; 1678 + device_release_driver(&device->dev); 1681 1679 } 1682 - return err; 1680 + return AE_OK; 1681 + } 1682 + 1683 + static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used, 1684 + void *not_used, void **ret_not_used) 1685 + { 1686 + struct acpi_device *device = NULL; 1687 + 1688 + if (!acpi_bus_get_device(handle, &device)) 1689 + acpi_device_unregister(device); 1690 + 1691 + return AE_OK; 1692 + } 1693 + 1694 + int acpi_bus_trim(struct acpi_device *start) 1695 + { 1696 + /* 1697 + * Execute acpi_bus_device_detach() as a post-order callback to detach 1698 + * all ACPI drivers from the device nodes being removed. 1699 + */ 1700 + acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, 1701 + acpi_bus_device_detach, NULL, NULL); 1702 + acpi_bus_device_detach(start->handle, 0, NULL, NULL); 1703 + /* 1704 + * Execute acpi_bus_remove() as a post-order callback to remove device 1705 + * nodes in the given namespace scope. 1706 + */ 1707 + acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL, 1708 + acpi_bus_remove, NULL, NULL); 1709 + acpi_bus_remove(start->handle, 0, NULL, NULL); 1710 + return 0; 1683 1711 } 1684 1712 EXPORT_SYMBOL_GPL(acpi_bus_trim); 1685 1713 ··· 1655 1747 { 1656 1748 int result = 0; 1657 1749 struct acpi_device *device = NULL; 1658 - struct acpi_bus_ops ops; 1659 - 1660 - memset(&ops, 0, sizeof(ops)); 1661 - ops.acpi_op_add = 1; 1662 - ops.acpi_op_start = 1; 1663 1750 1664 1751 /* 1665 1752 * Enumerate all fixed-feature devices. ··· 1662 1759 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1663 1760 result = acpi_add_single_object(&device, NULL, 1664 1761 ACPI_BUS_TYPE_POWER_BUTTON, 1665 - ACPI_STA_DEFAULT, 1666 - &ops); 1762 + ACPI_STA_DEFAULT, true); 1667 1763 device_init_wakeup(&device->dev, true); 1668 1764 } 1669 1765 1670 1766 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1671 1767 result = acpi_add_single_object(&device, NULL, 1672 1768 ACPI_BUS_TYPE_SLEEP_BUTTON, 1673 - ACPI_STA_DEFAULT, 1674 - &ops); 1769 + ACPI_STA_DEFAULT, true); 1675 1770 } 1676 1771 1677 1772 return result; ··· 1678 1777 int __init acpi_scan_init(void) 1679 1778 { 1680 1779 int result; 1681 - struct acpi_bus_ops ops; 1682 - 1683 - memset(&ops, 0, sizeof(ops)); 1684 - ops.acpi_op_add = 1; 1685 - ops.acpi_op_start = 1; 1686 1780 1687 1781 result = bus_register(&acpi_bus_type); 1688 1782 if (result) { ··· 1686 1790 } 1687 1791 1688 1792 acpi_power_init(); 1793 + acpi_pci_root_init(); 1689 1794 1690 1795 /* 1691 1796 * Enumerate devices in the ACPI namespace. 1692 1797 */ 1693 - result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root); 1694 - 1695 - if (!result) 1696 - result = acpi_bus_scan_fixed(); 1697 - 1798 + result = acpi_bus_scan(ACPI_ROOT_OBJECT); 1698 1799 if (result) 1699 - acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1700 - else 1701 - acpi_update_all_gpes(); 1800 + return result; 1702 1801 1703 - return result; 1802 + result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root); 1803 + if (result) 1804 + return result; 1805 + 1806 + result = acpi_bus_scan_fixed(); 1807 + if (result) { 1808 + acpi_device_unregister(acpi_root); 1809 + return result; 1810 + } 1811 + 1812 + acpi_update_all_gpes(); 1813 + return 0; 1704 1814 }
+16 -28
drivers/pci/hotplug/acpiphp_glue.c
··· 734 734 */ 735 735 static int acpiphp_bus_add(struct acpiphp_func *func) 736 736 { 737 - acpi_handle phandle; 738 - struct acpi_device *device, *pdevice; 737 + struct acpi_device *device; 739 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 740 if (!acpi_bus_get_device(func->handle, &device)) { 747 741 dbg("bus exists... trim\n"); 748 742 /* this shouldn't be in here, so remove 749 743 * the bus then re-add it... 750 744 */ 751 - ret_val = acpi_bus_trim(device, 1); 745 + ret_val = acpi_bus_trim(device); 752 746 dbg("acpi_bus_trim return %x\n", ret_val); 753 747 } 754 748 755 - ret_val = acpi_bus_add(&device, pdevice, func->handle, 756 - ACPI_BUS_TYPE_DEVICE); 757 - if (ret_val) { 758 - dbg("error adding bus, %x\n", 759 - -ret_val); 760 - goto acpiphp_bus_add_out; 761 - } 762 - ret_val = acpi_bus_start(device); 749 + ret_val = acpi_bus_scan(func->handle); 750 + if (!ret_val) 751 + ret_val = acpi_bus_get_device(func->handle, &device); 763 752 764 - acpiphp_bus_add_out: 753 + if (ret_val) 754 + dbg("error adding bus, %x\n", -ret_val); 755 + 765 756 return ret_val; 766 757 } 767 758 ··· 772 781 return retval; 773 782 } 774 783 775 - retval = acpi_bus_trim(device, 1); 784 + retval = acpi_bus_trim(device); 776 785 if (retval) 777 786 err("cannot remove from acpi list\n"); 778 787 ··· 1121 1130 1122 1131 static void handle_bridge_insertion(acpi_handle handle, u32 type) 1123 1132 { 1124 - struct acpi_device *device, *pdevice; 1125 - acpi_handle phandle; 1133 + struct acpi_device *device; 1126 1134 1127 1135 if ((type != ACPI_NOTIFY_BUS_CHECK) && 1128 1136 (type != ACPI_NOTIFY_DEVICE_CHECK)) { ··· 1129 1139 return; 1130 1140 } 1131 1141 1132 - acpi_get_parent(handle, &phandle); 1133 - if (acpi_bus_get_device(phandle, &pdevice)) { 1134 - dbg("no parent device, assuming NULL\n"); 1135 - pdevice = NULL; 1136 - } 1137 - if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) { 1142 + if (acpi_bus_scan(handle)) { 1138 1143 err("cannot add bridge to acpi list\n"); 1139 1144 return; 1140 1145 } 1141 - if (!acpiphp_configure_bridge(handle) && 1142 - !acpi_bus_start(device)) 1146 + if (acpi_bus_get_device(handle, &device)) { 1147 + err("ACPI device object missing\n"); 1148 + return; 1149 + } 1150 + if (!acpiphp_configure_bridge(handle)) 1143 1151 add_bridge(handle); 1144 1152 else 1145 1153 err("cannot configure and start bridge\n");
+3 -7
drivers/pci/hotplug/sgi_hotplug.c
··· 412 412 if (SN_ACPI_BASE_SUPPORT() && ssdt) { 413 413 unsigned long long adr; 414 414 struct acpi_device *pdevice; 415 - struct acpi_device *device; 416 415 acpi_handle phandle; 417 416 acpi_handle chandle = NULL; 418 417 acpi_handle rethandle; ··· 447 448 if (ACPI_SUCCESS(ret) && 448 449 (adr>>16) == (slot->device_num + 1)) { 449 450 450 - ret = acpi_bus_add(&device, pdevice, chandle, 451 - ACPI_BUS_TYPE_DEVICE); 451 + ret = acpi_bus_scan(chandle); 452 452 if (ACPI_FAILURE(ret)) { 453 - printk(KERN_ERR "%s: acpi_bus_add " 453 + printk(KERN_ERR "%s: acpi_bus_scan " 454 454 "failed (0x%x) for slot %d " 455 455 "func %d\n", __func__, 456 456 ret, (int)(adr>>16), 457 457 (int)(adr&0xffff)); 458 458 /* try to continue on */ 459 - } else { 460 - acpi_bus_start(device); 461 459 } 462 460 } 463 461 } ··· 535 539 ret = acpi_bus_get_device(chandle, 536 540 &device); 537 541 if (ACPI_SUCCESS(ret)) 538 - acpi_bus_trim(device, 1); 542 + acpi_bus_trim(device); 539 543 } 540 544 } 541 545
+57 -1
drivers/pci/pci-acpi.c
··· 283 283 .is_manageable = acpi_pci_power_manageable, 284 284 .set_state = acpi_pci_set_power_state, 285 285 .choose_state = acpi_pci_choose_state, 286 - .can_wakeup = acpi_pci_can_wakeup, 287 286 .sleep_wake = acpi_pci_sleep_wake, 288 287 .run_wake = acpi_pci_run_wake, 289 288 }; ··· 320 321 return 0; 321 322 } 322 323 324 + static void pci_acpi_setup(struct device *dev) 325 + { 326 + struct pci_dev *pci_dev = to_pci_dev(dev); 327 + acpi_handle handle = ACPI_HANDLE(dev); 328 + struct acpi_device *adev; 329 + acpi_status status; 330 + acpi_handle dummy; 331 + 332 + /* 333 + * Evaluate and parse _PRT, if exists. This code allows parsing of 334 + * _PRT objects within the scope of non-bridge devices. Note that 335 + * _PRTs within the scope of a PCI bridge assume the bridge's 336 + * subordinate bus number. 337 + * 338 + * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? 339 + */ 340 + status = acpi_get_handle(handle, METHOD_NAME__PRT, &dummy); 341 + if (ACPI_SUCCESS(status)) { 342 + unsigned char bus; 343 + 344 + bus = pci_dev->subordinate ? 345 + pci_dev->subordinate->number : pci_dev->bus->number; 346 + acpi_pci_irq_add_prt(handle, pci_domain_nr(pci_dev->bus), bus); 347 + } 348 + 349 + acpi_power_resource_register_device(dev, handle); 350 + if (acpi_bus_get_device(handle, &adev) || !adev->wakeup.flags.valid) 351 + return; 352 + 353 + device_set_wakeup_capable(dev, true); 354 + acpi_pci_sleep_wake(pci_dev, false); 355 + 356 + pci_acpi_add_pm_notifier(adev, pci_dev); 357 + if (adev->wakeup.flags.run_wake) 358 + device_set_run_wake(dev, true); 359 + } 360 + 361 + static void pci_acpi_cleanup(struct device *dev) 362 + { 363 + struct pci_dev *pci_dev = to_pci_dev(dev); 364 + acpi_handle handle = ACPI_HANDLE(dev); 365 + struct acpi_device *adev; 366 + 367 + if (!acpi_bus_get_device(handle, &adev) && adev->wakeup.flags.valid) { 368 + device_set_wakeup_capable(dev, false); 369 + device_set_run_wake(dev, false); 370 + pci_acpi_remove_pm_notifier(adev); 371 + } 372 + acpi_power_resource_unregister_device(dev, handle); 373 + 374 + if (pci_dev->subordinate) 375 + acpi_pci_irq_del_prt(pci_domain_nr(pci_dev->bus), 376 + pci_dev->subordinate->number); 377 + } 378 + 323 379 static struct acpi_bus_type acpi_pci_bus = { 324 380 .bus = &pci_bus_type, 325 381 .find_device = acpi_pci_find_device, 326 382 .find_bridge = acpi_pci_find_root_bridge, 383 + .setup = pci_acpi_setup, 384 + .cleanup = pci_acpi_cleanup, 327 385 }; 328 386 329 387 static int __init acpi_pci_init(void)
+1 -25
drivers/pci/pci.c
··· 450 450 int pci_set_platform_pm(struct pci_platform_pm_ops *ops) 451 451 { 452 452 if (!ops->is_manageable || !ops->set_state || !ops->choose_state 453 - || !ops->sleep_wake || !ops->can_wakeup) 453 + || !ops->sleep_wake) 454 454 return -EINVAL; 455 455 pci_platform_pm = ops; 456 456 return 0; ··· 471 471 { 472 472 return pci_platform_pm ? 473 473 pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR; 474 - } 475 - 476 - static inline bool platform_pci_can_wakeup(struct pci_dev *dev) 477 - { 478 - return pci_platform_pm ? pci_platform_pm->can_wakeup(dev) : false; 479 474 } 480 475 481 476 static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable) ··· 1978 1983 } else { 1979 1984 dev->pme_support = 0; 1980 1985 } 1981 - } 1982 - 1983 - /** 1984 - * platform_pci_wakeup_init - init platform wakeup if present 1985 - * @dev: PCI device 1986 - * 1987 - * Some devices don't have PCI PM caps but can still generate wakeup 1988 - * events through platform methods (like ACPI events). If @dev supports 1989 - * platform wakeup events, set the device flag to indicate as much. This 1990 - * may be redundant if the device also supports PCI PM caps, but double 1991 - * initialization should be safe in that case. 1992 - */ 1993 - void platform_pci_wakeup_init(struct pci_dev *dev) 1994 - { 1995 - if (!platform_pci_can_wakeup(dev)) 1996 - return; 1997 - 1998 - device_set_wakeup_capable(&dev->dev, true); 1999 - platform_pci_sleep_wake(dev, false); 2000 1986 } 2001 1987 2002 1988 static void pci_add_saved_cap(struct pci_dev *pci_dev,
-5
drivers/pci/pci.h
··· 43 43 * platform; to be used during system-wide transitions from a 44 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 46 * @sleep_wake: enables/disables the system wake up capability of given device 50 47 * 51 48 * @run_wake: enables/disables the platform to generate run-time wake-up events ··· 56 59 bool (*is_manageable)(struct pci_dev *dev); 57 60 int (*set_state)(struct pci_dev *dev, pci_power_t state); 58 61 pci_power_t (*choose_state)(struct pci_dev *dev); 59 - bool (*can_wakeup)(struct pci_dev *dev); 60 62 int (*sleep_wake)(struct pci_dev *dev, bool enable); 61 63 int (*run_wake)(struct pci_dev *dev, bool enable); 62 64 }; ··· 70 74 extern void pci_config_pm_runtime_get(struct pci_dev *dev); 71 75 extern void pci_config_pm_runtime_put(struct pci_dev *dev); 72 76 extern void pci_pm_init(struct pci_dev *dev); 73 - extern void platform_pci_wakeup_init(struct pci_dev *dev); 74 77 extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 75 78 void pci_free_cap_save_buffers(struct pci_dev *dev); 76 79
-1
drivers/pci/probe.c
··· 1280 1280 1281 1281 /* Power Management */ 1282 1282 pci_pm_init(dev); 1283 - platform_pci_wakeup_init(dev); 1284 1283 1285 1284 /* Vital Product Data */ 1286 1285 pci_vpd_pci22_init(dev);
+7 -18
include/acpi/acpi_bus.h
··· 91 91 typedef int (*acpi_op_add) (struct acpi_device * device); 92 92 typedef int (*acpi_op_remove) (struct acpi_device * device, int type); 93 93 typedef int (*acpi_op_start) (struct acpi_device * device); 94 - typedef int (*acpi_op_bind) (struct acpi_device * device); 95 - typedef int (*acpi_op_unbind) (struct acpi_device * device); 96 94 typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event); 97 - 98 - struct acpi_bus_ops { 99 - u32 acpi_op_add:1; 100 - u32 acpi_op_start:1; 101 - }; 102 95 103 96 struct acpi_device_ops { 104 97 acpi_op_add add; 105 98 acpi_op_remove remove; 106 99 acpi_op_start start; 107 - acpi_op_bind bind; 108 - acpi_op_unbind unbind; 109 100 acpi_op_notify notify; 110 101 }; 111 102 ··· 139 148 u32 power_manageable:1; 140 149 u32 performance_manageable:1; 141 150 u32 eject_pending:1; 142 - u32 reserved:24; 151 + u32 match_driver:1; 152 + u32 reserved:23; 143 153 }; 144 154 145 155 /* File System */ ··· 271 279 struct acpi_device_wakeup wakeup; 272 280 struct acpi_device_perf performance; 273 281 struct acpi_device_dir dir; 274 - struct acpi_device_ops ops; 275 282 struct acpi_driver *driver; 276 283 void *driver_data; 277 284 struct device dev; 278 - struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ 279 285 enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ 280 286 u8 physical_node_count; 281 287 struct list_head physical_node_list; ··· 306 316 }; 307 317 308 318 struct acpi_eject_event { 309 - acpi_handle handle; 319 + struct acpi_device *device; 310 320 u32 event; 311 321 }; 312 322 ··· 346 356 #endif 347 357 int acpi_bus_register_driver(struct acpi_driver *driver); 348 358 void acpi_bus_unregister_driver(struct acpi_driver *driver); 349 - int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, 350 - acpi_handle handle, int type); 359 + int acpi_bus_scan(acpi_handle handle); 351 360 void acpi_bus_hot_remove_device(void *context); 352 - int acpi_bus_trim(struct acpi_device *start, int rmdevice); 353 - int acpi_bus_start(struct acpi_device *device); 361 + int acpi_bus_trim(struct acpi_device *start); 354 362 acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 355 363 int acpi_match_device_ids(struct acpi_device *device, 356 364 const struct acpi_device_id *ids); ··· 378 390 int (*find_device) (struct device *, acpi_handle *); 379 391 /* For bridges, such as PCI root bridge, IDE controller */ 380 392 int (*find_bridge) (struct device *, acpi_handle *); 393 + void (*setup)(struct device *); 394 + void (*cleanup)(struct device *); 381 395 }; 382 396 int register_acpi_bus_type(struct acpi_bus_type *); 383 397 int unregister_acpi_bus_type(struct acpi_bus_type *); ··· 387 397 struct acpi_pci_root { 388 398 struct list_head node; 389 399 struct acpi_device * device; 390 - struct acpi_pci_id id; 391 400 struct pci_bus *bus; 392 401 u16 segment; 393 402 struct resource secondary; /* downstream bus range */
+5
include/linux/acpi.h
··· 526 526 #endif 527 527 528 528 #if defined(CONFIG_ACPI) && defined(CONFIG_PM) 529 + struct acpi_device *acpi_dev_pm_get_node(struct device *dev); 529 530 int acpi_dev_pm_attach(struct device *dev, bool power_on); 530 531 void acpi_dev_pm_detach(struct device *dev, bool power_off); 531 532 #else 533 + static inline struct acpi_device *acpi_dev_pm_get_node(struct device *dev) 534 + { 535 + return NULL; 536 + } 532 537 static inline int acpi_dev_pm_attach(struct device *dev, bool power_on) 533 538 { 534 539 return -ENODEV;