2022-06-06 14:02:08

by Li Qiong

[permalink] [raw]
Subject: [PATCH 1/2] HID: intel-ish-hid: ipc: use time_before to replace "jiffies < a"

time_before deals with timer wrapping correctly.

Signed-off-by: Li Qiong <[email protected]>
---
drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
index 8ccb246b0114..15e14239af82 100644
--- a/drivers/hid/intel-ish-hid/ipc/ipc.c
+++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
@@ -578,7 +578,7 @@ static void _ish_sync_fw_clock(struct ishtp_device *dev)
static unsigned long prev_sync;
uint64_t usec;

- if (prev_sync && jiffies - prev_sync < 20 * HZ)
+ if (prev_sync && time_before(jiffies, prev_sync + 20 * HZ))
return;

prev_sync = jiffies;
--
2.25.1


2022-06-08 05:05:29

by Pandruvada, Srinivas

[permalink] [raw]
Subject: Re: [PATCH 1/2] HID: intel-ish-hid: ipc: use time_before to replace "jiffies < a"

On Mon, 2022-06-06 at 21:47 +0800, Li Qiong wrote:
> time_before deals with timer wrapping correctly.
>
> Signed-off-by: Li Qiong <[email protected]>
Acked-by: Srinivas Pandruvada <[email protected]>

> ---
>  drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-
> ish-hid/ipc/ipc.c
> index 8ccb246b0114..15e14239af82 100644
> --- a/drivers/hid/intel-ish-hid/ipc/ipc.c
> +++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
> @@ -578,7 +578,7 @@ static void _ish_sync_fw_clock(struct
> ishtp_device *dev)
>         static unsigned long    prev_sync;
>         uint64_t        usec;
>  
> -       if (prev_sync && jiffies - prev_sync < 20 * HZ)
> +       if (prev_sync && time_before(jiffies, prev_sync + 20 * HZ))
>                 return;
>  
>         prev_sync = jiffies;

2022-06-08 11:38:48

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH 1/2] HID: intel-ish-hid: ipc: use time_before to replace "jiffies < a"

On Mon, 6 Jun 2022, Li Qiong wrote:

> time_before deals with timer wrapping correctly.
>
> Signed-off-by: Li Qiong <[email protected]>
> ---
> drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
> index 8ccb246b0114..15e14239af82 100644
> --- a/drivers/hid/intel-ish-hid/ipc/ipc.c
> +++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
> @@ -578,7 +578,7 @@ static void _ish_sync_fw_clock(struct ishtp_device *dev)
> static unsigned long prev_sync;
> uint64_t usec;
>
> - if (prev_sync && jiffies - prev_sync < 20 * HZ)
> + if (prev_sync && time_before(jiffies, prev_sync + 20 * HZ))
> return;

Applied, thanks.

--
Jiri Kosina
SUSE Labs