mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[PATCH] NTP shift_right cleanup
Create a macro shift_right() that avoids the numerous ugly conditionals in the NTP code that look like: if(a < 0) b = -(-a >> shift); else b = a >> shift; Replacing it with: b = shift_right(a, shift); This should have zero effect on the logic, however it should probably have a bit of testing just to be sure. Also replace open-coded min/max with the macros. Signed-off-by : John Stultz <johnstul@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
9c0cbd54ce
commit
1bb34a4127
3 changed files with 24 additions and 61 deletions
|
@ -282,6 +282,13 @@ static inline int ntp_synced(void)
|
|||
return !(time_status & STA_UNSYNC);
|
||||
}
|
||||
|
||||
/* Required to safely shift negative values */
|
||||
#define shift_right(x, s) ({ \
|
||||
__typeof__(x) __x = (x); \
|
||||
__typeof__(s) __s = (s); \
|
||||
__x < 0 ? -(-__x >> __s) : __x >> __s; \
|
||||
})
|
||||
|
||||
|
||||
#ifdef CONFIG_TIME_INTERPOLATION
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue