From patchwork Fri Oct 23 11:29:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingbo Wen X-Patchwork-Id: 55478 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id C8C3822A9D for ; Fri, 23 Oct 2015 11:30:04 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf9882113wiy.2 for ; Fri, 23 Oct 2015 04:30:04 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=mNYxWI9ZrBpeFKwPzL9ddOPaiJ0+1m/Ipp5eAg/9BV0=; b=jq/4MEXKgiFzzEzNDi2bjNkB/uQGiuIk+S5H82WzPhr8JiFFIeRGsFPF4b5verTFce i1EHiyJKdCHPd63DULwQP4z2JIjC9Ns78CsZPGAq0Gw6xMmDQPoYDZANf3ywq6T/fv40 0ObB/hUroGGGkTxXJWsKZdiOD1rCkOA+tl6H4bxdlfuyz0CunFUGzS35PWXOyZcr8pxE +QxkOhh9GyNsvIl+Y20sntaZf3EkMCh809spNohDvROQmhWsnu5fuMKI1fUCt6CbDfHu tByPr7ilk1t2jJ8ta/Alj01nZV80JGMFReH1+8jyo8RxJzfsSHpmBmS9Zqps04YNNk2/ fTZA== X-Gm-Message-State: ALoCoQmJmKzRB6crsqNwfQU8NY10Jjp58hI1ASdzN08BbVvGuh2WIGZCu9tF977zo8XHRFHZhBuO X-Received: by 10.112.130.41 with SMTP id ob9mr4771761lbb.17.1445599804127; Fri, 23 Oct 2015 04:30:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.23.201 with SMTP id 70ls426617lfx.49.gmail; Fri, 23 Oct 2015 04:30:03 -0700 (PDT) X-Received: by 10.112.54.130 with SMTP id j2mr8995771lbp.120.1445599803948; Fri, 23 Oct 2015 04:30:03 -0700 (PDT) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id o18si12402700lfo.58.2015.10.23.04.30.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2015 04:30:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lffv3 with SMTP id v3so79901764lff.0 for ; Fri, 23 Oct 2015 04:30:03 -0700 (PDT) X-Received: by 10.112.199.137 with SMTP id jk9mr10974245lbc.86.1445599803767; Fri, 23 Oct 2015 04:30:03 -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 w3csp1164873lbq; Fri, 23 Oct 2015 04:30:02 -0700 (PDT) X-Received: by 10.107.165.202 with SMTP id o193mr3500098ioe.69.1445599802630; Fri, 23 Oct 2015 04:30:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si450394igl.44.2015.10.23.04.30.02; Fri, 23 Oct 2015 04:30:02 -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 S1752248AbbJWLaA (ORCPT + 28 others); Fri, 23 Oct 2015 07:30:00 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33349 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbbJWL36 (ORCPT ); Fri, 23 Oct 2015 07:29:58 -0400 Received: by pabrc13 with SMTP id rc13so116200464pab.0 for ; Fri, 23 Oct 2015 04:29:58 -0700 (PDT) X-Received: by 10.69.1.65 with SMTP id be1mr4531424pbd.153.1445599798442; Fri, 23 Oct 2015 04:29:58 -0700 (PDT) Received: from localhost.localdomain (edge04.meizu.com. [103.26.122.10]) by smtp.gmail.com with ESMTPSA id bz2sm18443090pad.32.2015.10.23.04.29.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Oct 2015 04:29:57 -0700 (PDT) From: WEN Pingbo To: arnd@arndb.de Cc: y2038@lists.linaro.org, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, WEN Pingbo Subject: [PATCH V3] hp_sdc: convert struct timeval to ktime_t Date: Fri, 23 Oct 2015 19:29:39 +0800 Message-Id: <1445599779-11733-1-git-send-email-pingbo.wen@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <3901659.bcGNtuE6xV@wuerfel> References: <3901659.bcGNtuE6xV@wuerfel> 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.215.48 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: , 1. struct timeval is not y2038 safe, convert it to ktime_t, and there is no need to handle sec and usec separately 2. hp_sdc.rtv is only used for time diff, monotonic time is better here Signed-off-by: WEN Pingbo --- Version 2: Using ktime_t instead of struct timespec64 Version 3: Commit msg adjustment, and using ktime_to_ns to extract nsecs drivers/input/serio/hp_sdc.c | 16 ++++++---------- include/linux/hp_sdc.h | 6 +++--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c index 852858e..17e3725 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); + hp_sdc.rtv = ktime_get(); if (hp_sdc.rqty <= 0) { /* All data has been gathered. */ @@ -306,13 +306,9 @@ static void hp_sdc_tasklet(unsigned long foo) write_lock_irq(&hp_sdc.rtq_lock); if (hp_sdc.rcurr >= 0) { - struct timeval tv; + ktime_t time_diff = ktime_sub(ktime_get(), hp_sdc.rtv); - do_gettimeofday(&tv); - if (tv.tv_sec > hp_sdc.rtv.tv_sec) - tv.tv_usec += USEC_PER_SEC; - - if (tv.tv_usec - hp_sdc.rtv.tv_usec > HP_SDC_MAX_REG_DELAY) { + if (ktime_to_ns(time_diff) > HP_SDC_MAX_REG_DELAY) { hp_sdc_transaction *curr; uint8_t tmp; @@ -321,8 +317,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", + ktime_to_ns(time_diff)); curr->idx += hp_sdc.rqty; hp_sdc.rqty = 0; tmp = curr->seq[curr->actidx]; @@ -551,7 +547,7 @@ unsigned long hp_sdc_put(void) /* Start a new read */ hp_sdc.rqty = curr->seq[curr->idx]; - do_gettimeofday(&hp_sdc.rtv); + hp_sdc.rtv = ktime_get(); 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..348a9b5 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 */ + ktime_t rtv; /* Time when current read started */ int wcurr; /* Current write transact in process */ int dev_err; /* carries status from registration */