linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion
@ 2015-03-02  9:54 Nicholas Mc Guire
  2015-03-02  9:54 ` [PATCH 2/2] mesh_plink: fixup type of timeout to match usage Nicholas Mc Guire
  2015-03-03  9:55 ` [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Johannes Berg
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-03-02  9:54 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S. Miller, linux-wireless, netdev, linux-kernel,
	Nicholas Mc Guire

This is primarily an API consolidation and should make things more readable
it replaces var * HZ / 1000 by msecs_to_jiffies(var) which also handles
corner cases correctly.

There is a change of behavior as e.g. for HZ 100, t * HZ / 1000 will
return 0 for t < 10 but msecs_to_jiffies will return at least 1 always.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

Patch was only compile tested with x86_64_defconfig + CONFIG_MAC80211_MESH=y

Patch is against 4.0-rc1 (localversion-next is -next-20150302)

 net/mac80211/mesh_plink.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index b488e18..4eefd5d 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -17,7 +17,7 @@
 #define PLINK_GET_PLID(p) (p + 4)
 
 #define mod_plink_timer(s, t) (mod_timer(&s->plink_timer, \
-				jiffies + HZ * t / 1000))
+				jiffies + msecs_to_jiffies(t)))
 
 enum plink_event {
 	PLINK_UNDEFINED,
@@ -623,7 +623,7 @@ static void mesh_plink_timer(unsigned long data)
 
 static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
 {
-	sta->plink_timer.expires = jiffies + (HZ * timeout / 1000);
+	sta->plink_timer.expires = jiffies + msecs_to_jiffies(timeout);
 	sta->plink_timer.data = (unsigned long) sta;
 	sta->plink_timer.function = mesh_plink_timer;
 	sta->plink_timeout = timeout;
-- 
1.7.10.4


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

* [PATCH 2/2] mesh_plink: fixup type of timeout to match usage
  2015-03-02  9:54 [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Nicholas Mc Guire
@ 2015-03-02  9:54 ` Nicholas Mc Guire
  2015-03-03  9:55 ` [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-03-02  9:54 UTC (permalink / raw)
  To: Johannes Berg
  Cc: David S. Miller, linux-wireless, netdev, linux-kernel,
	Nicholas Mc Guire

timeout was being passed as int but assigned from u32/u16 values and used 
as unsigned type. This is really only for better readability.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

After review of the use locations of mesh_plink_timer_set() and declarations 
in sta_info.h this should not be breaking any integer promotions.

This patch applies on top of 
"[PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion"

Patch was only compile tested with x86_64_defconfig + CONFIG_MAC80211_MESH=y

Patch is against 4.0-rc1 (localversion-next is -next-20150302)

 net/mac80211/mesh_plink.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
index 4eefd5d..8465c05 100644
--- a/net/mac80211/mesh_plink.c
+++ b/net/mac80211/mesh_plink.c
@@ -621,7 +621,7 @@ static void mesh_plink_timer(unsigned long data)
 				    sta->llid, sta->plid, reason);
 }
 
-static inline void mesh_plink_timer_set(struct sta_info *sta, int timeout)
+static inline void mesh_plink_timer_set(struct sta_info *sta, u32 timeout)
 {
 	sta->plink_timer.expires = jiffies + msecs_to_jiffies(timeout);
 	sta->plink_timer.data = (unsigned long) sta;
-- 
1.7.10.4


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

* Re: [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion
  2015-03-02  9:54 [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Nicholas Mc Guire
  2015-03-02  9:54 ` [PATCH 2/2] mesh_plink: fixup type of timeout to match usage Nicholas Mc Guire
@ 2015-03-03  9:55 ` Johannes Berg
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2015-03-03  9:55 UTC (permalink / raw)
  To: Nicholas Mc Guire; +Cc: David S. Miller, linux-wireless, netdev, linux-kernel

Both applied, thanks.

johannes


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

end of thread, other threads:[~2015-03-03  9:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02  9:54 [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Nicholas Mc Guire
2015-03-02  9:54 ` [PATCH 2/2] mesh_plink: fixup type of timeout to match usage Nicholas Mc Guire
2015-03-03  9:55 ` [PATCH 1/2] mesh_plink: use msecs_to_jiffies for proper time conversion Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).