Commit bda46dbb authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 89373a55
...@@ -97,7 +97,7 @@ struct acpiphp_bridge { ...@@ -97,7 +97,7 @@ struct acpiphp_bridge {
*/ */
struct acpiphp_slot { struct acpiphp_slot {
struct list_head node; struct list_head node;
struct acpiphp_bridge *bridge; /* parent */ struct pci_bus *bus;
struct list_head funcs; /* one slot may have different struct list_head funcs; /* one slot may have different
objects (i.e. for each function) */ objects (i.e. for each function) */
struct slot *slot; struct slot *slot;
...@@ -115,7 +115,8 @@ struct acpiphp_slot { ...@@ -115,7 +115,8 @@ struct acpiphp_slot {
* typically 8 objects per slot (i.e. for each PCI function) * typically 8 objects per slot (i.e. for each PCI function)
*/ */
struct acpiphp_func { struct acpiphp_func {
struct acpiphp_slot *slot; /* parent */ struct acpiphp_bridge *parent;
struct acpiphp_slot *slot;
struct list_head sibling; struct list_head sibling;
......
...@@ -321,10 +321,8 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot, ...@@ -321,10 +321,8 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot,
slot->sun = sun; slot->sun = sun;
snprintf(name, SLOT_NAME_SIZE, "%u", sun); snprintf(name, SLOT_NAME_SIZE, "%u", sun);
retval = pci_hp_register(slot->hotplug_slot, retval = pci_hp_register(slot->hotplug_slot, acpiphp_slot->bus,
acpiphp_slot->bridge->pci_bus, acpiphp_slot->device, name);
acpiphp_slot->device,
name);
if (retval == -EBUSY) if (retval == -EBUSY)
goto error_hpslot; goto error_hpslot;
if (retval) { if (retval) {
......
...@@ -165,7 +165,7 @@ static void free_bridge(struct kref *kref) ...@@ -165,7 +165,7 @@ static void free_bridge(struct kref *kref)
/* Root bridges will not have hotplug context. */ /* Root bridges will not have hotplug context. */
if (context) { if (context) {
/* Release the reference taken by acpiphp_enumerate_slots(). */ /* Release the reference taken by acpiphp_enumerate_slots(). */
put_bridge(context->func.slot->bridge); put_bridge(context->func.parent);
context->bridge = NULL; context->bridge = NULL;
acpiphp_put_context(context); acpiphp_put_context(context);
} }
...@@ -187,7 +187,7 @@ static void free_bridge(struct kref *kref) ...@@ -187,7 +187,7 @@ static void free_bridge(struct kref *kref)
static void post_dock_fixups(acpi_handle not_used, u32 event, void *data) static void post_dock_fixups(acpi_handle not_used, u32 event, void *data)
{ {
struct acpiphp_context *context = data; struct acpiphp_context *context = data;
struct pci_bus *bus = context->func.slot->bridge->pci_bus; struct pci_bus *bus = context->func.slot->bus;
u32 buses; u32 buses;
if (!bus->self) if (!bus->self)
...@@ -248,14 +248,14 @@ static void acpiphp_dock_init(void *data) ...@@ -248,14 +248,14 @@ static void acpiphp_dock_init(void *data)
{ {
struct acpiphp_context *context = data; struct acpiphp_context *context = data;
get_bridge(context->func.slot->bridge); get_bridge(context->func.parent);
} }
static void acpiphp_dock_release(void *data) static void acpiphp_dock_release(void *data)
{ {
struct acpiphp_context *context = data; struct acpiphp_context *context = data;
put_bridge(context->func.slot->bridge); put_bridge(context->func.parent);
} }
/* callback routine to register each ACPI PCI slot object */ /* 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,6 +294,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
} }
newfunc = &context->func; newfunc = &context->func;
newfunc->function = function; newfunc->function = function;
newfunc->parent = bridge;
mutex_unlock(&acpiphp_context_lock); mutex_unlock(&acpiphp_context_lock);
if (acpi_has_method(handle, "_EJ0")) if (acpi_has_method(handle, "_EJ0"))
...@@ -322,7 +323,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data, ...@@ -322,7 +323,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
goto err; goto err;
} }
slot->bridge = bridge; slot->bus = bridge->pci_bus;
slot->device = device; slot->device = device;
INIT_LIST_HEAD(&slot->funcs); INIT_LIST_HEAD(&slot->funcs);
mutex_init(&slot->crit_sect); mutex_init(&slot->crit_sect);
...@@ -639,7 +640,7 @@ static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev) ...@@ -639,7 +640,7 @@ static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
static int __ref enable_device(struct acpiphp_slot *slot) static int __ref enable_device(struct acpiphp_slot *slot)
{ {
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *bus = slot->bridge->pci_bus; struct pci_bus *bus = slot->bus;
struct acpiphp_func *func; struct acpiphp_func *func;
int num, max, pass; int num, max, pass;
LIST_HEAD(add_list); LIST_HEAD(add_list);
...@@ -709,7 +710,7 @@ static int __ref enable_device(struct acpiphp_slot *slot) ...@@ -709,7 +710,7 @@ static int __ref enable_device(struct acpiphp_slot *slot)
/* return first device in slot, acquiring a reference on it */ /* return first device in slot, acquiring a reference on it */
static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot) static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
{ {
struct pci_bus *bus = slot->bridge->pci_bus; struct pci_bus *bus = slot->bus;
struct pci_dev *dev; struct pci_dev *dev;
struct pci_dev *ret = NULL; struct pci_dev *ret = NULL;
...@@ -781,7 +782,7 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot) ...@@ -781,7 +782,7 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
} else { } else {
u32 dvid; u32 dvid;
pci_bus_read_config_dword(slot->bridge->pci_bus, pci_bus_read_config_dword(slot->bus,
PCI_DEVFN(slot->device, PCI_DEVFN(slot->device,
func->function), func->function),
PCI_VENDOR_ID, &dvid); PCI_VENDOR_ID, &dvid);
...@@ -970,7 +971,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data) ...@@ -970,7 +971,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
if (bridge) if (bridge)
acpiphp_check_bridge(bridge); acpiphp_check_bridge(bridge);
else else
acpiphp_check_bridge(func->slot->bridge); acpiphp_check_bridge(func->parent);
break; break;
...@@ -1025,7 +1026,7 @@ static void hotplug_event_work(struct work_struct *work) ...@@ -1025,7 +1026,7 @@ static void hotplug_event_work(struct work_struct *work)
acpi_scan_lock_release(); acpi_scan_lock_release();
kfree(hp_work); /* allocated in handle_hotplug_event() */ kfree(hp_work); /* allocated in handle_hotplug_event() */
put_bridge(context->func.slot->bridge); put_bridge(context->func.parent);
} }
/** /**
...@@ -1043,7 +1044,7 @@ static void handle_hotplug_event(acpi_handle handle, u32 type, void *data) ...@@ -1043,7 +1044,7 @@ static void handle_hotplug_event(acpi_handle handle, u32 type, void *data)
mutex_lock(&acpiphp_context_lock); mutex_lock(&acpiphp_context_lock);
context = acpiphp_get_context(handle); context = acpiphp_get_context(handle);
if (context) { if (context) {
get_bridge(context->func.slot->bridge); get_bridge(context->func.parent);
acpiphp_put_context(context); acpiphp_put_context(context);
} }
mutex_unlock(&acpiphp_context_lock); mutex_unlock(&acpiphp_context_lock);
...@@ -1113,7 +1114,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) ...@@ -1113,7 +1114,7 @@ void acpiphp_enumerate_slots(struct pci_bus *bus)
bridge->context = context; bridge->context = context;
context->bridge = bridge; context->bridge = bridge;
/* Get a reference to the parent bridge. */ /* Get a reference to the parent bridge. */
get_bridge(context->func.slot->bridge); get_bridge(context->func.parent);
mutex_unlock(&acpiphp_context_lock); mutex_unlock(&acpiphp_context_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment