Skip to content

Commit c830dbc

Browse files
committed
ACPI: scan: Call acpi_get_object_info() from acpi_set_pnp_ids()
Notice that it is not necessary to call acpi_get_object_info() from acpi_add_single_object() in order to pass the pointer returned by it to acpi_init_device_object() and from there to acpi_set_pnp_ids(). It is more straightforward to call acpi_get_object_info() from acpi_set_pnp_ids() and avoid unnecessary pointer passing, so change the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
1 parent f5d9ab1 commit c830dbc

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

drivers/acpi/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct acpi_device_bus_id {
109109
int acpi_device_add(struct acpi_device *device,
110110
void (*release)(struct device *));
111111
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
112-
int type, struct acpi_device_info *info);
112+
int type);
113113
int acpi_device_setup_files(struct acpi_device *dev);
114114
void acpi_device_remove_files(struct acpi_device *dev);
115115
void acpi_device_add_finalize(struct acpi_device *device);

drivers/acpi/power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ int acpi_add_power_resource(acpi_handle handle)
925925
return -ENOMEM;
926926

927927
device = &resource->device;
928-
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, NULL);
928+
acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER);
929929
mutex_init(&resource->resource_lock);
930930
INIT_LIST_HEAD(&resource->list_node);
931931
INIT_LIST_HEAD(&resource->dependents);

drivers/acpi/scan.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,8 +1307,9 @@ static bool acpi_object_is_system_bus(acpi_handle handle)
13071307
}
13081308

13091309
static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1310-
int device_type, struct acpi_device_info *info)
1310+
int device_type)
13111311
{
1312+
struct acpi_device_info *info = NULL;
13121313
struct acpi_pnp_device_id_list *cid_list;
13131314
int i;
13141315

@@ -1319,6 +1320,7 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
13191320
break;
13201321
}
13211322

1323+
acpi_get_object_info(handle, &info);
13221324
if (!info) {
13231325
pr_err(PREFIX "%s: Error reading device info\n",
13241326
__func__);
@@ -1344,6 +1346,8 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
13441346
if (info->valid & ACPI_VALID_CLS)
13451347
acpi_add_id(pnp, info->class_code.string);
13461348

1349+
kfree(info);
1350+
13471351
/*
13481352
* Some devices don't reliably have _HIDs & _CIDs, so add
13491353
* synthetic HIDs to make sure drivers can find them.
@@ -1649,7 +1653,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
16491653
}
16501654

16511655
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1652-
int type, struct acpi_device_info *info)
1656+
int type)
16531657
{
16541658
INIT_LIST_HEAD(&device->pnp.ids);
16551659
device->device_type = type;
@@ -1658,7 +1662,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
16581662
fwnode_init(&device->fwnode, &acpi_device_fwnode_ops);
16591663
acpi_set_device_status(device, ACPI_STA_DEFAULT);
16601664
acpi_device_get_busid(device);
1661-
acpi_set_pnp_ids(handle, &device->pnp, type, info);
1665+
acpi_set_pnp_ids(handle, &device->pnp, type);
16621666
acpi_init_properties(device);
16631667
acpi_bus_get_flags(device);
16641668
device->flags.match_driver = false;
@@ -1688,21 +1692,14 @@ static void acpi_scan_init_status(struct acpi_device *adev)
16881692
static int acpi_add_single_object(struct acpi_device **child,
16891693
acpi_handle handle, int type)
16901694
{
1691-
struct acpi_device_info *info = NULL;
16921695
struct acpi_device *device;
16931696
int result;
16941697

1695-
if (type == ACPI_BUS_TYPE_DEVICE && handle != ACPI_ROOT_OBJECT)
1696-
acpi_get_object_info(handle, &info);
1697-
16981698
device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
1699-
if (!device) {
1700-
kfree(info);
1699+
if (!device)
17011700
return -ENOMEM;
1702-
}
17031701

1704-
acpi_init_device_object(device, handle, type, info);
1705-
kfree(info);
1702+
acpi_init_device_object(device, handle, type);
17061703
/*
17071704
* Getting the status is delayed till here so that we can call
17081705
* acpi_bus_get_status() and use its quirk handling. Note that

0 commit comments

Comments
 (0)