diff options
author | Stephen Hemminger <shemminger@osdl.org> | 2006-03-21 01:58:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:58:49 -0500 |
commit | 18fdb2b25be37e49b1669b5c394671f8c5b6550f (patch) | |
tree | 494e70fe7215849709352b826c54ea0c8154ac20 /net/bridge/br_stp_bpdu.c | |
parent | f8ae737deea1be001d7d8ac11c382a7b73a1c98f (diff) |
[BRIDGE]: stp timer to jiffies cleanup
Cleanup the get/set of bridge timer value in the packets.
It is clearer not to bury the conversion in macro.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_stp_bpdu.c')
-rw-r--r-- | net/bridge/br_stp_bpdu.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c index 296f6a487c52..c3da01cc6a6f 100644 --- a/net/bridge/br_stp_bpdu.c +++ b/net/bridge/br_stp_bpdu.c | |||
@@ -19,8 +19,7 @@ | |||
19 | #include "br_private.h" | 19 | #include "br_private.h" |
20 | #include "br_private_stp.h" | 20 | #include "br_private_stp.h" |
21 | 21 | ||
22 | #define JIFFIES_TO_TICKS(j) (((j) << 8) / HZ) | 22 | #define STP_HZ 256 |
23 | #define TICKS_TO_JIFFIES(j) (((j) * HZ) >> 8) | ||
24 | 23 | ||
25 | static void br_send_bpdu(struct net_bridge_port *p, unsigned char *data, int length) | 24 | static void br_send_bpdu(struct net_bridge_port *p, unsigned char *data, int length) |
26 | { | 25 | { |
@@ -57,18 +56,18 @@ static void br_send_bpdu(struct net_bridge_port *p, unsigned char *data, int len | |||
57 | dev_queue_xmit); | 56 | dev_queue_xmit); |
58 | } | 57 | } |
59 | 58 | ||
60 | static __inline__ void br_set_ticks(unsigned char *dest, int jiff) | 59 | static inline void br_set_ticks(unsigned char *dest, int j) |
61 | { | 60 | { |
62 | __u16 ticks; | 61 | unsigned long ticks = (STP_HZ * j)/ HZ; |
63 | 62 | ||
64 | ticks = JIFFIES_TO_TICKS(jiff); | 63 | *((__be16 *) dest) = htons(ticks); |
65 | dest[0] = (ticks >> 8) & 0xFF; | ||
66 | dest[1] = ticks & 0xFF; | ||
67 | } | 64 | } |
68 | 65 | ||
69 | static __inline__ int br_get_ticks(unsigned char *dest) | 66 | static inline int br_get_ticks(const unsigned char *src) |
70 | { | 67 | { |
71 | return TICKS_TO_JIFFIES((dest[0] << 8) | dest[1]); | 68 | unsigned long ticks = ntohs(*(__be16 *)src); |
69 | |||
70 | return (ticks * HZ + STP_HZ - 1) / STP_HZ; | ||
72 | } | 71 | } |
73 | 72 | ||
74 | /* called under bridge lock */ | 73 | /* called under bridge lock */ |