* [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled()
@ 2026-08-05 4:03 Dmitry Torokhov
2026-08-05 14:51 ` Mark Pearson
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2026-08-05 4:03 UTC (permalink / raw)
To: Mark Pearson, Derek J. Clark
Cc: Henrique de Moraes Holschuh, Hans de Goede, Ilpo Järvinen,
Nitin Joshi, Andrzej Pietrasiewicz, platform-driver-x86,
ibm-acpi-devel, linux-kernel
From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Use the new helper. Inspecting input device's 'users' member needs to be
done under device's mutex, so add appropriate invocations.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Link: https://lore.kernel.org/r/20200608112211.12125-7-andrzej.p@collabora.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Not sure how this got stuck in my patch queue but it is still valid...
drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 445e1403308e..f8e116e8a65d 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -2547,9 +2547,10 @@ static void hotkey_poll_setup(const bool may_warn)
lockdep_assert_held(&hotkey_mutex);
+ mutex_lock(&tpacpi_inputdev->mutex);
if (hotkey_poll_freq > 0 &&
(poll_driver_mask ||
- (poll_user_mask && tpacpi_inputdev->users > 0))) {
+ (poll_user_mask && input_device_enabled(tpacpi_inputdev)))) {
if (!tpacpi_hotkey_task) {
tpacpi_hotkey_task = kthread_run(hotkey_kthread,
NULL, TPACPI_NVRAM_KTHREAD_NAME);
@@ -2566,6 +2567,7 @@ static void hotkey_poll_setup(const bool may_warn)
poll_user_mask, poll_driver_mask);
}
}
+ mutex_unlock(&tpacpi_inputdev->mutex);
}
static void hotkey_poll_setup_safe(const bool may_warn)
--
2.55.0.571.g244d577d93-goog
--
Dmitry
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled()
2026-08-05 4:03 [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled() Dmitry Torokhov
@ 2026-08-05 14:51 ` Mark Pearson
2026-08-05 15:52 ` Dmitry Torokhov
0 siblings, 1 reply; 5+ messages in thread
From: Mark Pearson @ 2026-08-05 14:51 UTC (permalink / raw)
To: Dmitry Torokhov, Derek J . Clark
Cc: Henrique de Moraes Holschuh, Hans de Goede, Ilpo Järvinen,
Nitin Joshi, Andrzej Pietrasiewicz,
platform-driver-x86@vger.kernel.org, ibm-acpi-devel, linux-kernel
On Wed, Aug 5, 2026, at 12:03 AM, Dmitry Torokhov wrote:
> From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>
> Use the new helper. Inspecting input device's 'users' member needs to be
> done under device's mutex, so add appropriate invocations.
>
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Link: https://lore.kernel.org/r/20200608112211.12125-7-andrzej.p@collabora.com
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>
> Not sure how this got stuck in my patch queue but it is still valid...
>
> drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 445e1403308e..f8e116e8a65d 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -2547,9 +2547,10 @@ static void hotkey_poll_setup(const bool
> may_warn)
>
> lockdep_assert_held(&hotkey_mutex);
>
> + mutex_lock(&tpacpi_inputdev->mutex);
> if (hotkey_poll_freq > 0 &&
> (poll_driver_mask ||
> - (poll_user_mask && tpacpi_inputdev->users > 0))) {
> + (poll_user_mask && input_device_enabled(tpacpi_inputdev)))) {
> if (!tpacpi_hotkey_task) {
> tpacpi_hotkey_task = kthread_run(hotkey_kthread,
> NULL, TPACPI_NVRAM_KTHREAD_NAME);
> @@ -2566,6 +2567,7 @@ static void hotkey_poll_setup(const bool may_warn)
> poll_user_mask, poll_driver_mask);
> }
> }
> + mutex_unlock(&tpacpi_inputdev->mutex);
> }
>
> static void hotkey_poll_setup_safe(const bool may_warn)
> --
Looks good to me.
Only note is that can you use guard(mutex)(&tpacpi_inputdev->mutex) instead of the lock/unlock? I think that's preferred these days.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled()
2026-08-05 14:51 ` Mark Pearson
@ 2026-08-05 15:52 ` Dmitry Torokhov
2026-08-05 16:15 ` Mark Pearson
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2026-08-05 15:52 UTC (permalink / raw)
To: Mark Pearson
Cc: Derek J . Clark, Henrique de Moraes Holschuh, Hans de Goede,
Ilpo Järvinen, Nitin Joshi, Andrzej Pietrasiewicz,
platform-driver-x86@vger.kernel.org, ibm-acpi-devel, linux-kernel
Hi Mark,
On Wed, Aug 05, 2026 at 10:51:53AM -0400, Mark Pearson wrote:
>
>
> On Wed, Aug 5, 2026, at 12:03 AM, Dmitry Torokhov wrote:
> > From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> >
> > Use the new helper. Inspecting input device's 'users' member needs to be
> > done under device's mutex, so add appropriate invocations.
> >
> > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> > Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> > Link: https://lore.kernel.org/r/20200608112211.12125-7-andrzej.p@collabora.com
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >
> > Not sure how this got stuck in my patch queue but it is still valid...
> >
> > drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> > b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> > index 445e1403308e..f8e116e8a65d 100644
> > --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> > +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> > @@ -2547,9 +2547,10 @@ static void hotkey_poll_setup(const bool
> > may_warn)
> >
> > lockdep_assert_held(&hotkey_mutex);
> >
> > + mutex_lock(&tpacpi_inputdev->mutex);
> > if (hotkey_poll_freq > 0 &&
> > (poll_driver_mask ||
> > - (poll_user_mask && tpacpi_inputdev->users > 0))) {
> > + (poll_user_mask && input_device_enabled(tpacpi_inputdev)))) {
> > if (!tpacpi_hotkey_task) {
> > tpacpi_hotkey_task = kthread_run(hotkey_kthread,
> > NULL, TPACPI_NVRAM_KTHREAD_NAME);
> > @@ -2566,6 +2567,7 @@ static void hotkey_poll_setup(const bool may_warn)
> > poll_user_mask, poll_driver_mask);
> > }
> > }
> > + mutex_unlock(&tpacpi_inputdev->mutex);
> > }
> >
> > static void hotkey_poll_setup_safe(const bool may_warn)
> > --
>
> Looks good to me.
>
> Only note is that can you use guard(mutex)(&tpacpi_inputdev->mutex) instead of the lock/unlock? I think that's preferred these days.
If that is desired the whole driver needs converting. I can do it in a
separate patch(es) if you want.
>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled()
2026-08-05 15:52 ` Dmitry Torokhov
@ 2026-08-05 16:15 ` Mark Pearson
2026-08-06 6:20 ` Dmitry Torokhov
0 siblings, 1 reply; 5+ messages in thread
From: Mark Pearson @ 2026-08-05 16:15 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Derek J . Clark, Henrique de Moraes Holschuh, Hans de Goede,
Ilpo Järvinen, Nitin Joshi, Andrzej Pietrasiewicz,
platform-driver-x86@vger.kernel.org, ibm-acpi-devel, linux-kernel
On Wed, Aug 5, 2026, at 11:52 AM, Dmitry Torokhov wrote:
> Hi Mark,
>
> On Wed, Aug 05, 2026 at 10:51:53AM -0400, Mark Pearson wrote:
>>
>>
>> On Wed, Aug 5, 2026, at 12:03 AM, Dmitry Torokhov wrote:
>> > From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>> >
>> > Use the new helper. Inspecting input device's 'users' member needs to be
>> > done under device's mutex, so add appropriate invocations.
>> >
>> > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
>> > Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
>> > Link: https://lore.kernel.org/r/20200608112211.12125-7-andrzej.p@collabora.com
>> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> > ---
>> >
>> > Not sure how this got stuck in my patch queue but it is still valid...
>> >
>> > drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +++-
>> > 1 file changed, 3 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> > b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> > index 445e1403308e..f8e116e8a65d 100644
>> > --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> > +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> > @@ -2547,9 +2547,10 @@ static void hotkey_poll_setup(const bool
>> > may_warn)
>> >
>> > lockdep_assert_held(&hotkey_mutex);
>> >
>> > + mutex_lock(&tpacpi_inputdev->mutex);
>> > if (hotkey_poll_freq > 0 &&
>> > (poll_driver_mask ||
>> > - (poll_user_mask && tpacpi_inputdev->users > 0))) {
>> > + (poll_user_mask && input_device_enabled(tpacpi_inputdev)))) {
>> > if (!tpacpi_hotkey_task) {
>> > tpacpi_hotkey_task = kthread_run(hotkey_kthread,
>> > NULL, TPACPI_NVRAM_KTHREAD_NAME);
>> > @@ -2566,6 +2567,7 @@ static void hotkey_poll_setup(const bool may_warn)
>> > poll_user_mask, poll_driver_mask);
>> > }
>> > }
>> > + mutex_unlock(&tpacpi_inputdev->mutex);
>> > }
>> >
>> > static void hotkey_poll_setup_safe(const bool may_warn)
>> > --
>>
>> Looks good to me.
>>
>> Only note is that can you use guard(mutex)(&tpacpi_inputdev->mutex) instead of the lock/unlock? I think that's preferred these days.
>
> If that is desired the whole driver needs converting. I can do it in a
> separate patch(es) if you want.
>
Ah - good point. Not worth it for this IMO, unless the more experienced maintainers have a strong opinion :)
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled()
2026-08-05 16:15 ` Mark Pearson
@ 2026-08-06 6:20 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2026-08-06 6:20 UTC (permalink / raw)
To: Mark Pearson
Cc: Derek J . Clark, Henrique de Moraes Holschuh, Hans de Goede,
Ilpo Järvinen, Nitin Joshi, Andrzej Pietrasiewicz,
platform-driver-x86@vger.kernel.org, ibm-acpi-devel, linux-kernel
On Wed, Aug 05, 2026 at 12:15:27PM -0400, Mark Pearson wrote:
>
>
> On Wed, Aug 5, 2026, at 11:52 AM, Dmitry Torokhov wrote:
> > Hi Mark,
> >
> > On Wed, Aug 05, 2026 at 10:51:53AM -0400, Mark Pearson wrote:
> >>
> >>
> >> On Wed, Aug 5, 2026, at 12:03 AM, Dmitry Torokhov wrote:
> >> > From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> >> >
> >> > Use the new helper. Inspecting input device's 'users' member needs to be
> >> > done under device's mutex, so add appropriate invocations.
> >> >
> >> > Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
> >> > Acked-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> >> > Link: https://lore.kernel.org/r/20200608112211.12125-7-andrzej.p@collabora.com
> >> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >> > ---
> >> >
> >> > Not sure how this got stuck in my patch queue but it is still valid...
> >> >
> >> > drivers/platform/x86/lenovo/thinkpad_acpi.c | 4 +++-
> >> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> >> > b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> >> > index 445e1403308e..f8e116e8a65d 100644
> >> > --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> >> > +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> >> > @@ -2547,9 +2547,10 @@ static void hotkey_poll_setup(const bool
> >> > may_warn)
> >> >
> >> > lockdep_assert_held(&hotkey_mutex);
> >> >
> >> > + mutex_lock(&tpacpi_inputdev->mutex);
> >> > if (hotkey_poll_freq > 0 &&
> >> > (poll_driver_mask ||
> >> > - (poll_user_mask && tpacpi_inputdev->users > 0))) {
> >> > + (poll_user_mask && input_device_enabled(tpacpi_inputdev)))) {
> >> > if (!tpacpi_hotkey_task) {
> >> > tpacpi_hotkey_task = kthread_run(hotkey_kthread,
> >> > NULL, TPACPI_NVRAM_KTHREAD_NAME);
> >> > @@ -2566,6 +2567,7 @@ static void hotkey_poll_setup(const bool may_warn)
> >> > poll_user_mask, poll_driver_mask);
> >> > }
> >> > }
> >> > + mutex_unlock(&tpacpi_inputdev->mutex);
> >> > }
> >> >
> >> > static void hotkey_poll_setup_safe(const bool may_warn)
> >> > --
> >>
> >> Looks good to me.
> >>
> >> Only note is that can you use guard(mutex)(&tpacpi_inputdev->mutex) instead of the lock/unlock? I think that's preferred these days.
> >
> > If that is desired the whole driver needs converting. I can do it in a
> > separate patch(es) if you want.
> >
> Ah - good point. Not worth it for this IMO, unless the more experienced maintainers have a strong opinion :)
Well, I went and did it anyways in case you want to apply it.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-06 6:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 4:03 [PATCH] platform/x86: thinkpad_acpi: Use input_device_enabled() Dmitry Torokhov
2026-08-05 14:51 ` Mark Pearson
2026-08-05 15:52 ` Dmitry Torokhov
2026-08-05 16:15 ` Mark Pearson
2026-08-06 6:20 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox