aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-12-20 18:36:49 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-03 07:09:40 -0500
commit0cd6ac52b333f66ee64e50ed216ec99231092dcd (patch)
tree6172c3977fe7d5ea3a9c04312ff19c3be28929a6 /drivers/pci/hotplug
parent209d3b1743c8187c67cc75dbe9fefbcd3121fba0 (diff)
ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument
The callers of acpi_bus_add() usually assume that if it has succeeded, then a struct acpi_device object has been attached to the handle passed as the first argument. Unfortunately, however, this assumption is wrong, because acpi_bus_scan(), and acpi_bus_add() too as a result, may return a pointer to a different struct acpi_device object on success (it may be an object corresponding to one of the descendant ACPI nodes in the namespace scope below that handle). For this reason, the callers of acpi_bus_add() who care about whether or not a struct acpi_device object has been created for its first argument need to check that using acpi_bus_get_device() anyway, so the second argument of acpi_bus_add() is not really useful for them. The same observation applies to acpi_bus_scan() executed directly from acpi_scan_init(). Therefore modify the relevant callers of acpi_bus_add() to check the existence of the struct acpi_device in question with the help of acpi_bus_get_device() and drop the no longer necessary second argument of acpi_bus_add(). Accordingly, modify acpi_scan_init() to use acpi_bus_get_device() to get acpi_root and drop the no longer needed second argument of acpi_bus_scan(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Yinghai Lu <yinghai@kernel.org> Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c19
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c3
2 files changed, 12 insertions, 10 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index dfc2df54b93a..91b5ad875c53 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -746,14 +746,13 @@ static int acpiphp_bus_add(struct acpiphp_func *func)
746 dbg("acpi_bus_trim return %x\n", ret_val); 746 dbg("acpi_bus_trim return %x\n", ret_val);
747 } 747 }
748 748
749 ret_val = acpi_bus_add(func->handle, &device); 749 ret_val = acpi_bus_add(func->handle);
750 if (ret_val) { 750 if (!ret_val)
751 dbg("error adding bus, %x\n", 751 ret_val = acpi_bus_get_device(func->handle, &device);
752 -ret_val); 752
753 goto acpiphp_bus_add_out; 753 if (ret_val)
754 } 754 dbg("error adding bus, %x\n", -ret_val);
755 755
756acpiphp_bus_add_out:
757 return ret_val; 756 return ret_val;
758} 757}
759 758
@@ -1130,10 +1129,14 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
1130 return; 1129 return;
1131 } 1130 }
1132 1131
1133 if (acpi_bus_add(handle, &device)) { 1132 if (acpi_bus_add(handle)) {
1134 err("cannot add bridge to acpi list\n"); 1133 err("cannot add bridge to acpi list\n");
1135 return; 1134 return;
1136 } 1135 }
1136 if (acpi_bus_get_device(handle, &device)) {
1137 err("ACPI device object missing\n");
1138 return;
1139 }
1137 if (!acpiphp_configure_bridge(handle)) 1140 if (!acpiphp_configure_bridge(handle))
1138 add_bridge(handle); 1141 add_bridge(handle);
1139 else 1142 else
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 801b58d1f78e..f3c419256d2a 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -412,7 +412,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
412 if (SN_ACPI_BASE_SUPPORT() && ssdt) { 412 if (SN_ACPI_BASE_SUPPORT() && ssdt) {
413 unsigned long long adr; 413 unsigned long long adr;
414 struct acpi_device *pdevice; 414 struct acpi_device *pdevice;
415 struct acpi_device *device;
416 acpi_handle phandle; 415 acpi_handle phandle;
417 acpi_handle chandle = NULL; 416 acpi_handle chandle = NULL;
418 acpi_handle rethandle; 417 acpi_handle rethandle;
@@ -448,7 +447,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
448 if (ACPI_SUCCESS(ret) && 447 if (ACPI_SUCCESS(ret) &&
449 (adr>>16) == (slot->device_num + 1)) { 448 (adr>>16) == (slot->device_num + 1)) {
450 449
451 ret = acpi_bus_add(chandle, &device); 450 ret = acpi_bus_add(chandle);
452 if (ACPI_FAILURE(ret)) { 451 if (ACPI_FAILURE(ret)) {
453 printk(KERN_ERR "%s: acpi_bus_add " 452 printk(KERN_ERR "%s: acpi_bus_add "
454 "failed (0x%x) for slot %d " 453 "failed (0x%x) for slot %d "