Commit 6091b263 authored by Hans de Goede's avatar Hans de Goede Committed by Rafael J. Wysocki

ACPI: scan: Call acpi_get_object_info() from acpi_add_single_object()

Call acpi_get_object_info() from acpi_add_single_object() instead of
calling it from acpi_set_pnp_ids() and pass the result down to the
latter so as to allow acpi_add_single_object() to use that data for
other purposes.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
[ rjw: Changelog rewrite ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 637b9f1a
...@@ -105,7 +105,8 @@ struct acpi_device_bus_id { ...@@ -105,7 +105,8 @@ struct acpi_device_bus_id {
int acpi_device_add(struct acpi_device *device, int acpi_device_add(struct acpi_device *device,
void (*release)(struct device *)); void (*release)(struct device *));
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
int type, unsigned long long sta); int type, unsigned long long sta,
struct acpi_device_info *info);
int acpi_device_setup_files(struct acpi_device *dev); int acpi_device_setup_files(struct acpi_device *dev);
void acpi_device_remove_files(struct acpi_device *dev); void acpi_device_remove_files(struct acpi_device *dev);
void acpi_device_add_finalize(struct acpi_device *device); void acpi_device_add_finalize(struct acpi_device *device);
......
...@@ -939,7 +939,7 @@ int acpi_add_power_resource(acpi_handle handle) ...@@ -939,7 +939,7 @@ int acpi_add_power_resource(acpi_handle handle)
device = &resource->device; device = &resource->device;
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER,
ACPI_STA_DEFAULT); ACPI_STA_DEFAULT, NULL);
mutex_init(&resource->resource_lock); mutex_init(&resource->resource_lock);
INIT_LIST_HEAD(&resource->list_node); INIT_LIST_HEAD(&resource->list_node);
INIT_LIST_HEAD(&resource->dependents); INIT_LIST_HEAD(&resource->dependents);
......
...@@ -1258,10 +1258,8 @@ static bool acpi_object_is_system_bus(acpi_handle handle) ...@@ -1258,10 +1258,8 @@ static bool acpi_object_is_system_bus(acpi_handle handle)
} }
static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
int device_type) int device_type, struct acpi_device_info *info)
{ {
acpi_status status;
struct acpi_device_info *info;
struct acpi_pnp_device_id_list *cid_list; struct acpi_pnp_device_id_list *cid_list;
int i; int i;
...@@ -1272,8 +1270,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, ...@@ -1272,8 +1270,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
break; break;
} }
status = acpi_get_object_info(handle, &info); if (!info) {
if (ACPI_FAILURE(status)) {
pr_err(PREFIX "%s: Error reading device info\n", pr_err(PREFIX "%s: Error reading device info\n",
__func__); __func__);
return; return;
...@@ -1298,8 +1295,6 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, ...@@ -1298,8 +1295,6 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
if (info->valid & ACPI_VALID_CLS) if (info->valid & ACPI_VALID_CLS)
acpi_add_id(pnp, info->class_code.string); acpi_add_id(pnp, info->class_code.string);
kfree(info);
/* /*
* Some devices don't reliably have _HIDs & _CIDs, so add * Some devices don't reliably have _HIDs & _CIDs, so add
* synthetic HIDs to make sure drivers can find them. * synthetic HIDs to make sure drivers can find them.
...@@ -1605,7 +1600,8 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) ...@@ -1605,7 +1600,8 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
} }
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
int type, unsigned long long sta) int type, unsigned long long sta,
struct acpi_device_info *info)
{ {
INIT_LIST_HEAD(&device->pnp.ids); INIT_LIST_HEAD(&device->pnp.ids);
device->device_type = type; device->device_type = type;
...@@ -1614,7 +1610,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, ...@@ -1614,7 +1610,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
device->fwnode.ops = &acpi_device_fwnode_ops; device->fwnode.ops = &acpi_device_fwnode_ops;
acpi_set_device_status(device, sta); acpi_set_device_status(device, sta);
acpi_device_get_busid(device); acpi_device_get_busid(device);
acpi_set_pnp_ids(handle, &device->pnp, type); acpi_set_pnp_ids(handle, &device->pnp, type, info);
acpi_init_properties(device); acpi_init_properties(device);
acpi_bus_get_flags(device); acpi_bus_get_flags(device);
device->flags.match_driver = false; device->flags.match_driver = false;
...@@ -1642,14 +1638,20 @@ static int acpi_add_single_object(struct acpi_device **child, ...@@ -1642,14 +1638,20 @@ static int acpi_add_single_object(struct acpi_device **child,
int result; int result;
struct acpi_device *device; struct acpi_device *device;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
struct acpi_device_info *info = NULL;
if (handle != ACPI_ROOT_OBJECT && type == ACPI_BUS_TYPE_DEVICE)
acpi_get_object_info(handle, &info);
device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
if (!device) { if (!device) {
printk(KERN_ERR PREFIX "Memory allocation error\n"); printk(KERN_ERR PREFIX "Memory allocation error\n");
kfree(info);
return -ENOMEM; return -ENOMEM;
} }
acpi_init_device_object(device, handle, type, sta); acpi_init_device_object(device, handle, type, sta, info);
kfree(info);
/* /*
* For ACPI_BUS_TYPE_DEVICE getting the status is delayed till here so * For ACPI_BUS_TYPE_DEVICE getting the status is delayed till here so
* that we can call acpi_bus_get_status() and use its quirk handling. * that we can call acpi_bus_get_status() and use its quirk handling.
......
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