[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <878tv8gfi7.fsf@gmail.com>
Date: Sun, 04 Sep 2016 11:50:56 +0200
From: Nicolai Stange <nicstange@...il.com>
To: Nicolai Stange <nicstange@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
John Stultz <john.stultz@...aro.org>,
linux-kernel@...r.kernel.org
Subject: Re: [RFC v5 21/23] clockevents: initial support for mono to raw time conversion
Nicolai Stange <nicstange@...il.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;
> +}
Powered by blists - more mailing lists