Merge "kernel: time: Fix accuracy for low resolution timer"

This commit is contained in:
qctecmdr 2020-08-17 01:14:51 -07:00 • committed by Gerrit - the friendly Code Review server
commit 7b80147165

View file

@ -493,7 +493,11 @@ static inline void timer_set_idx(struct timer_list *timer, unsigned int idx)
*/
static inline unsigned calc_index(unsigned expires, unsigned lvl)
{
expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
if (lvl != 0 && (expires & ~(UINT_MAX << LVL_SHIFT(lvl))))
expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl);
else
expires = expires >> LVL_SHIFT(lvl);
return LVL_OFFS(lvl) + (expires & LVL_MASK);
}