Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+11 -14
+1 -1
drivers/acpi/internal.h
··· 109 109 int acpi_device_add(struct acpi_device *device, 110 110 void (*release)(struct device *)); 111 111 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 112 - int type, struct acpi_device_info *info); 112 + int type); 113 113 int acpi_device_setup_files(struct acpi_device *dev); 114 114 void acpi_device_remove_files(struct acpi_device *dev); 115 115 void acpi_device_add_finalize(struct acpi_device *device);
+1 -1
drivers/acpi/power.c
··· 925 925 return -ENOMEM; 926 926 927 927 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); 929 929 mutex_init(&resource->resource_lock); 930 930 INIT_LIST_HEAD(&resource->list_node); 931 931 INIT_LIST_HEAD(&resource->dependents);
+9 -12
drivers/acpi/scan.c
··· 1307 1307 } 1308 1308 1309 1309 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) 1311 1311 { 1312 + struct acpi_device_info *info = NULL; 1312 1313 struct acpi_pnp_device_id_list *cid_list; 1313 1314 int i; 1314 1315 ··· 1320 1319 break; 1321 1320 } 1322 1321 1322 + acpi_get_object_info(handle, &info); 1323 1323 if (!info) { 1324 1324 pr_err(PREFIX "%s: Error reading device info\n", 1325 1325 __func__); ··· 1345 1343 GFP_KERNEL); 1346 1344 if (info->valid & ACPI_VALID_CLS) 1347 1345 acpi_add_id(pnp, info->class_code.string); 1346 + 1347 + kfree(info); 1348 1348 1349 1349 /* 1350 1350 * Some devices don't reliably have _HIDs & _CIDs, so add ··· 1653 1649 } 1654 1650 1655 1651 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 1656 - int type, struct acpi_device_info *info) 1652 + int type) 1657 1653 { 1658 1654 INIT_LIST_HEAD(&device->pnp.ids); 1659 1655 device->device_type = type; ··· 1662 1658 fwnode_init(&device->fwnode, &acpi_device_fwnode_ops); 1663 1659 acpi_set_device_status(device, ACPI_STA_DEFAULT); 1664 1660 acpi_device_get_busid(device); 1665 - acpi_set_pnp_ids(handle, &device->pnp, type, info); 1661 + acpi_set_pnp_ids(handle, &device->pnp, type); 1666 1662 acpi_init_properties(device); 1667 1663 acpi_bus_get_flags(device); 1668 1664 device->flags.match_driver = false; ··· 1692 1688 static int acpi_add_single_object(struct acpi_device **child, 1693 1689 acpi_handle handle, int type) 1694 1690 { 1695 - struct acpi_device_info *info = NULL; 1696 1691 struct acpi_device *device; 1697 1692 int result; 1698 1693 1699 - if (type == ACPI_BUS_TYPE_DEVICE && handle != ACPI_ROOT_OBJECT) 1700 - acpi_get_object_info(handle, &info); 1701 - 1702 1694 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); 1703 - if (!device) { 1704 - kfree(info); 1695 + if (!device) 1705 1696 return -ENOMEM; 1706 - } 1707 1697 1708 - acpi_init_device_object(device, handle, type, info); 1709 - kfree(info); 1698 + acpi_init_device_object(device, handle, type); 1710 1699 /* 1711 1700 * Getting the status is delayed till here so that we can call 1712 1701 * acpi_bus_get_status() and use its quirk handling. Note that