lkml.org 
[lkml]   [2016]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC v5 21/23] clockevents: initial support for mono to raw time conversion
Date
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;
> +}

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.200 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site