Messages in this thread | | | From | Nicolai Stange <> | Subject | Re: [RFC v5 21/23] clockevents: initial support for mono to raw time conversion | Date | Sun, 04 Sep 2016 11:50:56 +0200 |
| |
Nicolai Stange <nicstange@gmail.com> writes:
> +static u32 __clockevents_calc_adjust_freq(u32 mult_ce_raw, u32 mult_cs_mono, > + u32 mult_cs_raw) > +{ > + u64 adj; > + int sign; > + > + if (mult_cs_raw >= mult_cs_mono) { > + sign = 0; > + adj = mult_cs_raw - mult_cs_mono; > + } else { > + sign = 1; > + adj = mult_cs_mono - mult_cs_raw; > + } > + > + adj *= mult_ce_raw; > + adj += mult_cs_mono / 2; > + do_div(adj, mult_cs_mono); > + > + if (!sign) { > + /* > + * Never increase mult by more than 12.5%, > + * c.f. __clockevents_update_bounds(). > + */ > + adj = max_t(u64, adj, mult_ce_raw / 8);
This is wrong and should read as min_t(...), of course -- it's an upper bound.
> + if (U32_MAX - mult_ce_raw < adj) > + return U32_MAX; > + return mult_ce_raw + (u32)adj; > + } > + if (adj >= mult_ce_raw) > + return 1; > + return mult_ce_raw - (u32)adj; > +}
| |