From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH v1 02/15] ACPI: button: Pass ACPI handle to acpi_lid_evaluate_state()
Date: Mon, 01 Jun 2026 18:55:53 +0200 [thread overview]
Message-ID: <4747530.LvFx2qVVIh@rafael.j.wysocki> (raw)
In-Reply-To: <12913564.O9o76ZdvQC@rafael.j.wysocki>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Make it clear that acpi_lid_evaluate_state() only uses the ACPI handle
of the lid by changing its argument to acpi_handle and adjust its
callers accordingly.
Also save the ACPI handle of the lid, that later may be passed to
acpi_lid_evaluate_state(), in a static variable instead of saving a
pointer to the ACPI device object containing that handle.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/button.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 5df470eea754..0b96db762bea 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -192,12 +192,12 @@ MODULE_PARM_DESC(lid_report_interval, "Interval (ms) between lid key events");
static struct proc_dir_entry *acpi_button_dir;
static struct proc_dir_entry *acpi_lid_dir;
-static int acpi_lid_evaluate_state(struct acpi_device *device)
+static int acpi_lid_evaluate_state(acpi_handle lid_handle)
{
unsigned long long lid_state;
acpi_status status;
- status = acpi_evaluate_integer(device->handle, "_LID", NULL, &lid_state);
+ status = acpi_evaluate_integer(lid_handle, "_LID", NULL, &lid_state);
if (ACPI_FAILURE(status))
return -ENODEV;
@@ -292,7 +292,7 @@ static int __maybe_unused acpi_button_state_seq_show(struct seq_file *seq,
struct acpi_button *button = seq->private;
int state;
- state = acpi_lid_evaluate_state(button->adev);
+ state = acpi_lid_evaluate_state(button->adev->handle);
seq_printf(seq, "state: %s\n",
state < 0 ? "unsupported" : (state ? "open" : "closed"));
return 0;
@@ -377,22 +377,22 @@ static int acpi_button_remove_fs(struct acpi_button *button)
return 0;
}
-static struct acpi_device *lid_device;
+static acpi_handle saved_lid_handle;
static DEFINE_MUTEX(acpi_lid_lock);
static void acpi_lid_save(struct acpi_device *adev)
{
guard(mutex)(&acpi_lid_lock);
- lid_device = adev;
+ saved_lid_handle = adev->handle;
}
static void acpi_lid_forget(struct acpi_device *adev)
{
guard(mutex)(&acpi_lid_lock);
- if (lid_device == adev)
- lid_device = NULL;
+ if (saved_lid_handle == adev->handle)
+ saved_lid_handle = NULL;
}
/* Driver Interface */
@@ -400,20 +400,19 @@ int acpi_lid_open(void)
{
guard(mutex)(&acpi_lid_lock);
- if (!lid_device)
+ if (!saved_lid_handle)
return -ENODEV;
- return acpi_lid_evaluate_state(lid_device);
+ return acpi_lid_evaluate_state(saved_lid_handle);
}
EXPORT_SYMBOL(acpi_lid_open);
static int acpi_lid_update_state(struct acpi_button *button,
bool signal_wakeup)
{
- struct acpi_device *device = button->adev;
int state;
- state = acpi_lid_evaluate_state(device);
+ state = acpi_lid_evaluate_state(button->adev->handle);
if (state < 0)
return state;
@@ -516,12 +515,11 @@ static int acpi_button_suspend(struct device *dev)
static int acpi_button_resume(struct device *dev)
{
struct acpi_button *button = dev_get_drvdata(dev);
- struct acpi_device *device = ACPI_COMPANION(dev);
struct input_dev *input;
button->suspended = false;
if (button->type == ACPI_BUTTON_TYPE_LID) {
- button->last_state = !!acpi_lid_evaluate_state(device);
+ button->last_state = !!acpi_lid_evaluate_state(ACPI_HANDLE(dev));
button->last_time = ktime_get();
acpi_lid_initialize_state(button);
}
@@ -540,9 +538,8 @@ static int acpi_button_resume(struct device *dev)
static int acpi_lid_input_open(struct input_dev *input)
{
struct acpi_button *button = input_get_drvdata(input);
- struct acpi_device *device = button->adev;
- button->last_state = !!acpi_lid_evaluate_state(device);
+ button->last_state = !!acpi_lid_evaluate_state(button->adev->handle);
button->last_time = ktime_get();
acpi_lid_initialize_state(button);
--
2.51.0
next prev parent reply other threads:[~2026-06-01 17:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 16:53 [PATCH v1 00/15] ACPI: button: Cleanups and conversion to using devm Rafael J. Wysocki
2026-06-01 16:55 ` [PATCH v1 01/15] ACPI: button: Fix lid_device value leak past driver removal Rafael J. Wysocki
2026-06-01 16:55 ` Rafael J. Wysocki [this message]
2026-06-01 16:56 ` [PATCH v1 03/15] ACPI: button: Improve warning message regarding lid state Rafael J. Wysocki
2026-06-01 16:58 ` [PATCH v1 04/15] ACPI: button: Use bool for representing boolean values Rafael J. Wysocki
2026-06-01 16:59 ` [PATCH v1 05/15] ACPI: button: Eliminate ternary operator from acpi_lid_evaluate_state() Rafael J. Wysocki
2026-06-01 17:00 ` [PATCH v1 06/15] ACPI: button: Change return type of two functions to void Rafael J. Wysocki
2026-06-01 17:00 ` [PATCH v1 07/15] ACPI: button: Eliminate redundant conditional statement Rafael J. Wysocki
2026-06-01 17:01 ` [PATCH v1 08/15] ACPI: button: Use local pointer to platform device dev field in probe Rafael J. Wysocki
2026-06-01 17:03 ` [PATCH v1 09/15] ACPI: button: Rework device verification during probe Rafael J. Wysocki
2026-06-01 17:04 ` [PATCH v1 10/15] ACPI: button: Drop redundant variable from acpi_button_probe() Rafael J. Wysocki
2026-06-01 17:05 ` [PATCH v1 11/15] ACPI: button: Merge two switch () statements in acpi_button_probe() Rafael J. Wysocki
2026-06-01 17:07 ` [PATCH v1 12/15] ACPI: button: Clean up adding and removing lid procfs interface Rafael J. Wysocki
2026-06-01 17:07 ` [PATCH v1 13/15] ACPI: button: Use string literals for generating netlink messages Rafael J. Wysocki
2026-06-01 17:12 ` [PATCH v1 14/15] ACPI: button: Reorganize installing and removing event handlers Rafael J. Wysocki
2026-06-01 17:12 ` [PATCH v1 15/15] ACPI: button: Switch over to devres-based resource management Rafael J. Wysocki
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=4747530.LvFx2qVVIh@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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