From patchwork Mon May 25 04:07:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tina Ruchandani X-Patchwork-Id: 6472551 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6465F9F1C1 for ; Mon, 25 May 2015 04:07:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E4D0F204A9 for ; Mon, 25 May 2015 04:07:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3309E204A0 for ; Mon, 25 May 2015 04:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750773AbbEYEHW (ORCPT ); Mon, 25 May 2015 00:07:22 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36240 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbbEYEHV (ORCPT ); Mon, 25 May 2015 00:07:21 -0400 Received: by paza2 with SMTP id a2so53213785paz.3; Sun, 24 May 2015 21:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=zO286CbDjgbZeWtT9hUHsCC/RmDZboUJwMYCLDcdVPo=; b=Raac65iFT9CQJjxEjDYVNmRWXE7B6TNBs9Dkk0JkDnisDJGDaqcXwWEhZpeQHNwI73 UVN4PxHlGcsWqMLSYJuqsHPv6YwScnptWvGuDU89g65Soo9SAHKLH/NEq54Q43v0zPaG zYlTfigTAI/g3QzQt+iBb6ue634febrFKmPENo1orCZwNEPTW4lX0UhEPgdU7UWqMcpW gi8LMFKkgZ0HHdrphUyybzIkQKKvMDdQzWHTGEgctyaXfb6TFIhmpg9WdylguKPcqwbV +LhGq+WafyZhrHiFlJu8BxP0bnBYHqJ/g3TvJL41ckw4Dk3AtX0E4S1Ei0UEjHfSoszw 2UeA== X-Received: by 10.68.232.10 with SMTP id tk10mr35913441pbc.106.1432526840931; Sun, 24 May 2015 21:07:20 -0700 (PDT) Received: from tinar ([14.97.205.153]) by mx.google.com with ESMTPSA id om4sm8446770pdb.68.2015.05.24.21.07.19 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 May 2015 21:07:20 -0700 (PDT) Date: Mon, 25 May 2015 09:37:16 +0530 From: Tina Ruchandani To: Arnd Bergmann Cc: y2038@lists.linaro.org, Benjamin Herrenschmidt , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fbdev: radeon: Remove 'struct timeval' usage Message-ID: <20150525040716.GA4448@tinar> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP '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; + hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1); vclk = (long long)hTotal * (long long)vTotal * hz; @@ -548,7 +547,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) denom *= 3; break; case 6: - denom *= 6; + denom *= 6; break; case 7: denom *= 12;