bonding: add bond_time_in_interval() and use it for time comparison
authorVeaceslav Falico <vfalico@redhat.com>
Sat, 3 Aug 2013 01:50:36 +0000 (03:50 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Aug 2013 19:19:45 +0000 (12:19 -0700)
commite7f63f1dc4bd643d9249c653e60c530d4a438147
tree7a8d9bcb5951e88100f2e466c7f19d2719871d82
parentdef4460cdb171d64309c927907c18c4efcb0204b
bonding: add bond_time_in_interval() and use it for time comparison

Currently we use a lot of time comparison math for arp_interval
comparisons, which are sometimes quite hard to read and understand.

All the time comparisons have one pattern:
(time - arp_interval_jiffies) <= jiffies <= (time + mod *
arp_interval_jiffies + arp_interval_jiffies/2)

Introduce a new helper - bond_time_in_interval(), which will do the math in
one place and, thus, will clean up the logical code. This helper introduces
a bit of overhead (by always calculating the jiffies from arp_interval),
however it's really not visible, considering that functions using it
usually run once in arp_interval milliseconds.

There are several lines slightly over 80 chars, however breaking them would
result in more hard-to-read code than several character after the 80 mark.

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c