diff mbox series

[v1,2/5] ACPI: scan: Rename acpi_bus_get_parent() and rearrange it

Message ID 2252770.ElGaqSPkdT@kreacher
State New
Headers show
Series ACPI: Device enumeration rearrangements and parent field elimination | expand

Commit Message

Rafael J. Wysocki Aug. 10, 2022, 4:15 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The acpi_bus_get_parent() name doesn't really reflect the
purpose of the function so change it to a more accurate
acpi_find_parent_acpi_dev().

While at it, rearrange the code inside that function the make it
easier to read.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/scan.c |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

Comments

Punit Agrawal Aug. 12, 2022, 1:08 p.m. UTC | #1
"Rafael J. Wysocki" <rjw@rjwysocki.net> writes:

> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> The acpi_bus_get_parent() name doesn't really reflect the
> purpose of the function so change it to a more accurate
> acpi_find_parent_acpi_dev().
>
> While at it, rearrange the code inside that function the make it

Typo:                                                  to

> easier to read.
>
> No intentional functional impact.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/scan.c |   24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -816,10 +816,9 @@ static const char * const acpi_honor_dep
>  	NULL
>  };
>  
> -static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
> +static struct acpi_device *acpi_find_parent_acpi_dev(acpi_handle handle)
>  {
> -	struct acpi_device *device;
> -	acpi_status status;
> +	struct acpi_device *adev;
>  
>  	/*
>  	 * Fixed hardware devices do not appear in the namespace and do not
> @@ -830,13 +829,18 @@ static struct acpi_device *acpi_bus_get_
>  		return acpi_root;
>  
>  	do {
> -		status = acpi_get_parent(handle, &handle);
> -		if (ACPI_FAILURE(status))
> -			return status == AE_NULL_ENTRY ? NULL : acpi_root;
> +		acpi_status status;
>  
> -		device = acpi_fetch_acpi_dev(handle);
> -	} while (!device);
> -	return device;
> +		status = acpi_get_parent(handle, &handle);
> +		if (ACPI_FAILURE(status)) {
> +			if (status != AE_NULL_ENTRY)
> +				return acpi_root;
> +
> +			return NULL;
> +		}
> +		adev = acpi_fetch_acpi_dev(handle);
> +	} while (!adev);
> +	return adev;
>  }
>  
>  acpi_status
> @@ -1777,7 +1781,7 @@ void acpi_init_device_object(struct acpi
>  	INIT_LIST_HEAD(&device->pnp.ids);
>  	device->device_type = type;
>  	device->handle = handle;
> -	device->parent = acpi_bus_get_parent(handle);
> +	device->parent = acpi_find_parent_acpi_dev(handle);
>  	fwnode_init(&device->fwnode, &acpi_device_fwnode_ops);
>  	acpi_set_device_status(device, ACPI_STA_DEFAULT);
>  	acpi_device_get_busid(device);
diff mbox series

Patch

Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -816,10 +816,9 @@  static const char * const acpi_honor_dep
 	NULL
 };
 
-static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
+static struct acpi_device *acpi_find_parent_acpi_dev(acpi_handle handle)
 {
-	struct acpi_device *device;
-	acpi_status status;
+	struct acpi_device *adev;
 
 	/*
 	 * Fixed hardware devices do not appear in the namespace and do not
@@ -830,13 +829,18 @@  static struct acpi_device *acpi_bus_get_
 		return acpi_root;
 
 	do {
-		status = acpi_get_parent(handle, &handle);
-		if (ACPI_FAILURE(status))
-			return status == AE_NULL_ENTRY ? NULL : acpi_root;
+		acpi_status status;
 
-		device = acpi_fetch_acpi_dev(handle);
-	} while (!device);
-	return device;
+		status = acpi_get_parent(handle, &handle);
+		if (ACPI_FAILURE(status)) {
+			if (status != AE_NULL_ENTRY)
+				return acpi_root;
+
+			return NULL;
+		}
+		adev = acpi_fetch_acpi_dev(handle);
+	} while (!adev);
+	return adev;
 }
 
 acpi_status
@@ -1777,7 +1781,7 @@  void acpi_init_device_object(struct acpi
 	INIT_LIST_HEAD(&device->pnp.ids);
 	device->device_type = type;
 	device->handle = handle;
-	device->parent = acpi_bus_get_parent(handle);
+	device->parent = acpi_find_parent_acpi_dev(handle);
 	fwnode_init(&device->fwnode, &acpi_device_fwnode_ops);
 	acpi_set_device_status(device, ACPI_STA_DEFAULT);
 	acpi_device_get_busid(device);