[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1422701514-17256-1-git-send-email-der.herr@hofr.at>
Date: Sat, 31 Jan 2015 11:51:54 +0100
From: Nicholas Mc Guire <der.herr@...r.at>
To: Larry Finger <Larry.Finger@...inger.net>
Cc: Florian Schilhabel <florian.c.schilhabel@...glemail.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
James A Shackleford <shack@...ux.com>,
Aybuke Ozdemir <aybuke.147@...il.com>,
Sarah Khan <sarahjmi07@...il.com>,
Andreea-Cristina Bernat <bernat.ada@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Nicholas Mc Guire <der.herr@...r.at>
Subject: [PATCH 1/2] staging: rtl8712: cleanup of timeout conversions
This is only an API consolidation to make things more readable.
Instances of var * HZ / 1000 are replaced by msecs_to_jiffies(var).
As msecs_to_jiffies will return > 0 if it is passed a value > 0 the
== 0 check is not needed.
Signed-off-by: Nicholas Mc Guire <der.herr@...r.at>
---
Converting milliseconds to jiffies by "val * HZ / 1000" is technically
ok but msecs_to_jiffies(val) is the cleaner solution and handles all
corner cases correctly. This is a minor API cleanup only.
As msecs_to_jiffies will not return at least 1 (unless 0 is passed as
argument) the check for delta == 0 is not needed here.
This patch was only compile tested for x86_64_defconfig +
CONFIG_STAGING=y, CONFIG_R8712U=m
This patch is against 3.0.19-rc6 -next-20150129
drivers/staging/rtl8712/osdep_service.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h
index 5153ad9..f933713 100644
--- a/drivers/staging/rtl8712/osdep_service.h
+++ b/drivers/staging/rtl8712/osdep_service.h
@@ -71,7 +71,7 @@ static inline void _init_timer(struct timer_list *ptimer,
static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
{
- mod_timer(ptimer, (jiffies+(delay_time*HZ/1000)));
+ mod_timer(ptimer, (jiffies+msecs_to_jiffies(delay_time)));
}
static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
@@ -101,9 +101,7 @@ static inline void sleep_schedulable(int ms)
{
u32 delta;
- delta = (ms * HZ) / 1000;/*(ms)*/
- if (delta == 0)
- delta = 1;/* 1 ms */
+ delta = msecs_to_jiffies(ms);/*(ms)*/
set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(delta) != 0)
return;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists