From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: "Linux PM" <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Mika Westerberg" <mika.westerberg@linux.intel.com>,
"Peixin Xie" <peixin.xie@linux.spacemit.com>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Lukas Wunner" <lukas@wunner.de>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Linux PCI" <linux-pci@vger.kernel.org>,
"Bjorn Helgaas" <helgaas@kernel.org>,
"Hans de Goede" <hansg@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 2/7] ACPI: PM: Introduce acpi_device_init_power()
Date: Mon, 31 Aug 2026 18:25:52 +0200 [thread overview]
Message-ID: <2055986.PYKUYFuaPT@rafael.j.wysocki> (raw)
In-Reply-To: <3435655.aeNJFYEL58@rafael.j.wysocki>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Two out of three callers of acpi_bus_init_power() need to clear
flags.power_manageable for the target device on errors, which
is somewhat cumbersome, so rename the function to
__acpi_device_init_power(), add a wrapper called
acpi_device_init_power() around it that will take care
of the flags.power_manageable clearing, and make the two
callers of acpi_bus_init_power() in question invoke that
wrapper.
While at it, clean up the declaration of local variables
in __acpi_device_init_power().
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/device_pm.c | 22 +++++++++++++++-------
drivers/acpi/scan.c | 5 ++---
include/acpi/acpi_bus.h | 2 +-
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index a680e6972a8c..7fd780125177 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -169,10 +169,8 @@ int acpi_device_set_power(struct acpi_device *device, int state)
return -EINVAL;
if (device->power.state == ACPI_STATE_UNKNOWN &&
- acpi_bus_init_power(device)) {
- device->flags.power_manageable = 0;
+ acpi_device_init_power(device))
return -ENODEV;
- }
acpi_handle_debug(device->handle, "Power state change: %s -> %s\n",
acpi_power_state_string(device->power.state),
@@ -310,10 +308,9 @@ int acpi_bus_set_power(acpi_handle handle, int state)
}
EXPORT_SYMBOL(acpi_bus_set_power);
-int acpi_bus_init_power(struct acpi_device *device)
+static int __acpi_device_init_power(struct acpi_device *device)
{
- int state;
- int result;
+ int result, state;
result = acpi_device_get_power(device, &state);
if (result)
@@ -355,6 +352,17 @@ int acpi_bus_init_power(struct acpi_device *device)
return 0;
}
+int acpi_device_init_power(struct acpi_device *device)
+{
+ int ret;
+
+ ret = __acpi_device_init_power(device);
+ if (ret)
+ device->flags.power_manageable = 0;
+
+ return ret;
+}
+
/**
* acpi_device_fix_up_power - Force device with missing _PSC into D0.
* @device: Device object whose power state is to be fixed up.
@@ -417,7 +425,7 @@ int acpi_device_update_power(struct acpi_device *device, int *state_p)
int result;
if (device->power.state == ACPI_STATE_UNKNOWN) {
- result = acpi_bus_init_power(device);
+ result = __acpi_device_init_power(device);
if (!result && state_p)
*state_p = device->power.state;
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 1ad8dffc2daf..5aa3ecb000e1 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -2362,9 +2362,8 @@ static int acpi_bus_attach(struct acpi_device *device, void *first_pass)
acpi_ec_register_opregions(device);
if (device->flags.power_manageable &&
- device->power.state == ACPI_STATE_UNKNOWN &&
- acpi_bus_init_power(device))
- device->flags.power_manageable = 0;
+ device->power.state == ACPI_STATE_UNKNOWN)
+ acpi_device_init_power(device);
if (device->flags.visited)
goto ok;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 1a45e0d521d8..b0d9057ccb8a 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -618,7 +618,7 @@ int acpi_bus_get_status(struct acpi_device *device);
int acpi_bus_set_power(acpi_handle handle, int state);
const char *acpi_power_state_string(int state);
int acpi_device_set_power(struct acpi_device *device, int state);
-int acpi_bus_init_power(struct acpi_device *device);
+int acpi_device_init_power(struct acpi_device *device);
int acpi_device_fix_up_power(struct acpi_device *device);
void acpi_device_fix_up_power_extended(struct acpi_device *adev);
void acpi_device_fix_up_power_children(struct acpi_device *adev);
--
2.51.0
next prev parent reply other threads:[~2026-08-31 18:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 16:20 [PATCH v1 0/7] ACPI: scan: Address power management initialization and PCI devices handling Rafael J. Wysocki
2026-08-31 16:24 ` [PATCH v1 1/7] ACPI: scan: Stop calling acpi_bus_init_power() early Rafael J. Wysocki
2026-09-01 8:27 ` Andy Shevchenko
2026-08-31 16:25 ` Rafael J. Wysocki [this message]
2026-09-01 8:29 ` [PATCH v1 2/7] ACPI: PM: Introduce acpi_device_init_power() Andy Shevchenko
2026-09-01 16:38 ` Rafael J. Wysocki (Intel)
2026-08-31 17:59 ` [PATCH v1 3/7] ACPI: bus: Drop initialized flag from struct acpi_device_flags Rafael J. Wysocki
2026-08-31 17:59 ` [PATCH v1 4/7] ACPI: scan: Combine two conditionals in acpi_bus_attach() Rafael J. Wysocki
2026-09-01 8:40 ` Andy Shevchenko
2026-09-01 19:11 ` Rafael J. Wysocki (Intel)
2026-08-31 17:59 ` [PATCH v1 5/7] ACPI: scan: Add ACPI device "enumerated" marker Rafael J. Wysocki
2026-08-31 17:59 ` [PATCH v1 6/7] ACPI: scan: Adjust and rename acpi_bus_attach() Rafael J. Wysocki
2026-08-31 17:59 ` [PATCH v1 7/7] ACPI: scan: Take PCI device enumeration into account directly Rafael J. Wysocki
2026-09-01 8:44 ` Andy Shevchenko
2026-09-01 19:14 ` Rafael J. Wysocki (Intel)
2026-09-02 12:42 ` [PATCH v1 0/7] ACPI: scan: Address power management initialization and PCI devices handling Peixin Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2055986.PYKUYFuaPT@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hansg@kernel.org \
--cc=helgaas@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mika.westerberg@linux.intel.com \
--cc=peixin.xie@linux.spacemit.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox