Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8bd759a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead



The only difference between acpi_bus_scan() and acpi_bus_add() is the
invocation of acpi_update_all_gpes() in the latter which in fact is
unnecessary, because acpi_update_all_gpes() has already been called
by acpi_scan_init() and the way it is implemented guarantees the next
invocations of it to do nothing.

For this reason, drop acpi_bus_add() and make all its callers use
acpi_bus_scan() directly instead of it.  Additionally, rearrange the
code in acpi_scan_init() slightly to improve the visibility of the
acpi_update_all_gpes() call in there.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarYinghai Lu <yinghai@kernel.org>
parent 5993c467
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ acpi_memory_get_device(acpi_handle handle,
	 * Now add the notified device.  This creates the acpi_device
	 * and invokes .add function
	 */
	result = acpi_bus_add(handle);
	result = acpi_bus_scan(handle);
	if (result) {
		acpi_handle_warn(handle, "Cannot add acpi bus\n");
		return -EINVAL;
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
		if (!ACPI_FAILURE(status) || device)
			break;

		result = acpi_bus_add(handle);
		result = acpi_bus_scan(handle);
		if (result) {
			acpi_handle_warn(handle, "Failed to add container\n");
			break;
+1 −1
Original line number Diff line number Diff line
@@ -317,7 +317,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
		 * no device created for this object,
		 * so we should create one.
		 */
		ret = acpi_bus_add(handle);
		ret = acpi_bus_scan(handle);
		if (ret)
			pr_debug("error adding bus, %x\n", -ret);

+1 −1
Original line number Diff line number Diff line
@@ -699,7 +699,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
		if (!acpi_bus_get_device(handle, &device))
			break;

		result = acpi_bus_add(handle);
		result = acpi_bus_scan(handle);
		if (result) {
			acpi_handle_err(handle, "Unable to add the device\n");
			break;
+22 −32
Original line number Diff line number Diff line
@@ -1577,26 +1577,8 @@ static acpi_status acpi_bus_device_attach(acpi_handle handle, u32 lvl_not_used,
	return status;
}

static int acpi_bus_scan(acpi_handle handle)
{
	void *device = NULL;

	if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
				    acpi_bus_check_add, NULL, NULL, &device);

	if (!device)
		return -ENODEV;

	if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
				    acpi_bus_device_attach, NULL, NULL, NULL);

	return 0;
}

/**
 * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
 * @handle: Root of the namespace scope to scan.
 *
 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
@@ -1607,18 +1589,24 @@ static int acpi_bus_scan(acpi_handle handle)
 * in the table trunk from which the kernel could create a device and add an
 * appropriate driver.
 */
int acpi_bus_add(acpi_handle handle)
int acpi_bus_scan(acpi_handle handle)
{
	int err;
	void *device = NULL;

	if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
				    acpi_bus_check_add, NULL, NULL, &device);

	err = acpi_bus_scan(handle);
	if (err)
		return err;
	if (!device)
		return -ENODEV;

	if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
				    acpi_bus_device_attach, NULL, NULL, NULL);

	acpi_update_all_gpes();
	return 0;
}
EXPORT_SYMBOL(acpi_bus_add);
EXPORT_SYMBOL(acpi_bus_scan);

static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
					  void *not_used, void **ret_not_used)
@@ -1708,13 +1696,15 @@ int __init acpi_scan_init(void)
		return result;

	result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
	if (!result)
		result = acpi_bus_scan_fixed();

	if (result)
		acpi_device_unregister(acpi_root);
	else
		acpi_update_all_gpes();
		return result;

	result = acpi_bus_scan_fixed();
	if (result) {
		acpi_device_unregister(acpi_root);
		return result;
	}

	acpi_update_all_gpes();
	return 0;
}
Loading