From patchwork Mon Nov 27 11:51:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 119692 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp141536qgn; Mon, 27 Nov 2017 03:52:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMaYufR9r+peXBmKyv+yl2BuyfO6rhVIkkjZQQWl2fMSdxZVNOLLzbLKiHSHogg/tw5kFoeK X-Received: by 10.98.11.71 with SMTP id t68mr36003345pfi.79.1511783540813; Mon, 27 Nov 2017 03:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511783540; cv=none; d=google.com; s=arc-20160816; b=xx8+82yxWyM9D14JGImxB8tWRiMBFfyWqwmDFdX85Cl10DyoSjUT2POKDlYzZF8I3b fJ8MaTG+BjuwRcmYDJLysqxKu6hvrKsvNeOTGJxCjC2GrQzX50UG0h1VEBdocu0rk+tR Du5rOYmDV79keqULCh7W580PPID/nWsheUxW462Nha8JZnB9juPVVlYwOT/6fe6x65fu 5carrAsEP0zmlMl/bfVOmWqlIGfrCqr2sSSDDwrje6DF7PqyoLPQLdstdNhyS13hShQ9 3odsb5dcR1DZm4QltoCJ9+iT89H4uLpKRdYAVqDWPZXzEr1eN62V/R4DKGyuqqPcJKpf DjVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ORgFbUoJcf7/0n36cFIYpIoPAWzyvOmGhdDsEd7iJKY=; b=r9qXvAH96FlKwngnhiNiteGgOMetJ30P5NV4imS0If8ocsosQALslTEc+Mn2VPpuUP iKSUrCwbfuNv4nZxYLLBTpMAamThADQ1zhZ7U4gTJI/bM2W5cjzx+/MXpZTcv3tcKgzv rPCzfRwflHDg2uc3IPEcOGGnZHEhtpzeNBf/trZShq9m0DyiY24Xd48KWXJyR4HAq5HM pM609hPWUiv/lmhha7ElPeejjPed23fE1kOcujUlIJNBjX2zd5CehZGUUigc8OHPRCno noET3sdNOXqcUX5A638Ggb+NNvM+wfxITFyb2KEvugiVrYcKRVF0jliqxd2vl+iHVXzY x2gQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h69si22576473pge.382.2017.11.27.03.52.20; Mon, 27 Nov 2017 03:52:20 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbdK0LwT (ORCPT + 28 others); Mon, 27 Nov 2017 06:52:19 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:54363 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751712AbdK0LwQ (ORCPT ); Mon, 27 Nov 2017 06:52:16 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M09nw-1f8lZj23Js-00uIAU; Mon, 27 Nov 2017 12:51:59 +0100 From: Arnd Bergmann To: Jonathan Cameron , Arnd Bergmann Cc: y2038@lists.linaro.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: common: ssp_sensors: use ktime_get_real_ns() timestamps Date: Mon, 27 Nov 2017 12:51:48 +0100 Message-Id: <20171127115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KZVVZnK0VCHpOFFDRg7CBWp3Ji6cHA6g== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org getnstimeofday() suffers from the overflow in y2038 on 32-bit architectures and requires a conversion into the nanosecond format that we want here. This changes ssp_parse_dataframe() to use ktime_get_real_ns() directly, which does not have that problem. An open question is what time base should be used here. Normally timestamps should use ktime_get_ns() or ktime_get_boot_ns() to read monotonic time instead of "real" time, which suffers from time jumps due to settimeofday() calls or leap seconds. Signed-off-by: Arnd Bergmann --- drivers/iio/common/ssp_sensors/ssp_spi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.9.0 diff --git a/drivers/iio/common/ssp_sensors/ssp_spi.c b/drivers/iio/common/ssp_sensors/ssp_spi.c index 704284a475ae..2ab106bb3e03 100644 --- a/drivers/iio/common/ssp_sensors/ssp_spi.c +++ b/drivers/iio/common/ssp_sensors/ssp_spi.c @@ -277,12 +277,9 @@ static int ssp_handle_big_data(struct ssp_data *data, char *dataframe, int *idx) static int ssp_parse_dataframe(struct ssp_data *data, char *dataframe, int len) { int idx, sd; - struct timespec ts; struct ssp_sensor_data *spd; struct iio_dev **indio_devs = data->sensor_devs; - getnstimeofday(&ts); - for (idx = 0; idx < len;) { switch (dataframe[idx++]) { case SSP_MSG2AP_INST_BYPASS_DATA: @@ -329,7 +326,7 @@ static int ssp_parse_dataframe(struct ssp_data *data, char *dataframe, int len) } if (data->time_syncing) - data->timestamp = ts.tv_sec * 1000000000ULL + ts.tv_nsec; + data->timestamp = ktime_get_real_ns(); return 0; }