Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752122AbbFEEkk (ORCPT ); Fri, 5 Jun 2015 00:40:40 -0400 Received: from mail-la0-f48.google.com ([209.85.215.48]:36110 "EHLO mail-la0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073AbbFEEki (ORCPT ); Fri, 5 Jun 2015 00:40:38 -0400 MIME-Version: 1.0 In-Reply-To: <556EEC3D.4010608@ti.com> References: <20150525040716.GA4448@tinar> <556EEC3D.4010608@ti.com> Date: Fri, 5 Jun 2015 14:40:36 +1000 Message-ID: Subject: Re: [PATCH] fbdev: radeon: Remove 'struct timeval' usage From: Dave Airlie To: Tomi Valkeinen Cc: Tina Ruchandani , Arnd Bergmann , y2038@lists.linaro.org, Benjamin Herrenschmidt , Jean-Christophe Plagniol-Villard , Linux Fbdev development list , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3265 Lines: 87 On 3 June 2015 at 21:59, Tomi Valkeinen wrote: > > > On 25/05/15 07:07, Tina Ruchandani wrote: >> 'struct timeval' uses a 32-bit representation for the >> seconds field which will overflow in the year 2038 and beyond. >> This patch replaces the usage of 'struct timeval' with >> ktime_t which uses a 64-bit time representation and does not >> suffer from the y2038 problem. This patch is part of a larger >> effort to remove all instances of 'struct timeval', 'struct >> timespec', time_t and other 32-bit timekeeping variables >> from the kernel. >> The patch also replaces the use of real time (do_gettimeofday) >> with monotonic time (ktime_get). >> >> Signed-off-by: Tina Ruchandani >> --- >> drivers/video/fbdev/aty/radeon_base.c | 29 ++++++++++++++--------------- >> 1 file changed, 14 insertions(+), 15 deletions(-) >> >> diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c >> index 01237c8..9747e9e 100644 >> --- a/drivers/video/fbdev/aty/radeon_base.c >> +++ b/drivers/video/fbdev/aty/radeon_base.c >> @@ -64,6 +64,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -461,8 +462,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) >> int hTotal, vTotal, num, denom, m, n; >> unsigned long long hz, vclk; >> long xtal; >> - struct timeval start_tv, stop_tv; >> - long total_secs, total_usecs; >> + ktime_t start, stop; >> + s64 delta; >> int i; >> >> /* Ugh, we cut interrupts, bad bad bad, but we want some precision >> @@ -478,7 +479,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) >> if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) >> break; >> >> - do_gettimeofday(&start_tv); >> + start = ktime_get(); >> >> for(i=0; i<1000000; i++) >> if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0) >> @@ -487,20 +488,18 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) >> for(i=0; i<1000000; i++) >> if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) >> break; >> - >> - do_gettimeofday(&stop_tv); >> - >> + >> + stop = ktime_get(); >> + >> local_irq_enable(); >> >> - total_secs = stop_tv.tv_sec - start_tv.tv_sec; >> - if (total_secs > 10) >> + delta = ktime_us_delta(stop, start); >> + >> + /* Return -1 if more than 10 seconds have elapsed */ >> + if (delta > (10*1000000)) >> return -1; >> - total_usecs = stop_tv.tv_usec - start_tv.tv_usec; >> - total_usecs += total_secs * 1000000; >> - if (total_usecs < 0) >> - total_usecs = -total_usecs; >> - hz = 1000000/total_usecs; >> - >> + hz = 1000000/delta; This needs to be on of the do_div family. Dave. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/