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

ACPI: Drop parent field from struct acpi_device



The parent field in struct acpi_device is, in fact, redundant,
because the dev.parent field in it effectively points to the same
object and it is used by the driver core.

Accordingly, the parent field can be dropped from struct acpi_device
and for this purpose define acpi_dev_parent() to retrieve a parent
struct acpi_device pointer from the dev.parent field in struct
acpi_device.  Next, update all of the users of the parent field
in struct acpi_device to use acpi_dev_parent() instead of it and
drop it.

While at it, drop the ACPI_IS_ROOT_DEVICE() macro that is only used
in one place in a confusing way.

No intentional functional impact.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: default avatarWei Liu <wei.liu@kernel.org>
Reviewed-by: default avatarPunit Agrawal <punit.agrawal@bytedance.com>
parent 6e1850b2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ static void amba_register_dummy_clk(void)
static int amba_handler_attach(struct acpi_device *adev,
				const struct acpi_device_id *id)
{
	struct acpi_device *parent = acpi_dev_parent(adev);
	struct amba_device *dev;
	struct resource_entry *rentry;
	struct list_head resource_list;
@@ -97,8 +98,8 @@ static int amba_handler_attach(struct acpi_device *adev,
	 * attached to it, that physical device should be the parent of
	 * the amba device we are about to create.
	 */
	if (adev->parent)
		dev->dev.parent = acpi_get_first_physical_node(adev->parent);
	if (parent)
		dev->dev.parent = acpi_get_first_physical_node(parent);

	ACPI_COMPANION_SET(&dev->dev, adev);

+3 −3
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
	 * If the device has parent we need to take its resources into
	 * account as well because this device might consume part of those.
	 */
	parent = acpi_get_first_physical_node(adev->parent);
	parent = acpi_get_first_physical_node(acpi_dev_parent(adev));
	if (parent && dev_is_pci(parent))
		dest->parent = pci_find_resource(to_pci_dev(parent), dest);
}
@@ -97,6 +97,7 @@ static void acpi_platform_fill_resource(struct acpi_device *adev,
struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
						    const struct property_entry *properties)
{
	struct acpi_device *parent = acpi_dev_parent(adev);
	struct platform_device *pdev = NULL;
	struct platform_device_info pdevinfo;
	struct resource_entry *rentry;
@@ -137,8 +138,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
	 * attached to it, that physical device should be the parent of the
	 * platform device we are about to create.
	 */
	pdevinfo.parent = adev->parent ?
		acpi_get_first_physical_node(adev->parent) : NULL;
	pdevinfo.parent = parent ? acpi_get_first_physical_node(parent) : NULL;
	pdevinfo.name = dev_name(&adev->dev);
	pdevinfo.id = -1;
	pdevinfo.res = resources;
+1 −1
Original line number Diff line number Diff line
@@ -2030,7 +2030,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
	acpi_status status;

	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
				device->parent->handle, 1,
				acpi_dev_parent(device)->handle, 1,
				acpi_video_bus_match, NULL,
				device, NULL);
	if (status == AE_ALREADY_EXISTS) {
+10 −9
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state)
 */
int acpi_device_get_power(struct acpi_device *device, int *state)
{
	struct acpi_device *parent = acpi_dev_parent(device);
	int result = ACPI_STATE_UNKNOWN;
	int error;

@@ -82,8 +83,7 @@ int acpi_device_get_power(struct acpi_device *device, int *state)

	if (!device->flags.power_manageable) {
		/* TBD: Non-recursive algorithm for walking up hierarchy. */
		*state = device->parent ?
			device->parent->power.state : ACPI_STATE_D0;
		*state = parent ? parent->power.state : ACPI_STATE_D0;
		goto out;
	}

@@ -122,10 +122,10 @@ int acpi_device_get_power(struct acpi_device *device, int *state)
	 * point, the fact that the device is in D0 implies that the parent has
	 * to be in D0 too, except if ignore_parent is set.
	 */
	if (!device->power.flags.ignore_parent && device->parent
	    && device->parent->power.state == ACPI_STATE_UNKNOWN
	    && result == ACPI_STATE_D0)
		device->parent->power.state = ACPI_STATE_D0;
	if (!device->power.flags.ignore_parent && parent &&
	    parent->power.state == ACPI_STATE_UNKNOWN &&
	    result == ACPI_STATE_D0)
		parent->power.state = ACPI_STATE_D0;

	*state = result;

@@ -159,6 +159,7 @@ static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
 */
int acpi_device_set_power(struct acpi_device *device, int state)
{
	struct acpi_device *parent = acpi_dev_parent(device);
	int target_state = state;
	int result = 0;

@@ -191,12 +192,12 @@ int acpi_device_set_power(struct acpi_device *device, int state)
		return -ENODEV;
	}

	if (!device->power.flags.ignore_parent && device->parent &&
	    state < device->parent->power.state) {
	if (!device->power.flags.ignore_parent && parent &&
	    state < parent->power.state) {
		acpi_handle_debug(device->handle,
				  "Cannot transition to %s for parent in %s\n",
				  acpi_power_state_string(state),
				  acpi_power_state_string(device->parent->power.state));
				  acpi_power_state_string(parent->power.state));
		return -ENODEV;
	}

+4 −2
Original line number Diff line number Diff line
@@ -304,8 +304,10 @@ static void acpi_init_of_compatible(struct acpi_device *adev)
		ret = acpi_dev_get_property(adev, "compatible",
					    ACPI_TYPE_STRING, &of_compatible);
		if (ret) {
			if (adev->parent
			    && adev->parent->flags.of_compatible_ok)
			struct acpi_device *parent;

			parent = acpi_dev_parent(adev);
			if (parent && parent->flags.of_compatible_ok)
				goto out;

			return;
Loading