use time_is_{before,after}_jiffies() instead of open coding it
Subsystems (13)
v3 cover use time_is_{before,after}_jiffies() instead of open coding it
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
V2:
Batch them in a series suggested by Joe.
Use time_xxx_jiffies() instead of time_xxx() suggested by Kieran.
V3:
Fix subject and description suggested by Ted.
Wang Qing (14):
block: xen: use time_is_before_eq_jiffies() instead of open coding it
clk: mvebu: use time_is_before_eq_jiffies() instead of open coding it
gpu: drm: i915: use time_is_after_jiffies() instead of open coding it
gpu: drm: radeon: use time_is_before_jiffies() instead open coding it
hid: use time_is_after_jiffies() instead of open coding it
input: serio: use time_is_before_jiffies() instead of open coding it
md: use time_is_before_jiffies(() instead of open coding it
md: use time_is_before_eq_jiffies() instead of open coding it
media: si21xx: use time_is_before_jiffies() instead of open coding it
media: stv0299: use time_is_before_jiffies() instead of open coding it
media: tda8083: use time_is_after_jiffies() instead of open coding it
media: wl128x: use time_is_before_jiffies() instead of open coding it
media: vivid: use time_is_after_jiffies() instead of open coding it
drivers/block/xen-blkback/blkback.c | 5 +++-- drivers/clk/mvebu/armada-37xx-periph.c | 3 ++- drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c | 2 +- drivers/gpu/drm/radeon/radeon_pm.c | 3 ++- drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +- drivers/input/serio/ps2-gpio.c | 4 ++-- drivers/md/dm-thin.c | 2 +- drivers/md/dm-writecache.c | 5 +++-- drivers/media/dvb-frontends/si21xx.c | 2 +- drivers/media/dvb-frontends/stv0299.c | 4 ++-- drivers/media/dvb-frontends/tda8083.c | 2 +- drivers/media/radio/wl128x/fmdrv_common.c | 3 ++- drivers/media/test-drivers/vivid/vivid-kthread-cap.c | 3 ++- drivers/media/test-drivers/vivid/vivid-kthread-out.c | 3 ++- drivers/media/test-drivers/vivid/vivid-kthread-touch.c | 3 ++- drivers/media/test-drivers/vivid/vivid-sdr-cap.c | 3 ++- 17 files changed, 31 insertions(+), 22 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/13 block: xen: use time_is_before_eq_jiffies() instead of open coding it
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/block/xen-blkback/blkback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/block/xen-blkback/blkback.c +3 -2
@@ -42,6 +42,7 @@#include <linux/delay.h> #include <linux/freezer.h> #include <linux/bitmap.h> +#include <linux/jiffies.h> #include <xen/events.h> #include <xen/page.h>
@@ -134,8 +135,8 @@ module_param(log_stats, int, 0644);static inline bool persistent_gnt_timeout (struct persistent_gnt *persistent_gnt) { -return pgrant_timeout && (jiffies - persistent_gnt->last_used >= -HZ * pgrant_timeout); +return pgrant_timeout &&time_is_before_eq_jiffies ( + persistent_gnt->last_used +HZ * pgrant_timeout); }#define vaddr (page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
Signature · 1 line
2.7.4
Re: [PATCH V3 1/13] block: xen: use time_is_before_eq_jiffies() instead of open coding it
Quoted 6 lines · Qing Wang
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>
Thanks, Roger.
PATCH v3 2/13 clk: mvebu: use time_is_before_eq_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/clk/mvebu/armada-37xx-periph.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/mvebu/armada-37xx-periph.c +2 -1
@@ -25,6 +25,7 @@#include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/slab.h> +#include <linux/jiffies.h> #define TBG_SEL 0x0#define DIV_SEL0 0x4
@@ -541,7 +542,7 @@ static void clk_pm_cpu_set_rate_wa(struct clk_pm_cpu *pm_cpu,* We are going to L0 with rate >= 1GHz. Check whether we have been at * L1 for long enough time. If not, go to L1 for 20ms. */ -if (pm_cpu->l1_expiration && jiffies >= pm_cpu->l1_expiration) +if (pm_cpu->l1_expiration &&time_is_before_eq_jiffies (pm_cpu->l1_expiration)) goto invalidate_l1_exp; regmap_update_bits(base, ARMADA_37XX_NB_CPU_LOAD,
Signature · 1 line
2.7.4
Re: [PATCH V3 2/13] clk: mvebu: use time_is_before_eq_jiffies() instead of open coding it
Quoting Qing Wang (2022-02-14 17:55:39)
Quoted 7 lines
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>---
Applied to clk-next
PATCH v3 3/13 gpu: drm: i915: use time_is_after_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c +1 -1
@@ -56,7 +56,7 @@ static bool pool_free_older_than(struct intel_gt_buffer_pool *pool, long keep) node =list_entry (pos,typeof (*node), link); age =READ_ONCE (node->age); -if (!age || jiffies - age < keep) +if (!age ||time_is_after_jiffies (age + keep))break ;/* Check we are the first to claim this node */
Signature · 1 line
2.7.4
PATCH v3 4/13 gpu: drm: radeon: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/gpu/drm/radeon/radeon_pm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_pm.c +2 -1
@@ -25,6 +25,7 @@#include <linux/hwmon.h> #include <linux/pci.h> #include <linux/power_supply.h> +#include <linux/jiffies.h> #include <drm/drm_vblank.h>
@@ -1899,7 +1900,7 @@ static void radeon_dynpm_idle_work_handler(struct work_struct *work)* to false since we want to wait for vbl to avoid flicker. */ if (rdev->pm.dynpm_planned_action !=DYNPM_ACTION_NONE && - jiffies > rdev->pm.dynpm_action_timeout) { +time_is_before_jiffies (rdev->pm.dynpm_action_timeout)) {radeon_pm_get_dynpm_state (rdev);radeon_pm_set_clocks (rdev); }
Signature · 1 line
2.7.4
PATCH v3 5/13 hid: use time_is_after_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ipc/ipc.c +1 -1
@@ -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_is_after_jiffies (prev_sync +20 *HZ ))return ; prev_sync = jiffies;
Signature · 1 line
2.7.4
Re: [PATCH V3 5/13] hid: use time_is_after_jiffies() instead of open coding it
Quoted 8 lines · Qing Wang
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>
FWIW, this one is
Wang, is there any plan to take this series through the trivial tree or should each maintainer take the matching patches?
Cheers,
Benjamin
Quoted 20 lines
--- drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/intel-ish-hid/ipc/ipc.c +1
-2@@ -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_is_after_jiffies (prev_sync +20 *HZ ))return ; prev_sync = jiffies; --2.7.4
A message that is not in the archive (sent off-list or not yet received): [email protected].@PENBTy1od0pKSzV5ZVcrS192THBXVjl0M1RzRWRrMHhDTy1FVHhlSnNYTTJjMTE3SnpOd0BtYWlsLmdtYWlsLmNvbT4=
RE: [PATCH V3 5/13] hid: use time_is_after_jiffies() instead of open coding it
Quoted 7 lines
Quoted 7 lines · Qing Wang
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Wang Qing <[email protected]>FWIW, this one is
Wang, is there any plan to take this series through the trivial tree
That's why I batch them in a series, but I don't know how to take this series through the trivial tree directly.
I would appreciate if you could help.
Thanks,
Wang
Quoted 25 lines
or should each maintainer take the matching patches?
Cheers,
BenjaminQuoted 20 lines
---
drivers/hid/intel-ish-hid/ipc/ipc.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/intel-ish-hid/ipc/ipc.c +1
-2@@ -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_is_after_jiffies(prev_sync + 20 * HZ)) return; prev_sync = jiffies; --2.7.4
PATCH v3 6/13 input: serio: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/input/serio/ps2-gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/serio/ps2-gpio.c +2 -2
@@ -136,7 +136,7 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata)if (old_jiffies ==0 ) old_jiffies = jiffies; -if ((jiffies - old_jiffies) >usecs_to_jiffies (100 )) { +if (time_is_before_jiffies (old_jiffies +usecs_to_jiffies (100 ))) {dev_err (drvdata->dev,"RX: timeout, probably we missed an interrupt\n" ); goto err;
@@ -237,7 +237,7 @@ static irqreturn_t ps2_gpio_irq_tx(struct ps2_gpio_data *drvdata)if (old_jiffies ==0 ) old_jiffies = jiffies; -if ((jiffies - old_jiffies) >usecs_to_jiffies (100 )) { +if (time_is_before_jiffies (old_jiffies +usecs_to_jiffies (100 ))) {dev_err (drvdata->dev,"TX: timeout, probably we missed an interrupt\n" ); goto err;
Signature · 1 line
2.7.4
Re: [PATCH V3 6/13] input: serio: use time_is_before_jiffies() instead of open coding it
Quoted 8 lines · Qing Wang
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
Signed-off-by Wang Qing <[email protected]>---
Cheers,
Benjamin
Quoted 28 lines
drivers/input/serio/ps2-gpio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/input/serio/ps2-gpio.c +2
-3@@ -136,7 +136,7 @@ static irqreturn_t ps2_gpio_irq_rx(struct ps2_gpio_data *drvdata)if (old_jiffies ==0 ) old_jiffies = jiffies; -if ((jiffies - old_jiffies) >usecs_to_jiffies (100 )) { +if (time_is_before_jiffies (old_jiffies +usecs_to_jiffies (100 ))) {dev_err (drvdata->dev,"RX: timeout, probably we missed an interrupt\n" ); goto err;@@ -237,7 +237,7 @@ static irqreturn_t ps2_gpio_irq_tx(struct ps2_gpio_data *drvdata)if (old_jiffies ==0 ) old_jiffies = jiffies; -if ((jiffies - old_jiffies) >usecs_to_jiffies (100 )) { +if (time_is_before_jiffies (old_jiffies +usecs_to_jiffies (100 ))) {dev_err (drvdata->dev,"TX: timeout, probably we missed an interrupt\n" ); goto err; --2.7.4
Dmitry Torokhov
maintainerRe: [PATCH V3 6/13] input: serio: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangHi Wang,
Quoted 4 lines · Qing Wang
From: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
I applied changes by Danilo Krummrich converting the driver to usektime_t (see https://lore.kernel.org/r/[email protected])
which makes this change not applicable.
Thanks.
Signature · 1 line
Dmitry
PATCH v3 7/13 md: use time_is_before_jiffies(() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/md/dm-thin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-thin.c +1 -1
@@ -161,7 +161,7 @@ static void throttle_work_start(struct throttle *t)static void throttle_work_update (struct throttle *t) { -if (!t->throttle_applied && jiffies > t->threshold) { +if (!t->throttle_applied &&time_is_before_jiffies (t->threshold)) {down_write (&t->lock); t->throttle_applied = true; }
Signature · 1 line
2.7.4
PATCH v3 9/13 media: si21xx: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/media/dvb-frontends/si21xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/si21xx.c +1 -1
@@ -336,7 +336,7 @@ static int si21xx_wait_diseqc_idle(struct si21xx_state *state, int timeout)dprintk ("%s\n" , __func__);while ((si21_readreg (state,LNB_CTRL_REG_1 ) &0x8 ) ==8 ) { -if (jiffies - start > timeout) { +if (time_is_before_jiffies (start + timeout)) {dprintk ("%s: timeout!!\n" , __func__);return -ETIMEDOUT ; }
Signature · 1 line
2.7.4
PATCH v3 10/13 media: stv0299: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/media/dvb-frontends/stv0299.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/dvb-frontends/stv0299.c +2 -2
@@ -183,7 +183,7 @@ static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout)dprintk ("%s\n" , __func__);while (stv0299_readreg (state,0x0a ) &1 ) { -if (jiffies - start > timeout) { +if (time_is_before_jiffies (start + timeout)) {dprintk ("%s: timeout!!\n" , __func__);return -ETIMEDOUT ; }
@@ -200,7 +200,7 @@ static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout)dprintk ("%s\n" , __func__);while ((stv0299_readreg (state,0x0a ) &3 ) !=2 ) { -if (jiffies - start > timeout) { +if (time_is_before_jiffies (start + timeout)) {dprintk ("%s: timeout!!\n" , __func__);return -ETIMEDOUT ; }
Signature · 1 line
2.7.4
PATCH v3 10/13 md: use time_is_before_eq_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/md/dm-writecache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/md/dm-writecache.c +3 -2
@@ -16,6 +16,7 @@#include <linux/pfn_t.h> #include <linux/libnvdimm.h> #include <linux/delay.h> +#include <linux/jiffies.h> #include "dm-io-tracker.h" #define DM_MSG_PREFIX "writecache"
@@ -1971,8 +1972,8 @@ static void writecache_writeback(struct work_struct *work)while (!list_empty (&wc->lru) && (wc->writeback_all || wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark || - (jiffies - container_of(wc->lru.prev, struct wc_entry, lru)->age >= - wc->max_age - wc->max_age /MAX_AGE_DIV ))) { + time_is_before_eq_jiffies(container_of(wc->lru.prev, struct wc_entry, lru)->age + + wc->max_age - wc->max_age / MAX_AGE_DIV)) { n_walked++; if (unlikely(n_walked > WRITEBACK_LATENCY) &&
Signature · 1 line
2.7.4
PATCH v3 11/13 media: tda8083: use time_is_after_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/media/dvb-frontends/tda8083.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/tda8083.c +1 -1
@@ -162,7 +162,7 @@ static void tda8083_wait_diseqc_fifo (struct tda8083_state* state, int timeout) {unsigned long start = jiffies; -while (jiffies - start < timeout && +while (time_is_after_jiffies (start + timeout) && !(tda8083_readreg (state,0x02 ) &0x80 )) {msleep (50 );
Signature · 1 line
2.7.4
PATCH v3 12/13 media: wl128x: use time_is_before_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/media/radio/wl128x/fmdrv_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/radio/wl128x/fmdrv_common.c +2 -1
@@ -23,6 +23,7 @@#include <linux/firmware.h> #include <linux/module.h> #include <linux/nospec.h> +#include <linux/jiffies.h> #include "fmdrv.h" #include "fmdrv_v4l2.h"
@@ -342,7 +343,7 @@ static void send_tasklet(struct tasklet_struct *t)return ;/* Check, is there any timeout happened to last transmitted packet */ -if ((jiffies - fmdev->last_tx_jiffies) >FM_DRV_TX_TIMEOUT ) { +if (time_is_before_jiffies (fmdev->last_tx_jiffies +FM_DRV_TX_TIMEOUT )) {fmerr ("TX timeout occurred\n" );atomic_set (&fmdev->tx_cnt,1 ); }
Signature · 1 line
2.7.4
PATCH v3 13/13 media: vivid: use time_is_after_jiffies() instead of open coding it
In reply to Qing WangFrom: Wang Qing <[email protected]>
Use the helper function time_is_{before,after}_jiffies() to improve code readability.
--- drivers/media/test-drivers/vivid/vivid-kthread-cap.c | 3 ++- drivers/media/test-drivers/vivid/vivid-kthread-out.c | 3 ++- drivers/media/test-drivers/vivid/vivid-kthread-touch.c | 3 ++- drivers/media/test-drivers/vivid/vivid-sdr-cap.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-)
drivers/media/test-drivers/vivid/vivid-kthread-cap.c +2 -1
@@ -18,6 +18,7 @@#include <linux/freezer.h> #include <linux/random.h> #include <linux/v4l2-dv-timings.h> +#include <linux/jiffies.h> #include <asm/div64.h> #include <media/videobuf2-vmalloc.h> #include <media/v4l2-dv-timings.h>
@@ -893,7 +894,7 @@ static int vivid_thread_vid_cap(void *data) next_jiffies_since_start = jiffies_since_start; wait_jiffies = next_jiffies_since_start - jiffies_since_start; -while (jiffies - cur_jiffies < wait_jiffies && +while (time_is_after_jiffies (cur_jiffies + wait_jiffies) && !kthread_should_stop ())schedule (); }
drivers/media/test-drivers/vivid/vivid-kthread-out.c +2 -1
@@ -18,6 +18,7 @@#include <linux/freezer.h> #include <linux/random.h> #include <linux/v4l2-dv-timings.h> +#include <linux/jiffies.h> #include <asm/div64.h> #include <media/videobuf2-vmalloc.h> #include <media/v4l2-dv-timings.h>
@@ -234,7 +235,7 @@ static int vivid_thread_vid_out(void *data) next_jiffies_since_start = jiffies_since_start; wait_jiffies = next_jiffies_since_start - jiffies_since_start; -while (jiffies - cur_jiffies < wait_jiffies && +while (time_is_after_jiffies (cur_jiffies + wait_jiffies) && !kthread_should_stop ())schedule (); }
drivers/media/test-drivers/vivid/vivid-kthread-touch.c +2 -1
@@ -5,6 +5,7 @@*/ #include <linux/freezer.h> +#include <linux/jiffies.h> #include "vivid-core.h" #include "vivid-kthread-touch.h" #include "vivid-touch-cap.h"
@@ -134,7 +135,7 @@ static int vivid_thread_touch_cap(void *data) next_jiffies_since_start = jiffies_since_start; wait_jiffies = next_jiffies_since_start - jiffies_since_start; -while (jiffies - cur_jiffies < wait_jiffies && +while (time_is_after_jiffies (cur_jiffies + wait_jiffies) && !kthread_should_stop ())schedule (); }
drivers/media/test-drivers/vivid/vivid-sdr-cap.c +2 -1
@@ -17,6 +17,7 @@#include <media/v4l2-event.h> #include <media/v4l2-dv-timings.h> #include <linux/fixp-arith.h> +#include <linux/jiffies.h> #include "vivid-core.h" #include "vivid-ctrls.h"
@@ -205,7 +206,7 @@ static int vivid_thread_sdr_cap(void *data) next_jiffies_since_start = jiffies_since_start; wait_jiffies = next_jiffies_since_start - jiffies_since_start; -while (jiffies - cur_jiffies < wait_jiffies && +while (time_is_after_jiffies (cur_jiffies + wait_jiffies) && !kthread_should_stop ())schedule (); }
Signature · 1 line
2.7.4