diff mbox

[2/2] ACPI / scan: Clean up acpi_bus_get_parent()

Message ID 7667918.svVNymu9rt@vostro.rjw.lan (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Rafael Wysocki Jan. 30, 2013, 10:04 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Make acpi_bus_get_parent() more straightforward and remove an
unnecessary local variable ret from it.

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


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Yasuaki Ishimatsu Jan. 31, 2013, 3:41 a.m. UTC | #1
2013/01/31 7:04, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Make acpi_bus_get_parent() more straightforward and remove an
> unnecessary local variable ret from it.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---

Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

>   drivers/acpi/scan.c |   16 +++++-----------
>   1 file changed, 5 insertions(+), 11 deletions(-)
>
> Index: test/drivers/acpi/scan.c
> ===================================================================
> --- test.orig/drivers/acpi/scan.c
> +++ test/drivers/acpi/scan.c
> @@ -871,29 +871,23 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver
>      -------------------------------------------------------------------------- */
>   static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
>   {
> +	struct acpi_device *device = NULL;
>   	acpi_status status;
> -	int ret;
> -	struct acpi_device *device;
>
>   	/*
>   	 * Fixed hardware devices do not appear in the namespace and do not
>   	 * have handles, but we fabricate acpi_devices for them, so we have
>   	 * to deal with them specially.
>   	 */
> -	if (handle == NULL)
> +	if (!handle)
>   		return acpi_root;
>
>   	do {
>   		status = acpi_get_parent(handle, &handle);
> -		if (status == AE_NULL_ENTRY)
> -			return NULL;
>   		if (ACPI_FAILURE(status))
> -			return acpi_root;
> -
> -		ret = acpi_bus_get_device(handle, &device);
> -		if (ret == 0)
> -			return device;
> -	} while (1);
> +			return status == AE_NULL_ENTRY ? NULL : acpi_root;
> +	} while (acpi_bus_get_device(handle, &device));
> +	return device;
>   }
>
>   acpi_status
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg Jan. 31, 2013, 8:46 a.m. UTC | #2
On Wed, Jan 30, 2013 at 11:04:03PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make acpi_bus_get_parent() more straightforward and remove an
> unnecessary local variable ret from it.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yinghai Lu Jan. 31, 2013, 6:43 p.m. UTC | #3
On Wed, Jan 30, 2013 at 2:04 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Make acpi_bus_get_parent() more straightforward and remove an
> unnecessary local variable ret from it.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/scan.c |   16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
>
> Index: test/drivers/acpi/scan.c
> ===================================================================
> --- test.orig/drivers/acpi/scan.c
> +++ test/drivers/acpi/scan.c
> @@ -871,29 +871,23 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver
>     -------------------------------------------------------------------------- */
>  static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
>  {
> +       struct acpi_device *device = NULL;
>         acpi_status status;
> -       int ret;
> -       struct acpi_device *device;
>
>         /*
>          * Fixed hardware devices do not appear in the namespace and do not
>          * have handles, but we fabricate acpi_devices for them, so we have
>          * to deal with them specially.
>          */
> -       if (handle == NULL)
> +       if (!handle)
>                 return acpi_root;
>
>         do {
>                 status = acpi_get_parent(handle, &handle);
> -               if (status == AE_NULL_ENTRY)
> -                       return NULL;
>                 if (ACPI_FAILURE(status))
> -                       return acpi_root;
> -
> -               ret = acpi_bus_get_device(handle, &device);
> -               if (ret == 0)
> -                       return device;
> -       } while (1);
> +                       return status == AE_NULL_ENTRY ? NULL : acpi_root;
> +       } while (acpi_bus_get_device(handle, &device));
> +       return device;
>  }

Acked-by: Yinghai Lu <yinghai@kernel.org>

>
>  acpi_status
>
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: test/drivers/acpi/scan.c
===================================================================
--- test.orig/drivers/acpi/scan.c
+++ test/drivers/acpi/scan.c
@@ -871,29 +871,23 @@  EXPORT_SYMBOL(acpi_bus_unregister_driver
    -------------------------------------------------------------------------- */
 static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
 {
+	struct acpi_device *device = NULL;
 	acpi_status status;
-	int ret;
-	struct acpi_device *device;
 
 	/*
 	 * Fixed hardware devices do not appear in the namespace and do not
 	 * have handles, but we fabricate acpi_devices for them, so we have
 	 * to deal with them specially.
 	 */
-	if (handle == NULL)
+	if (!handle)
 		return acpi_root;
 
 	do {
 		status = acpi_get_parent(handle, &handle);
-		if (status == AE_NULL_ENTRY)
-			return NULL;
 		if (ACPI_FAILURE(status))
-			return acpi_root;
-
-		ret = acpi_bus_get_device(handle, &device);
-		if (ret == 0)
-			return device;
-	} while (1);
+			return status == AE_NULL_ENTRY ? NULL : acpi_root;
+	} while (acpi_bus_get_device(handle, &device));
+	return device;
 }
 
 acpi_status