* [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates
@ 2022-01-11 16:45 Rafael J. Wysocki
2022-01-11 16:50 ` [PATCH v1 1/3] ACPI: scan: Change acpi_scan_init() return value type to void Rafael J. Wysocki
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 16:45 UTC (permalink / raw)
To: Linux ACPI; +Cc: LKML, Andy Shevchenko, Mika Westerberg, Hans de Goede
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!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/3] ACPI: scan: Change acpi_scan_init() return value type to void
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
@ 2022-01-11 16:50 ` Rafael J. Wysocki
2022-01-11 16:52 ` [PATCH v1 2/3] ACPI: scan: Simplify initialization of power and sleep buttons Rafael J. Wysocki
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 16:50 UTC (permalink / raw)
To: Linux ACPI
Cc: LKML, Andy Shevchenko, Mika Westerberg, Hans de Goede, Dan Carpenter
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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.
Link: https://lore.kernel.org/linux-acpi/20220106082317.GA9123@kili/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/internal.h | 2 +-
drivers/acpi/scan.c | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -2513,9 +2513,8 @@ static void __init acpi_get_spcr_uart_ad
static 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;
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -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);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 2/3] ACPI: scan: Simplify initialization of power and sleep buttons
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
2022-01-11 16:50 ` [PATCH v1 1/3] ACPI: scan: Change acpi_scan_init() return value type to void Rafael J. Wysocki
@ 2022-01-11 16:52 ` Rafael J. Wysocki
2022-01-11 16:53 ` [PATCH v1 3/3] ACPI: scan: Rename label in acpi_scan_init() Rafael J. Wysocki
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 16:52 UTC (permalink / raw)
To: Linux ACPI; +Cc: LKML, Andy Shevchenko, Mika Westerberg, Hans de Goede
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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().
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/scan.c | 58 ++++++++++++++++++----------------------------------
1 file changed, 21 insertions(+), 37 deletions(-)
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -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();
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 3/3] ACPI: scan: Rename label in acpi_scan_init()
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
2022-01-11 16:50 ` [PATCH v1 1/3] ACPI: scan: Change acpi_scan_init() return value type to void Rafael J. Wysocki
2022-01-11 16:52 ` [PATCH v1 2/3] ACPI: scan: Simplify initialization of power and sleep buttons Rafael J. Wysocki
@ 2022-01-11 16:53 ` Rafael J. Wysocki
2022-01-12 7:14 ` [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Mika Westerberg
2022-01-12 12:33 ` Hans de Goede
4 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-01-11 16:53 UTC (permalink / raw)
To: Linux ACPI; +Cc: LKML, Andy Shevchenko, Mika Westerberg, Hans de Goede
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/scan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -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);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
` (2 preceding siblings ...)
2022-01-11 16:53 ` [PATCH v1 3/3] ACPI: scan: Rename label in acpi_scan_init() Rafael J. Wysocki
@ 2022-01-12 7:14 ` Mika Westerberg
2022-01-12 12:33 ` Hans de Goede
4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2022-01-12 7:14 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Linux ACPI, LKML, Andy Shevchenko, Hans de Goede
On Tue, Jan 11, 2022 at 05:45:23PM +0100, Rafael J. Wysocki wrote:
> 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 :)
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
` (3 preceding siblings ...)
2022-01-12 7:14 ` [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Mika Westerberg
@ 2022-01-12 12:33 ` Hans de Goede
4 siblings, 0 replies; 6+ messages in thread
From: Hans de Goede @ 2022-01-12 12:33 UTC (permalink / raw)
To: Rafael J. Wysocki, Linux ACPI; +Cc: LKML, Andy Shevchenko, Mika Westerberg
Hi,
On 1/11/22 17:45, Rafael J. Wysocki wrote:
> 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:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
for the series.
Regards,
Hans
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-12 12:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 16:45 [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Rafael J. Wysocki
2022-01-11 16:50 ` [PATCH v1 1/3] ACPI: scan: Change acpi_scan_init() return value type to void Rafael J. Wysocki
2022-01-11 16:52 ` [PATCH v1 2/3] ACPI: scan: Simplify initialization of power and sleep buttons Rafael J. Wysocki
2022-01-11 16:53 ` [PATCH v1 3/3] ACPI: scan: Rename label in acpi_scan_init() Rafael J. Wysocki
2022-01-12 7:14 ` [PATCH v1 0/3] ACPI: scan: acpi_scan_init() updates Mika Westerberg
2022-01-12 12:33 ` Hans de Goede
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.