ACPI / scan: Fold acpi_bus_scan() into acpi_bus_add()
Subsystems (3)
PATCH 1/1 ACPI / scan: Fold acpi_bus_scan() into acpi_bus_add()
From: Rafael J. Wysocki <[email protected]>
The only difference between acpi_bus_scan() into 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 causes the next invocations of it to do nothing.
For this reason, drop the acpi_update_all_gpes() call from acpi_bus_add() and fold acpi_bus_scan() into it. Additionally, rename acpi_bus_scan_fixed() to acpi_bus_add_fixed(), because acpi_bus_scan() is not present any more, and rearrange the code in acpi_scan_init() slightly.
--- drivers/acpi/scan.c | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-)
drivers/acpi/scan.c +21 -31
@@ -1584,24 +1584,6 @@ static acpi_status acpi_bus_device_attacreturn 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. * @handle: Root of the namespace scope to scan.
@@ -1616,13 +1598,19 @@ static int acpi_bus_scan(acpi_handle han*/ int acpi_bus_add (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); + +if (!device) +return -ENODEV ; - err =acpi_bus_scan (handle); -if (err) -return err; +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);
@@ -1670,7 +1658,7 @@ int acpi_bus_trim(struct acpi_device *st }EXPORT_SYMBOL_GPL (acpi_bus_trim); -static int acpi_bus_scan_fixed (void ) +static int acpi_bus_add_fixed (void ) {int result =0 ;struct acpi_device *device =NULL ;
@@ -1709,18 +1697,20 @@ int __init acpi_scan_init(void)/* * Enumerate devices in the ACPI namespace. */ - result =acpi_bus_scan (ACPI_ROOT_OBJECT ); + result =acpi_bus_add (ACPI_ROOT_OBJECT );if (result)return result; result =acpi_bus_get_device (ACPI_ROOT_OBJECT , &acpi_root); -if (!result) - result =acpi_bus_scan_fixed (); -if (result) +return result; + + result =acpi_bus_add_fixed (); +if (result) {acpi_device_unregister (acpi_root); -else -acpi_update_all_gpes (); +return result; + } -return result; +acpi_update_all_gpes (); +return 0 ; }
Quoted 49 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The only difference between
acpi_bus_scan()intoacpi_bus_add()is the invocation ofacpi_update_all_gpes()in the latter which in fact is unnecessary, becauseacpi_update_all_gpes()has already been called byacpi_scan_init()and the way it is implemented causes the next invocations of it to do nothing.For this reason, drop the
acpi_update_all_gpes()call fromacpi_bus_add()and foldacpi_bus_scan()into it. Additionally, renameacpi_bus_scan_fixed()toacpi_bus_add_fixed(), becauseacpi_bus_scan()is not present any more, and rearrange the code inacpi_scan_init()slightly.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/scan.c | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-)Index:
linux-pm/drivers/acpi/scan.c
===================================================================drivers/acpi/scan.c +0
-18@@ -1584,24 +1584,6 @@ static acpi_status acpi_bus_device_attacreturn 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. * @handle: Root of the namespace scope to scan.
drivers/acpi/scan.c static int acpi_bus_scan(acpi_handle han · line 1599
Quoted 2 lines
drivers/acpi/scan.c +0
-0@@ -1616,13 +1598,19 @@ static int acpi_bus_scan(acpi_handle han*/ int acpi_bus_add (acpi_handle handle)
looks like scan is good name.
scan = add + attach better than
add = add + attach?
Quoted 60 lines
drivers/acpi/scan.c +21
-13{ -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); + +if (!device) +return -ENODEV ; - err =acpi_bus_scan (handle); -if (err) -return err; +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);@@ -1670,7 +1658,7 @@ int acpi_bus_trim(struct acpi_device *st }EXPORT_SYMBOL_GPL (acpi_bus_trim); -static int acpi_bus_scan_fixed (void ) +static int acpi_bus_add_fixed (void ) {int result =0 ;struct acpi_device *device =NULL ;@@ -1709,18 +1697,20 @@ int __init acpi_scan_init(void)/* * Enumerate devices in the ACPI namespace. */ - result =acpi_bus_scan (ACPI_ROOT_OBJECT ); + result =acpi_bus_add (ACPI_ROOT_OBJECT );if (result)return result; result =acpi_bus_get_device (ACPI_ROOT_OBJECT , &acpi_root); -if (!result) - result =acpi_bus_scan_fixed (); -if (result) +return result; + + result =acpi_bus_add_fixed (); +if (result) {acpi_device_unregister (acpi_root); -else -acpi_update_all_gpes (); +return result; + } -return result; +acpi_update_all_gpes (); +return 0 ; }
PATCH 1/1 ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead (was: Re: [PATCH] ACPI / scan: Fold acpi_bus_scan() into acpi_bus_add())
Quoted 55 lines · Yinghai Lu
Quoted 49 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The only difference between
acpi_bus_scan()intoacpi_bus_add()is the invocation ofacpi_update_all_gpes()in the latter which in fact is unnecessary, becauseacpi_update_all_gpes()has already been called byacpi_scan_init()and the way it is implemented causes the next invocations of it to do nothing.For this reason, drop the
acpi_update_all_gpes()call fromacpi_bus_add()and foldacpi_bus_scan()into it. Additionally, renameacpi_bus_scan_fixed()toacpi_bus_add_fixed(), becauseacpi_bus_scan()is not present any more, and rearrange the code inacpi_scan_init()slightly.Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/scan.c | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-)Index:
linux-pm/drivers/acpi/scan.c
===================================================================drivers/acpi/scan.c +0
-18@@ -1584,24 +1584,6 @@ static acpi_status acpi_bus_device_attacreturn 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. * @handle: Root of the namespace scope to scan. drivers/acpi/scan.c static int acpi_bus_scan(acpi_handle han · line 1599
Quoted 2 lines
drivers/acpi/scan.c +0
-0@@ -1616,13 +1598,19 @@ static int acpi_bus_scan(acpi_handle han*/ int acpi_bus_add (acpi_handle handle)looks like scan is good name.
Quoted 2 lines
scan = add + attach better than
add = add + attach?
Well, I thought "add = create + attach". :-)
Anyway, scan works for me too.
Thanks,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: 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.
--- drivers/acpi/acpi_memhotplug.c | 2 - drivers/acpi/container.c | 2 - drivers/acpi/dock.c | 2 - drivers/acpi/processor_driver.c | 2 - drivers/acpi/scan.c | 54 +++++++++++++++---------------------- drivers/pci/hotplug/acpiphp_glue.c | 4 +- drivers/pci/hotplug/sgi_hotplug.c | 4 +- include/acpi/acpi_bus.h | 2 - 8 files changed, 31 insertions(+), 41 deletions(-)
drivers/acpi/scan.c +22 -32
@@ -1584,26 +1584,8 @@ static acpi_status acpi_bus_device_attacreturn 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
@@ -1614,18 +1596,24 @@ static int acpi_bus_scan(acpi_handle han* 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); + +if (!device) +return -ENODEV ; - err =acpi_bus_scan (handle); -if (err) -return err; +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)
@@ -1714,13 +1702,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) +return result; + + result =acpi_bus_scan_fixed (); +if (result) {acpi_device_unregister (acpi_root); -else -acpi_update_all_gpes (); +return result; + } -return result; +acpi_update_all_gpes (); +return 0 ; }
drivers/acpi/acpi_memhotplug.c +1 -1
@@ -167,7 +167,7 @@ acpi_memory_get_device(acpi_handle handl* 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 ;
drivers/acpi/container.c +1 -1
@@ -166,7 +166,7 @@ static void container_notify_cb(acpi_hanif (!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 ;
drivers/acpi/dock.c +1 -1
@@ -317,7 +317,7 @@ static struct acpi_device * dock_create_* 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);
drivers/pci/hotplug/acpiphp_glue.c +2 -2
@@ -746,7 +746,7 @@ static int acpiphp_bus_add(struct acpiphdbg ("acpi_bus_trim return %x\n" , ret_val); } - ret_val =acpi_bus_add (func->handle); + ret_val =acpi_bus_scan (func->handle);if (!ret_val) ret_val =acpi_bus_get_device (func->handle, &device);
@@ -1129,7 +1129,7 @@ static void handle_bridge_insertion(acpireturn ; } -if (acpi_bus_add (handle)) { +if (acpi_bus_scan (handle)) {err ("cannot add bridge to acpi list\n" );return ; }
include/acpi/acpi_bus.h +1 -1
@@ -385,7 +385,7 @@ static inline int acpi_bus_generate_proc#endif int acpi_bus_register_driver (struct acpi_driver *driver);void acpi_bus_unregister_driver (struct acpi_driver *driver); -int acpi_bus_add (acpi_handle handle); +int acpi_bus_scan (acpi_handle handle);void acpi_bus_hot_remove_device (void *context);int acpi_bus_trim (struct acpi_device *start);acpi_status acpi_bus_get_ejd (acpi_handle handle,acpi_handle * ejd);
drivers/acpi/processor_driver.c +1 -1
@@ -699,7 +699,7 @@ static void acpi_processor_hotplug_notifif (!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 ;
drivers/pci/hotplug/sgi_hotplug.c +2 -2
@@ -447,9 +447,9 @@ static int enable_slot(struct hotplug_slif (ACPI_SUCCESS (ret) && (adr>>16 ) == (slot->device_num +1 )) { - ret =acpi_bus_add (chandle); + ret =acpi_bus_scan (chandle);if (ACPI_FAILURE (ret)) { - printk(KERN_ERR "%s: acpi_bus_add " + printk(KERN_ERR "%s: acpi_bus_scan " "failed (0x%x) for slot %d " "func %d\n", __func__, ret, (int)(adr>>16),
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH] ACPI / scan: Drop acpi_bus_add() and use acpi_bus_scan() instead (was: Re: [PATCH] ACPI / scan: Fold acpi_bus_scan() into acpi_bus_add())
Quoted 15 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Subject: ACPI / scan: Dropacpi_bus_add()and useacpi_bus_scan()insteadThe only difference between
acpi_bus_scan()andacpi_bus_add()is the invocation ofacpi_update_all_gpes()in the latter which in fact is unnecessary, becauseacpi_update_all_gpes()has already been called byacpi_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 useacpi_bus_scan()directly instead of it. Additionally, rearrange the code inacpi_scan_init()slightly to improve the visibility of theacpi_update_all_gpes()call in there.Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 10 lines
--- drivers/acpi/acpi_memhotplug.c | 2 - drivers/acpi/container.c | 2 - drivers/acpi/dock.c | 2 - drivers/acpi/processor_driver.c | 2 - drivers/acpi/scan.c | 54 +++++++++++++++---------------------- drivers/pci/hotplug/acpiphp_glue.c | 4 +- drivers/pci/hotplug/sgi_hotplug.c | 4 +- include/acpi/acpi_bus.h | 2 - 8 files changed, 31 insertions(+), 41 deletions(-)