mirror of https://gitee.com/openkylin/linux.git
PCI/ACPI: Pass acpi_pci_root to acpi_pci_drivers' add/remove interface
This patch changes .add/.remove interfaces of acpi_pci_driver. In the current implementation acpi_handle is passed as a parameter of .add/.remove interface. However, the acpi_pci_root structure contains more useful information than just the acpi_handle. This enables us to avoid some useless lookups in each acpi_pci_driver. Note: This changes interfaces used by acpi_pci_register_driver(), an exported symbol. This patch updates all the in-kernel users, but any out-of-kernel acpi_pci_register_driver() users will need updates. [bhelgaas: changelog] Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
parent
d0020f6522
commit
55bfe3c0c5
|
@ -87,7 +87,7 @@ int acpi_pci_register_driver(struct acpi_pci_driver *driver)
|
||||||
list_add_tail(&driver->node, &acpi_pci_drivers);
|
list_add_tail(&driver->node, &acpi_pci_drivers);
|
||||||
if (driver->add)
|
if (driver->add)
|
||||||
list_for_each_entry(root, &acpi_pci_roots, node) {
|
list_for_each_entry(root, &acpi_pci_roots, node) {
|
||||||
driver->add(root->device->handle);
|
driver->add(root);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
mutex_unlock(&acpi_pci_root_lock);
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
|
@ -104,7 +104,7 @@ void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
|
||||||
list_del(&driver->node);
|
list_del(&driver->node);
|
||||||
if (driver->remove)
|
if (driver->remove)
|
||||||
list_for_each_entry(root, &acpi_pci_roots, node)
|
list_for_each_entry(root, &acpi_pci_roots, node)
|
||||||
driver->remove(root->device->handle);
|
driver->remove(root);
|
||||||
mutex_unlock(&acpi_pci_root_lock);
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(acpi_pci_unregister_driver);
|
EXPORT_SYMBOL(acpi_pci_unregister_driver);
|
||||||
|
@ -629,7 +629,7 @@ static int acpi_pci_root_start(struct acpi_device *device)
|
||||||
mutex_lock(&acpi_pci_root_lock);
|
mutex_lock(&acpi_pci_root_lock);
|
||||||
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
||||||
if (driver->add)
|
if (driver->add)
|
||||||
driver->add(device->handle);
|
driver->add(root);
|
||||||
mutex_unlock(&acpi_pci_root_lock);
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
|
|
||||||
pci_bus_add_devices(root->bus);
|
pci_bus_add_devices(root->bus);
|
||||||
|
@ -645,7 +645,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)
|
||||||
mutex_lock(&acpi_pci_root_lock);
|
mutex_lock(&acpi_pci_root_lock);
|
||||||
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
list_for_each_entry(driver, &acpi_pci_drivers, node)
|
||||||
if (driver->remove)
|
if (driver->remove)
|
||||||
driver->remove(root->device->handle);
|
driver->remove(root);
|
||||||
mutex_unlock(&acpi_pci_root_lock);
|
mutex_unlock(&acpi_pci_root_lock);
|
||||||
|
|
||||||
device_set_run_wake(root->bus->bridge, false);
|
device_set_run_wake(root->bus->bridge, false);
|
||||||
|
|
|
@ -67,8 +67,8 @@ struct acpi_pci_slot {
|
||||||
struct list_head list; /* node in the list of slots */
|
struct list_head list; /* node in the list of slots */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int acpi_pci_slot_add(acpi_handle handle);
|
static int acpi_pci_slot_add(struct acpi_pci_root *root);
|
||||||
static void acpi_pci_slot_remove(acpi_handle handle);
|
static void acpi_pci_slot_remove(struct acpi_pci_root *root);
|
||||||
|
|
||||||
static LIST_HEAD(slot_list);
|
static LIST_HEAD(slot_list);
|
||||||
static DEFINE_MUTEX(slot_list_lock);
|
static DEFINE_MUTEX(slot_list_lock);
|
||||||
|
@ -295,11 +295,11 @@ walk_root_bridge(acpi_handle handle, acpi_walk_callback user_function)
|
||||||
* @handle: points to an acpi_pci_root
|
* @handle: points to an acpi_pci_root
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
acpi_pci_slot_add(acpi_handle handle)
|
acpi_pci_slot_add(struct acpi_pci_root *root)
|
||||||
{
|
{
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
status = walk_root_bridge(handle, register_slot);
|
status = walk_root_bridge(root->device->handle, register_slot);
|
||||||
if (ACPI_FAILURE(status))
|
if (ACPI_FAILURE(status))
|
||||||
err("%s: register_slot failure - %d\n", __func__, status);
|
err("%s: register_slot failure - %d\n", __func__, status);
|
||||||
|
|
||||||
|
@ -311,10 +311,11 @@ acpi_pci_slot_add(acpi_handle handle)
|
||||||
* @handle: points to an acpi_pci_root
|
* @handle: points to an acpi_pci_root
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
acpi_pci_slot_remove(acpi_handle handle)
|
acpi_pci_slot_remove(struct acpi_pci_root *root)
|
||||||
{
|
{
|
||||||
struct acpi_pci_slot *slot, *tmp;
|
struct acpi_pci_slot *slot, *tmp;
|
||||||
struct pci_bus *pbus;
|
struct pci_bus *pbus;
|
||||||
|
acpi_handle handle = root->device->handle;
|
||||||
|
|
||||||
mutex_lock(&slot_list_lock);
|
mutex_lock(&slot_list_lock);
|
||||||
list_for_each_entry_safe(slot, tmp, &slot_list, list) {
|
list_for_each_entry_safe(slot, tmp, &slot_list, list) {
|
||||||
|
|
|
@ -382,10 +382,10 @@ static inline void config_p2p_bridge_flags(struct acpiphp_bridge *bridge)
|
||||||
|
|
||||||
|
|
||||||
/* allocate and initialize host bridge data structure */
|
/* allocate and initialize host bridge data structure */
|
||||||
static void add_host_bridge(acpi_handle *handle)
|
static void add_host_bridge(struct acpi_pci_root *root)
|
||||||
{
|
{
|
||||||
struct acpiphp_bridge *bridge;
|
struct acpiphp_bridge *bridge;
|
||||||
struct acpi_pci_root *root = acpi_pci_find_root(handle);
|
acpi_handle handle = root->device->handle;
|
||||||
|
|
||||||
bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
|
bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
|
||||||
if (bridge == NULL)
|
if (bridge == NULL)
|
||||||
|
@ -468,11 +468,12 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
|
||||||
|
|
||||||
|
|
||||||
/* find hot-pluggable slots, and then find P2P bridge */
|
/* find hot-pluggable slots, and then find P2P bridge */
|
||||||
static int add_bridge(acpi_handle handle)
|
static int add_bridge(struct acpi_pci_root *root)
|
||||||
{
|
{
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
unsigned long long tmp;
|
unsigned long long tmp;
|
||||||
acpi_handle dummy_handle;
|
acpi_handle dummy_handle;
|
||||||
|
acpi_handle handle = root->device->handle;
|
||||||
|
|
||||||
/* if the bridge doesn't have _STA, we assume it is always there */
|
/* if the bridge doesn't have _STA, we assume it is always there */
|
||||||
status = acpi_get_handle(handle, "_STA", &dummy_handle);
|
status = acpi_get_handle(handle, "_STA", &dummy_handle);
|
||||||
|
@ -490,7 +491,7 @@ static int add_bridge(acpi_handle handle)
|
||||||
/* check if this bridge has ejectable slots */
|
/* check if this bridge has ejectable slots */
|
||||||
if (detect_ejectable_slots(handle) > 0) {
|
if (detect_ejectable_slots(handle) > 0) {
|
||||||
dbg("found PCI host-bus bridge with hot-pluggable slots\n");
|
dbg("found PCI host-bus bridge with hot-pluggable slots\n");
|
||||||
add_host_bridge(handle);
|
add_host_bridge(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search P2P bridges under this host bridge */
|
/* search P2P bridges under this host bridge */
|
||||||
|
@ -588,9 +589,10 @@ cleanup_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
|
||||||
return AE_OK;
|
return AE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_bridge(acpi_handle handle)
|
static void remove_bridge(struct acpi_pci_root *root)
|
||||||
{
|
{
|
||||||
struct acpiphp_bridge *bridge;
|
struct acpiphp_bridge *bridge;
|
||||||
|
acpi_handle handle = root->device->handle;
|
||||||
|
|
||||||
/* cleanup p2p bridges under this host bridge
|
/* cleanup p2p bridges under this host bridge
|
||||||
in a depth-first manner */
|
in a depth-first manner */
|
||||||
|
|
|
@ -139,8 +139,8 @@ void acpi_pci_irq_disable (struct pci_dev *dev);
|
||||||
|
|
||||||
struct acpi_pci_driver {
|
struct acpi_pci_driver {
|
||||||
struct list_head node;
|
struct list_head node;
|
||||||
int (*add)(acpi_handle handle);
|
int (*add)(struct acpi_pci_root *root);
|
||||||
void (*remove)(acpi_handle handle);
|
void (*remove)(struct acpi_pci_root *root);
|
||||||
};
|
};
|
||||||
|
|
||||||
int acpi_pci_register_driver(struct acpi_pci_driver *driver);
|
int acpi_pci_register_driver(struct acpi_pci_driver *driver);
|
||||||
|
|
Loading…
Reference in New Issue