ACPI / bind: Pass struct acpi_device pointer to acpi_bind_one()
There is no reason to pass an ACPI handle to acpi_bind_one() instead of a struct acpi_device pointer to the target device object, so modify that function to take a struct acpi_device pointer as its second argument and update all code depending on it accordingly. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Lan Tianyu <tianyu.lan@intel.com> # for USB/ACPI
This commit is contained in:
@@ -180,14 +180,14 @@ static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info)
|
|||||||
|
|
||||||
static int acpi_bind_memblk(struct memory_block *mem, void *arg)
|
static int acpi_bind_memblk(struct memory_block *mem, void *arg)
|
||||||
{
|
{
|
||||||
return acpi_bind_one(&mem->dev, (acpi_handle)arg);
|
return acpi_bind_one(&mem->dev, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
|
static int acpi_bind_memory_blocks(struct acpi_memory_info *info,
|
||||||
acpi_handle handle)
|
struct acpi_device *adev)
|
||||||
{
|
{
|
||||||
return walk_memory_range(acpi_meminfo_start_pfn(info),
|
return walk_memory_range(acpi_meminfo_start_pfn(info),
|
||||||
acpi_meminfo_end_pfn(info), (void *)handle,
|
acpi_meminfo_end_pfn(info), adev,
|
||||||
acpi_bind_memblk);
|
acpi_bind_memblk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,8 +197,7 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acpi_unbind_memory_blocks(struct acpi_memory_info *info,
|
static void acpi_unbind_memory_blocks(struct acpi_memory_info *info)
|
||||||
acpi_handle handle)
|
|
||||||
{
|
{
|
||||||
walk_memory_range(acpi_meminfo_start_pfn(info),
|
walk_memory_range(acpi_meminfo_start_pfn(info),
|
||||||
acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
|
acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk);
|
||||||
@@ -242,9 +241,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
|
|||||||
if (result && result != -EEXIST)
|
if (result && result != -EEXIST)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result = acpi_bind_memory_blocks(info, handle);
|
result = acpi_bind_memory_blocks(info, mem_device->device);
|
||||||
if (result) {
|
if (result) {
|
||||||
acpi_unbind_memory_blocks(info, handle);
|
acpi_unbind_memory_blocks(info);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +284,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
|
|||||||
if (nid == NUMA_NO_NODE)
|
if (nid == NUMA_NO_NODE)
|
||||||
nid = memory_add_physaddr_to_nid(info->start_addr);
|
nid = memory_add_physaddr_to_nid(info->start_addr);
|
||||||
|
|
||||||
acpi_unbind_memory_blocks(info, handle);
|
acpi_unbind_memory_blocks(info);
|
||||||
remove_memory(nid, info->start_addr, info->length);
|
remove_memory(nid, info->start_addr, info->length);
|
||||||
list_del(&info->list);
|
list_del(&info->list);
|
||||||
kfree(info);
|
kfree(info);
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ static int acpi_processor_add(struct acpi_device *device,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = acpi_bind_one(dev, pr->handle);
|
result = acpi_bind_one(dev, device);
|
||||||
if (result)
|
if (result)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|||||||
@@ -172,9 +172,8 @@ static void acpi_physnode_link_name(char *buf, unsigned int node_id)
|
|||||||
strcpy(buf, PHYSICAL_NODE_STRING);
|
strcpy(buf, PHYSICAL_NODE_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
int acpi_bind_one(struct device *dev, acpi_handle handle)
|
int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
|
||||||
{
|
{
|
||||||
struct acpi_device *acpi_dev = NULL;
|
|
||||||
struct acpi_device_physical_node *physical_node, *pn;
|
struct acpi_device_physical_node *physical_node, *pn;
|
||||||
char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
|
char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
|
||||||
struct list_head *physnode_list;
|
struct list_head *physnode_list;
|
||||||
@@ -182,14 +181,12 @@ int acpi_bind_one(struct device *dev, acpi_handle handle)
|
|||||||
int retval = -EINVAL;
|
int retval = -EINVAL;
|
||||||
|
|
||||||
if (ACPI_COMPANION(dev)) {
|
if (ACPI_COMPANION(dev)) {
|
||||||
if (handle) {
|
if (acpi_dev) {
|
||||||
dev_warn(dev, "ACPI companion already set\n");
|
dev_warn(dev, "ACPI companion already set\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
acpi_dev = ACPI_COMPANION(dev);
|
acpi_dev = ACPI_COMPANION(dev);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
acpi_bus_get_device(handle, &acpi_dev);
|
|
||||||
}
|
}
|
||||||
if (!acpi_dev)
|
if (!acpi_dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -314,7 +311,7 @@ static int acpi_platform_notify(struct device *dev)
|
|||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ret = acpi_bind_one(dev, adev->handle);
|
ret = acpi_bind_one(dev, adev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
|
|||||||
int type, unsigned long long sta);
|
int type, unsigned long long sta);
|
||||||
void acpi_device_add_finalize(struct acpi_device *device);
|
void acpi_device_add_finalize(struct acpi_device *device);
|
||||||
void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
|
void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
|
||||||
int acpi_bind_one(struct device *dev, acpi_handle handle);
|
int acpi_bind_one(struct device *dev, struct acpi_device *adev);
|
||||||
int acpi_unbind_one(struct device *dev);
|
int acpi_unbind_one(struct device *dev);
|
||||||
bool acpi_device_is_present(struct acpi_device *adev);
|
bool acpi_device_is_present(struct acpi_device *adev);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user