From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966036AbcA1IXP (ORCPT ); Thu, 28 Jan 2016 03:23:15 -0500 Received: from www.linutronix.de ([62.245.132.108]:57698 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965918AbcA1IXJ (ORCPT ); Thu, 28 Jan 2016 03:23:09 -0500 Date: Thu, 28 Jan 2016 09:22:04 +0100 (CET) From: Thomas Gleixner To: zengtao cc: LKML , Arnd Bergmann Subject: Re: [PATCH] cputime: Fix timeval-->cputime conversion In-Reply-To: <1453964546-111074-1-git-send-email-prime.zeng@huawei.com> Message-ID: References: <1453964546-111074-1-git-send-email-prime.zeng@huawei.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc'ing Arnd On Thu, 28 Jan 2016, zengtao wrote: > The structure: > struct timeval { > __kernel_time_t tv_sec; /* seconds */ > __kernel_suseconds_t tv_usec; /* microseconds */ > }; > both __kernel_time_t and __kernel_suseconds_t are short than u64 > when it is 32bit platform, so force u64 conversion here. > > Signed-off-by: zengtao Reviewed-by: Thomas Gleixner > --- > include/asm-generic/cputime_nsecs.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h > index 0419485..e2f7ff9 100644 > --- a/include/asm-generic/cputime_nsecs.h > +++ b/include/asm-generic/cputime_nsecs.h > @@ -91,7 +91,8 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) > */ > static inline cputime_t timeval_to_cputime(const struct timeval *val) > { > - u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC; > + u64 ret = (u64)val->tv_sec * NSEC_PER_SEC + > + val->tv_usec * NSEC_PER_USEC; > return (__force cputime_t) ret; > } > static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val) > -- > 1.9.1 > >