From: surirajat@gmail.com
To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
ibm-acpi-devel@lists.sourceforge.net, markpearson@lenovo.com,
hdegoede@redhat.com, rajat.suri@dell.com
Subject: [PATCH] platform/x86: lenovo: convert mutex_init() users to devm_mutex_init()
Date: Mon, 2 Nov 2026 19:22:15 +0530 [thread overview]
Message-ID: <20261102135215.352680-1-surirajat@gmail.com> (raw)
From: Rajat Suri <rajat.suri@dell.com>
Convert the mutex_init() calls in thinkpad_acpi to devm_mutex_init()
so that the mutex lifecycle is managed by devres.
This fixes thinkpad_acpi, which never destroyed the hotkey, brightness,
volume and fan mutexes on its teardown path.
Per feedback, the patch now covers only driver code for hardware validated so far.
Details per driver:
- thinkpad_acpi: bind the hotkey, hotkey thread data, brightness, volume
and fan mutexes to tpacpi_pdev, which is registered before any
subdriver init runs, and propagate a possible failure from
devm_mutex_init().
No functional change intended.
Signed-off-by: Rajat Suri <rajat.suri@dell.com>
---
drivers/platform/x86/lenovo/thinkpad_acpi.c | 22 ++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 4f81855ad721..0fc105fc28d0 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -3381,10 +3381,14 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
tpacpi_inputdev->close != NULL);
TPACPI_ACPIHANDLE_INIT(hkey);
- mutex_init(&hotkey_mutex);
+ res = devm_mutex_init(&tpacpi_pdev->dev, &hotkey_mutex);
+ if (res)
+ return res;
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
- mutex_init(&hotkey_thread_data_mutex);
+ res = devm_mutex_init(&tpacpi_pdev->dev, &hotkey_thread_data_mutex);
+ if (res)
+ return res;
#endif
/* hotkey not supported on 570 */
@@ -6830,11 +6834,14 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
{
struct backlight_properties props;
int b;
+ int ret;
unsigned long quirks;
vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
- mutex_init(&brightness_mutex);
+ ret = devm_mutex_init(&tpacpi_pdev->dev, &brightness_mutex);
+ if (ret)
+ return ret;
quirks = tpacpi_check_quirks(brightness_quirk_table,
ARRAY_SIZE(brightness_quirk_table));
@@ -7575,7 +7582,9 @@ static int __init volume_init(struct ibm_init_struct *iibm)
vdbg_printk(TPACPI_DBG_INIT, "initializing volume subdriver\n");
- mutex_init(&volume_mutex);
+ rc = devm_mutex_init(&tpacpi_pdev->dev, &volume_mutex);
+ if (rc)
+ return rc;
/*
* Check for module parameter bogosity, note that we
@@ -8913,11 +8922,14 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = {
static int __init fan_init(struct ibm_init_struct *iibm)
{
unsigned long quirks;
+ int ret;
vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_FAN,
"initializing fan subdriver\n");
- mutex_init(&fan_mutex);
+ ret = devm_mutex_init(&tpacpi_pdev->dev, &fan_mutex);
+ if (ret)
+ return ret;
fan_status_access_mode = TPACPI_FAN_NONE;
fan_control_access_mode = TPACPI_FAN_WR_NONE;
fan_control_commands = 0;
--
2.43.0
next reply other threads:[~2026-11-02 13:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 13:52 surirajat [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-30 13:54 surirajat
2026-10-30 14:03 ` Ilpo Järvinen
2026-10-31 1:04 ` Mark Pearson
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=20261102135215.352680-1-surirajat@gmail.com \
--to=surirajat@gmail.com \
--cc=hansg@kernel.org \
--cc=hdegoede@redhat.com \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markpearson@lenovo.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rajat.suri@dell.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
all inboxes | Powered by JetHome®