mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: amd_sfh: return an error when response wait times out
@ 2026-06-24 14:35 Pengpeng Hou
  2026-08-03 17:29 ` Jiri Kosina
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pengpeng Hou @ 2026-06-24 14:35 UTC (permalink / raw)
  To: Basavaraj Natikar, Jiri Kosina, Benjamin Tissoires
  Cc: Pengpeng Hou, linux-input, linux-kernel

amdtp_wait_for_response() waits for request_done before completing a
report request. wait_event_interruptible_timeout() returns 0 when the
wait expires, but the current code treats only negative values as errors
and returns success on timeout.

Return -ETIMEDOUT when the response wait expires while preserving the
existing success path when the response has already been observed.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
index b04f675d4..8f88f965f 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
@@ -87,16 +87,17 @@ static int amdtp_wait_for_response(struct hid_device *hid)
 			break;
 	}
 
-	if (!cli_data->request_done[i])
+	if (!cli_data->request_done[i]) {
 		ret = wait_event_interruptible_timeout(hid_data->hid_wait,
 						       cli_data->request_done[i],
 						       msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
-	if (ret == -ERESTARTSYS)
-		return -ERESTARTSYS;
-	else if (ret < 0)
-		return -ETIMEDOUT;
-	else
-		return 0;
+		if (ret == -ERESTARTSYS)
+			return -ERESTARTSYS;
+		if (ret <= 0)
+			return -ETIMEDOUT;
+	}
+
+	return 0;
 }
 
 void amdtp_hid_wakeup(struct hid_device *hid)
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: amd_sfh: return an error when response wait times out
  2026-06-24 14:35 [PATCH] HID: amd_sfh: return an error when response wait times out Pengpeng Hou
@ 2026-08-03 17:29 ` Jiri Kosina
  2026-08-03 17:36 ` Basavaraj Natikar
  2026-08-03 17:38 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2026-08-03 17:29 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Basavaraj Natikar, Benjamin Tissoires, linux-input, linux-kernel

On Wed, 24 Jun 2026, Pengpeng Hou wrote:

> amdtp_wait_for_response() waits for request_done before completing a
> report request. wait_event_interruptible_timeout() returns 0 when the
> wait expires, but the current code treats only negative values as errors
> and returns success on timeout.
> 
> Return -ETIMEDOUT when the response wait expires while preserving the
> existing success path when the response has already been observed.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>

Basavaraj, could you please review/ack this?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: amd_sfh: return an error when response wait times out
  2026-06-24 14:35 [PATCH] HID: amd_sfh: return an error when response wait times out Pengpeng Hou
  2026-08-03 17:29 ` Jiri Kosina
@ 2026-08-03 17:36 ` Basavaraj Natikar
  2026-08-03 17:38 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Basavaraj Natikar @ 2026-08-03 17:36 UTC (permalink / raw)
  To: Pengpeng Hou, Basavaraj Natikar, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel


On 6/24/2026 8:05 PM, Pengpeng Hou wrote:
> [You don't often get email from pengpeng@iscas.ac.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> amdtp_wait_for_response() waits for request_done before completing a
> report request. wait_event_interruptible_timeout() returns 0 when the
> wait expires, but the current code treats only negative values as errors
> and returns success on timeout.
>
> Return -ETIMEDOUT when the response wait expires while preserving the
> existing success path when the response has already been observed.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
>   drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> index b04f675d4..8f88f965f 100644
> --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c
> @@ -87,16 +87,17 @@ static int amdtp_wait_for_response(struct hid_device *hid)
>                          break;
>          }
>
> -       if (!cli_data->request_done[i])
> +       if (!cli_data->request_done[i]) {
>                  ret = wait_event_interruptible_timeout(hid_data->hid_wait,
>                                                         cli_data->request_done[i],
>                                                         msecs_to_jiffies(AMD_SFH_RESPONSE_TIMEOUT));
> -       if (ret == -ERESTARTSYS)
> -               return -ERESTARTSYS;
> -       else if (ret < 0)
> -               return -ETIMEDOUT;
> -       else
> -               return 0;
> +               if (ret == -ERESTARTSYS)
> +                       return -ERESTARTSYS;
> +               if (ret <= 0)
> +                       return -ETIMEDOUT;
> +       }
> +
> +       return 0;
>   }

Acked-by: Basavaraj Natikar<Basavaraj.Natikar@amd.com>

Thanks,
--
Basavaraj

>
>   void amdtp_hid_wakeup(struct hid_device *hid)
> --
> 2.50.1 (Apple Git-155)
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] HID: amd_sfh: return an error when response wait times out
  2026-06-24 14:35 [PATCH] HID: amd_sfh: return an error when response wait times out Pengpeng Hou
  2026-08-03 17:29 ` Jiri Kosina
  2026-08-03 17:36 ` Basavaraj Natikar
@ 2026-08-03 17:38 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2026-08-03 17:38 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Basavaraj Natikar, Benjamin Tissoires, linux-input, linux-kernel

On Wed, 24 Jun 2026, Pengpeng Hou wrote:

> amdtp_wait_for_response() waits for request_done before completing a
> report request. wait_event_interruptible_timeout() returns 0 when the
> wait expires, but the current code treats only negative values as errors
> and returns success on timeout.
> 
> Return -ETIMEDOUT when the response wait expires while preserving the
> existing success path when the response has already been observed.

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-03 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-24 14:35 [PATCH] HID: amd_sfh: return an error when response wait times out Pengpeng Hou
2026-08-03 17:29 ` Jiri Kosina
2026-08-03 17:36 ` Basavaraj Natikar
2026-08-03 17:38 ` Jiri Kosina

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®