aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-13 17:27:25 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-22 22:00:24 -0400
commitbda46dbb6626c923a800b4033c86fefa613cd64c (patch)
tree1c035530c7ce97096b91558c6ce5fd4043cea159
parent89373a55d294b53e85792dbc636015b83d492f67 (diff)
ACPI / hotplug / PCI: Store parent in functions and bus in slots
To avoid chasing more pointers than necessary in some situations, move the bridge pointer from struct acpiphp_slot to struct acpiphp_func (and call it 'parent') and add a bus pointer to struct acpiphp_slot. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r--drivers/pci/hotplug/acpiphp.h5
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c6
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c25
3 files changed, 18 insertions, 18 deletions
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index afd7110a1ca8..7d3251d2f4ad 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -97,7 +97,7 @@ struct acpiphp_bridge {
97 */ 97 */
98struct acpiphp_slot { 98struct acpiphp_slot {
99 struct list_head node; 99 struct list_head node;
100 struct acpiphp_bridge *bridge; /* parent */ 100 struct pci_bus *bus;
101 struct list_head funcs; /* one slot may have different 101 struct list_head funcs; /* one slot may have different
102 objects (i.e. for each function) */ 102 objects (i.e. for each function) */
103 struct slot *slot; 103 struct slot *slot;
@@ -115,7 +115,8 @@ struct acpiphp_slot {
115 * typically 8 objects per slot (i.e. for each PCI function) 115 * typically 8 objects per slot (i.e. for each PCI function)
116 */ 116 */
117struct acpiphp_func { 117struct acpiphp_func {
118 struct acpiphp_slot *slot; /* parent */ 118 struct acpiphp_bridge *parent;
119 struct acpiphp_slot *slot;
119 120
120 struct list_head sibling; 121 struct list_head sibling;
121 122
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 1798740f7e18..8f20e6021611 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -321,10 +321,8 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot,
321 slot->sun = sun; 321 slot->sun = sun;
322 snprintf(name, SLOT_NAME_SIZE, "%u", sun); 322 snprintf(name, SLOT_NAME_SIZE, "%u", sun);
323 323
324 retval = pci_hp_register(slot->hotplug_slot, 324 retval = pci_hp_register(slot->hotplug_slot, acpiphp_slot->bus,
325 acpiphp_slot->bridge->pci_bus, 325 acpiphp_slot->device, name);
326 acpiphp_slot->device,
327 name);
328 if (retval == -EBUSY) 326 if (retval == -EBUSY)
329 goto error_hpslot; 327 goto error_hpslot;
330 if (retval) { 328 if (retval) {
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index bbbf8f4e8482..7ac315afa430 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -165,7 +165,7 @@ static void free_bridge(struct kref *kref)
165 /* Root bridges will not have hotplug context. */ 165 /* Root bridges will not have hotplug context. */
166 if (context) { 166 if (context) {
167 /* Release the reference taken by acpiphp_enumerate_slots(). */ 167 /* Release the reference taken by acpiphp_enumerate_slots(). */
168 put_bridge(context->func.slot->bridge); 168 put_bridge(context->func.parent);
169 context->bridge = NULL; 169 context->bridge = NULL;
170 acpiphp_put_context(context); 170 acpiphp_put_context(context);
171 } 171 }
@@ -187,7 +187,7 @@ static void free_bridge(struct kref *kref)
187static void post_dock_fixups(acpi_handle not_used, u32 event, void *data) 187static void post_dock_fixups(acpi_handle not_used, u32 event, void *data)
188{ 188{
189 struct acpiphp_context *context = data; 189 struct acpiphp_context *context = data;
190 struct pci_bus *bus = context->func.slot->bridge->pci_bus; 190 struct pci_bus *bus = context->func.slot->bus;
191 u32 buses; 191 u32 buses;
192 192
193 if (!bus->self) 193 if (!bus->self)
@@ -248,14 +248,14 @@ static void acpiphp_dock_init(void *data)
248{ 248{
249 struct acpiphp_context *context = data; 249 struct acpiphp_context *context = data;
250 250
251 get_bridge(context->func.slot->bridge); 251 get_bridge(context->func.parent);
252} 252}
253 253
254static void acpiphp_dock_release(void *data) 254static void acpiphp_dock_release(void *data)
255{ 255{
256 struct acpiphp_context *context = data; 256 struct acpiphp_context *context = data;
257 257
258 put_bridge(context->func.slot->bridge); 258 put_bridge(context->func.parent);
259} 259}
260 260
261/* callback routine to register each ACPI PCI slot object */ 261/* callback routine to register each ACPI PCI slot object */
@@ -294,6 +294,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
294 } 294 }
295 newfunc = &context->func; 295 newfunc = &context->func;
296 newfunc->function = function; 296 newfunc->function = function;
297 newfunc->parent = bridge;
297 mutex_unlock(&acpiphp_context_lock); 298 mutex_unlock(&acpiphp_context_lock);
298 299
299 if (acpi_has_method(handle, "_EJ0")) 300 if (acpi_has_method(handle, "_EJ0"))
@@ -322,7 +323,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
322 goto err; 323 goto err;
323 } 324 }
324 325
325 slot->bridge = bridge; 326 slot->bus = bridge->pci_bus;
326 slot->device = device; 327 slot->device = device;
327 INIT_LIST_HEAD(&slot->funcs); 328 INIT_LIST_HEAD(&slot->funcs);
328 mutex_init(&slot->crit_sect); 329 mutex_init(&slot->crit_sect);
@@ -639,7 +640,7 @@ static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
639static int __ref enable_device(struct acpiphp_slot *slot) 640static int __ref enable_device(struct acpiphp_slot *slot)
640{ 641{
641 struct pci_dev *dev; 642 struct pci_dev *dev;
642 struct pci_bus *bus = slot->bridge->pci_bus; 643 struct pci_bus *bus = slot->bus;
643 struct acpiphp_func *func; 644 struct acpiphp_func *func;
644 int num, max, pass; 645 int num, max, pass;
645 LIST_HEAD(add_list); 646 LIST_HEAD(add_list);
@@ -709,7 +710,7 @@ static int __ref enable_device(struct acpiphp_slot *slot)
709/* return first device in slot, acquiring a reference on it */ 710/* return first device in slot, acquiring a reference on it */
710static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot) 711static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
711{ 712{
712 struct pci_bus *bus = slot->bridge->pci_bus; 713 struct pci_bus *bus = slot->bus;
713 struct pci_dev *dev; 714 struct pci_dev *dev;
714 struct pci_dev *ret = NULL; 715 struct pci_dev *ret = NULL;
715 716
@@ -781,7 +782,7 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
781 } else { 782 } else {
782 u32 dvid; 783 u32 dvid;
783 784
784 pci_bus_read_config_dword(slot->bridge->pci_bus, 785 pci_bus_read_config_dword(slot->bus,
785 PCI_DEVFN(slot->device, 786 PCI_DEVFN(slot->device,
786 func->function), 787 func->function),
787 PCI_VENDOR_ID, &dvid); 788 PCI_VENDOR_ID, &dvid);
@@ -970,7 +971,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
970 if (bridge) 971 if (bridge)
971 acpiphp_check_bridge(bridge); 972 acpiphp_check_bridge(bridge);
972 else 973 else
973 acpiphp_check_bridge(func->slot->bridge); 974 acpiphp_check_bridge(func->parent);
974 975
975 break; 976 break;
976 977
@@ -1025,7 +1026,7 @@ static void hotplug_event_work(struct work_struct *work)
1025 1026
1026 acpi_scan_lock_release(); 1027 acpi_scan_lock_release();
1027 kfree(hp_work); /* allocated in handle_hotplug_event() */ 1028 kfree(hp_work); /* allocated in handle_hotplug_event() */
1028 put_bridge(context->func.slot->bridge); 1029 put_bridge(context->func.parent);
1029} 1030}
1030 1031
1031/** 1032/**
@@ -1043,7 +1044,7 @@ static void handle_hotplug_event(acpi_handle handle, u32 type, void *data)
1043 mutex_lock(&acpiphp_context_lock); 1044 mutex_lock(&acpiphp_context_lock);
1044 context = acpiphp_get_context(handle); 1045 context = acpiphp_get_context(handle);
1045 if (context) { 1046 if (context) {
1046 get_bridge(context->func.slot->bridge); 1047 get_bridge(context->func.parent);
1047 acpiphp_put_context(context); 1048 acpiphp_put_context(context);
1048 } 1049 }
1049 mutex_unlock(&acpiphp_context_lock); 1050 mutex_unlock(&acpiphp_context_lock);
@@ -1113,7 +1114,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
1113 bridge->context = context; 1114 bridge->context = context;
1114 context->bridge = bridge; 1115 context->bridge = bridge;
1115 /* Get a reference to the parent bridge. */ 1116 /* Get a reference to the parent bridge. */
1116 get_bridge(context->func.slot->bridge); 1117 get_bridge(context->func.parent);
1117 mutex_unlock(&acpiphp_context_lock); 1118 mutex_unlock(&acpiphp_context_lock);
1118 } 1119 }
1119 1120