ACPI: scan: acpi_scan_init() updates
cover ACPI: scan: acpi_scan_init() updates
Hi All,
There are some minor defects in acpi_scan_init() and because recent changes cause static checkers to catch them, it is better to address them right away.
Please see patch changelogs for the details.
Thanks!
PATCH 1/3 ACPI: scan: Change acpi_scan_init() return value type to void
From: Rafael J. Wysocki <[email protected]>
The only caller of acpi_scan_init(), acpi_init(), doesn't check its return value, so turn it into a void function.
This avoids complaints from the Smatch static checker that the function should return a negative error code when it fails, which is not really a problem in this particular case.
No intentional functional impact.
--- drivers/acpi/internal.h | 2 +- drivers/acpi/scan.c | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/acpi/scan.c +3 -7
@@ -2513,9 +2513,8 @@ static void __init acpi_get_spcr_uart_adstatic bool acpi_scan_initialized; -int __init acpi_scan_init (void ) +void __init acpi_scan_init (void ) { -int result;acpi_status status;struct acpi_table_stao *stao_ptr;
@@ -2565,8 +2564,7 @@ int __init acpi_scan_init(void)/* * Enumerate devices in the ACPI namespace. */ - result =acpi_bus_scan (ACPI_ROOT_OBJECT ); -if (result) +if (acpi_bus_scan (ACPI_ROOT_OBJECT )) goto out; acpi_root =acpi_fetch_acpi_dev (ACPI_ROOT_OBJECT );
@@ -2575,8 +2573,7 @@ int __init acpi_scan_init(void)/* Fixed feature devices do not exist on HW-reduced platform */ if (!acpi_gbl_reduced_hardware) { - result =acpi_bus_scan_fixed (); -if (result) { +if (acpi_bus_scan_fixed ()) {acpi_detach_data (acpi_root->handle, acpi_scan_drop_device);acpi_device_del (acpi_root);
@@ -2591,7 +2588,6 @@ int __init acpi_scan_init(void) out:mutex_unlock (&acpi_scan_lock); -return result; }static struct acpi_probe_entry *ape;
drivers/acpi/internal.h +1 -1
@@ -14,7 +14,7 @@int early_acpi_osi_init (void );int acpi_osi_init (void );acpi_status acpi_os_initialize1 (void ); -int acpi_scan_init (void ); +void acpi_scan_init (void );#ifdef CONFIG_PCI void acpi_pci_root_init (void );void acpi_pci_link_init (void );
PATCH 2/3 ACPI: scan: Simplify initialization of power and sleep buttons
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
It should be perfectly fine to use ACPI if the "fixed" power or sleep buttons cannot be initialized. Moreover, running acpi_bus_scan() successfully on ACPI_ROOT_OBJECT generally causes many devices to be enumerated and probed, possibly including the entire PCI bus, so unregistering acpi_root if the registration of the "fixed" buttons fails is rather unhelpful.
For this reason, do not fail acpi_scan_init() when acpi_bus_scan_fixed() fails and turn the latter into a void function.
While at it, drop the outdated and misleading comment from acpi_bus_scan_fixed().
--- drivers/acpi/scan.c | 58 ++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 37 deletions(-)
drivers/acpi/scan.c +21 -37
@@ -2457,42 +2457,33 @@ int acpi_bus_register_early_device(int t }EXPORT_SYMBOL_GPL (acpi_bus_register_early_device); -static int acpi_bus_scan_fixed (void ) +static void acpi_bus_scan_fixed (void ) { -int result =0 ; - -/* -* Enumerate all fixed-feature devices. -*/ if (!(acpi_gbl_FADT.flags &ACPI_FADT_POWER_BUTTON )) { -struct acpi_device *device =NULL ; +struct acpi_device *adev =NULL ; - result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_POWER_BUTTON , false); -if (result) -return result; - - device->flags.match_driver = true; - result =device_attach (&device->dev); -if (result <0 ) -return result; - -device_init_wakeup (&device->dev, true); +acpi_add_single_object (&adev,NULL ,ACPI_BUS_TYPE_POWER_BUTTON , + false); +if (adev) { + adev->flags.match_driver = true; +if (device_attach (&adev->dev) >=0 ) +device_init_wakeup (&adev->dev, true); +else +dev_dbg (&adev->dev,"No driver\n" ); + } }if (!(acpi_gbl_FADT.flags &ACPI_FADT_SLEEP_BUTTON )) { -struct acpi_device *device =NULL ; +struct acpi_device *adev =NULL ; - result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_SLEEP_BUTTON , false); -if (result) -return result; - - device->flags.match_driver = true; - result =device_attach (&device->dev); +acpi_add_single_object (&adev,NULL ,ACPI_BUS_TYPE_SLEEP_BUTTON , + false); +if (adev) { + adev->flags.match_driver = true; +if (device_attach (&adev->dev) <0 ) +dev_dbg (&adev->dev,"No driver\n" ); + } } - -return result <0 ? result :0 ; }static void __init acpi_get_spcr_uart_addr (void )
@@ -2572,15 +2563,8 @@ void __init acpi_scan_init(void) goto out;/* Fixed feature devices do not exist on HW-reduced platform */ -if (!acpi_gbl_reduced_hardware) { -if (acpi_bus_scan_fixed ()) { -acpi_detach_data (acpi_root->handle, - acpi_scan_drop_device); -acpi_device_del (acpi_root); -acpi_bus_put_acpi_device (acpi_root); - goto out; - } - } +if (!acpi_gbl_reduced_hardware) +acpi_bus_scan_fixed ();acpi_turn_off_unused_power_resources ();
PATCH 3/3 ACPI: scan: Rename label in acpi_scan_init()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Rename the "out" label in acpi_scan_init() to "unlock", which is a better match for its purpose, and fix up the alignment.
No functional impact.
--- drivers/acpi/scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/scan.c +3 -3
@@ -2556,11 +2556,11 @@ void __init acpi_scan_init(void)* Enumerate devices in the ACPI namespace. */ if (acpi_bus_scan (ACPI_ROOT_OBJECT )) - goto out; + goto unlock; acpi_root =acpi_fetch_acpi_dev (ACPI_ROOT_OBJECT );if (!acpi_root) - goto out; + goto unlock;/* Fixed feature devices do not exist on HW-reduced platform */ if (!acpi_gbl_reduced_hardware)
@@ -2570,7 +2570,7 @@ void __init acpi_scan_init(void) acpi_scan_initialized = true; - out: +unlock:mutex_unlock (&acpi_scan_lock); }
Quoted 4 lines · Rafael J. Wysocki
Hi All,
There are some minor defects in
acpi_scan_init()and because recent changes cause static checkers to catch them, it is better to address them right away.
Looks good to me :)
Hi,
Quoted 6 lines · Rafael J. Wysocki
Hi All,
There are some minor defects in
acpi_scan_init()and because recent changes cause static checkers to catch them, it is better to address them right away.Please see patch changelogs for the details.
The entire series looks good to me:
for the series.
Regards,
Hans