From patchwork Sun Oct 18 09:44:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingbo Wen X-Patchwork-Id: 55173 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 1393F22F11 for ; Sun, 18 Oct 2015 09:45:53 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf14948966wiy.2 for ; Sun, 18 Oct 2015 02:45:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=iQMxq34gdNN6wc88b+OL2RBdyiTZeW6JNgXnpVJkCJE=; b=Dygpk/p2f0wXmtyuv/8XqL46weYVUs5ARAMyf0nizDiu5FntwTmFNLGG8DBKmSH1gY EBeTXVUeaf/Tvn7eOZV6KNAZf0O1U2PA9qXYxKkrL8m0bJHp9p/SchBIpK/8fhAG2pnu qNSGUo2qaXAkV2vVhBQMmBbogW3Ebpbu0rGIbbqobO0lWVuZt1X7gkJ94h9niWb8AhLy q/YKmHD/j2BR6CnlnP0JohZW0pN33nVbTTrbDnMZIY9fvpHwiPPsj2qOZuBSbyEhlv6P 8FTYjOwcv+8Wlq/0F8cpG0dkaDYd0e34bcim5IUKFoV8bLqpB01dQqpzxPmdp1uNFg1L PPFg== X-Gm-Message-State: ALoCoQkTwfre1Jq7o4CJ2TVfM7+pWXTr+/Ey/bOYpwlKvCPXVPORC2Bw5XBmEOhH22BtrPQm0aMH X-Received: by 10.180.89.41 with SMTP id bl9mr2974478wib.1.1445161552328; Sun, 18 Oct 2015 02:45:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.17.203 with SMTP id 72ls444482lfr.24.gmail; Sun, 18 Oct 2015 02:45:51 -0700 (PDT) X-Received: by 10.25.16.92 with SMTP id f89mr7824112lfi.1.1445161551917; Sun, 18 Oct 2015 02:45:51 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id pq6si18885638lbb.61.2015.10.18.02.45.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 02:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcao8 with SMTP id ao8so123672460lbc.3 for ; Sun, 18 Oct 2015 02:45:51 -0700 (PDT) X-Received: by 10.112.168.228 with SMTP id zz4mr12140343lbb.73.1445161551492; Sun, 18 Oct 2015 02:45:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp883076lbq; Sun, 18 Oct 2015 02:45:50 -0700 (PDT) X-Received: by 10.66.55.41 with SMTP id o9mr27481831pap.44.1445161550276; Sun, 18 Oct 2015 02:45:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xn8si43497145pab.234.2015.10.18.02.45.49; Sun, 18 Oct 2015 02:45:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752882AbbJRJps (ORCPT + 28 others); Sun, 18 Oct 2015 05:45:48 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36336 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752331AbbJRJpq (ORCPT ); Sun, 18 Oct 2015 05:45:46 -0400 Received: by pacfv9 with SMTP id fv9so64226883pac.3 for ; Sun, 18 Oct 2015 02:45:46 -0700 (PDT) X-Received: by 10.68.93.194 with SMTP id cw2mr27360882pbb.36.1445161545996; Sun, 18 Oct 2015 02:45:45 -0700 (PDT) Received: from localhost.localdomain (edge04.meizu.com. [103.26.122.10]) by smtp.gmail.com with ESMTPSA id kp4sm30302049pbc.34.2015.10.18.02.45.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Oct 2015 02:45:45 -0700 (PDT) From: WEN Pingbo To: dmitry.torokhov@gmail.com, arnd@arndb.de Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, y2038@lists.linaro.org, WEN Pingbo Subject: [PATCH] hp_sdc: fixed y2038 problem Date: Sun, 18 Oct 2015 17:44:19 +0800 Message-Id: <1445161459-26918-1-git-send-email-pingbo.wen@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pingbo.wen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Two replacements happened in this patch: 1. using timespec64 to prevent time overflow in 2038 2. using ktime_get_ts64 to avoid wall time issues(leap second, etc) Signed-off-by: WEN Pingbo --- drivers/input/serio/hp_sdc.c | 18 +++++++++--------- include/linux/hp_sdc.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 852858e..76fb7fa 100644 --- a/drivers/input/serio/hp_sdc.c +++ b/drivers/input/serio/hp_sdc.c @@ -193,7 +193,7 @@ static void hp_sdc_take(int irq, void *dev_id, uint8_t status, uint8_t data) curr->seq[curr->idx++] = status; curr->seq[curr->idx++] = data; hp_sdc.rqty -= 2; - do_gettimeofday(&hp_sdc.rtv); + ktime_get_ts64(&hp_sdc.rtv); if (hp_sdc.rqty <= 0) { /* All data has been gathered. */ @@ -306,13 +306,13 @@ static void hp_sdc_tasklet(unsigned long foo) write_lock_irq(&hp_sdc.rtq_lock); if (hp_sdc.rcurr >= 0) { - struct timeval tv; + struct timespec64 ts64; - do_gettimeofday(&tv); - if (tv.tv_sec > hp_sdc.rtv.tv_sec) - tv.tv_usec += USEC_PER_SEC; + ktime_get_ts64(&ts64); + if (ts64.tv_sec > hp_sdc.rtv.tv_sec) + ts64.tv_nsec += NSEC_PER_SEC; - if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { + if (ts64.tv_nsec - hp_sdc.rtv.tv_nsec > HP_SDC_MAX_REG_DELAY) { hp_sdc_transaction *curr; uint8_t tmp; @@ -321,8 +321,8 @@ static void hp_sdc_tasklet(unsigned long foo) * we'll need to figure out a way to communicate * it back to the application. and be less verbose. */ - printk(KERN_WARNING PREFIX "read timeout (%ius)!\n", - (int)(tv.tv_usec - hp_sdc.rtv.tv_usec)); + printk(KERN_WARNING PREFIX "read timeout (%llins)!\n", + (s64)(ts64.tv_nsec - hp_sdc.rtv.tv_nsec)); curr->idx += hp_sdc.rqty; hp_sdc.rqty = 0; tmp = curr->seq[curr->actidx]; @@ -551,7 +551,7 @@ unsigned long hp_sdc_put(void) /* Start a new read */ hp_sdc.rqty = curr->seq[curr->idx]; - do_gettimeofday(&hp_sdc.rtv); + ktime_get_ts64(&hp_sdc.rtv); curr->idx++; /* Still need to lock here in case of spurious irq. */ write_lock_irq(&hp_sdc.rtq_lock); diff --git a/include/linux/hp_sdc.h b/include/linux/hp_sdc.h index d392975..1535640 100644 --- a/include/linux/hp_sdc.h +++ b/include/linux/hp_sdc.h @@ -47,9 +47,9 @@ #endif -/* No 4X status reads take longer than this (in usec). +/* No 4X status reads take longer than this (in nsec). */ -#define HP_SDC_MAX_REG_DELAY 20000 +#define HP_SDC_MAX_REG_DELAY 20000000 typedef void (hp_sdc_irqhook) (int irq, void *dev_id, uint8_t status, uint8_t data); @@ -281,7 +281,7 @@ typedef struct { hp_sdc_transaction *tq[HP_SDC_QUEUE_LEN]; /* All pending read/writes */ int rcurr, rqty; /* Current read transact in process */ - struct timeval rtv; /* Time when current read started */ + struct timespec64 rtv; /* Time when current read started */ int wcurr; /* Current write transact in process */ int dev_err; /* carries status from registration */