Re: [RFC/PATCH 4/5] cputime: use do_div() for nsec resolution conversion helpers

From: Kevin Hilman
Date: Thu Feb 21 2013 - 14:21:23 EST


Namhyung Kim <namhyung@xxxxxxxxxx> writes:

> Hi Kevin,
>
> On Wed, Feb 20, 2013 at 11:41:41AM -0800, Kevin Hilman wrote:
>> For the nsec resolution conversions to be useful on non 64-bit
>> architectures, do_div() needs to be used for the 64-bit divisions.
>>
>> Signed-off-by: Kevin Hilman <khilman@xxxxxxxxxx>
>> ---
>> include/asm-generic/cputime_nsecs.h | 51 +++++++++++++++++++++++++++----------
>> 1 file changed, 37 insertions(+), 14 deletions(-)
>>
>> diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h
>> index b6485ca..daa6075 100644
>> --- a/include/asm-generic/cputime_nsecs.h
>> +++ b/include/asm-generic/cputime_nsecs.h
>> @@ -24,13 +24,17 @@ typedef u64 __nocast cputime64_t;
>> /*
>> * Convert cputime <-> jiffies (HZ)
>> */
>> -#define cputime_to_jiffies(__ct) \
>> - ((__force u64)(__ct) / (NSEC_PER_SEC / HZ))
>> +static inline u64 cputime_to_jiffies(const cputime_t ct)
>> +{
>> + cputime_t __ct = ct;
>
> Why it removed the "(__force u64)" conversion part? Shouldn't it be:
>
> u64 __ct = (__force u64) ct;
>
> ?

You're right, that was an oversight. Updated patch below.

Frederic, if you merge this, please take the one below with the __force
attributes added back.

I've updated my branch to include the fixed version.

Kevin