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: 10076701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 246C0602BC for ; Mon, 27 Nov 2017 11:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E50528E05 for ; Mon, 27 Nov 2017 11:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1334628E0D; Mon, 27 Nov 2017 11:52:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BEE828E05 for ; Mon, 27 Nov 2017 11:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751849AbdK0LwS (ORCPT ); Mon, 27 Nov 2017 06:52:18 -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: <20171127115158.2884398-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:SyRPUP588cQOANuBfBESP9QBicV08o909o3DFysX0XDKgjG0C/1 4ljMJMAIkRJGiTykhRtjsBlgKhC6P4x/cZN8nU2NwrUBnwb4QwbZOJ7V2If72gA6XfBABU1 zIfGwWAz9WhjKEpyJ+1X5aWX7qSHB+nx3ZeXi0NRXlB1RJP4Iovx0Gf5sUgIjgtIRySaMvs BUr1NlxvfUy+gCITyma0A== X-UI-Out-Filterresults: notjunk:1; V01:K0:rSDIHglyu/4=:YwxHbEk/ijBdtgnS8TRstS p47d7eIw7q/JZEy1wVK9he2YrKqt4JpqMWgKj+rEZfP12G3VsvOfqh0GQKiO+3CBToViAHdB5 u+nQw+BPZAU5tkNNN9x6fEPMzeMdFAR5r/UVAGSaiv34z83NUS8LO0lq8oLCIt0G99KTZ8BPX ftssjAjgVVuoVaUyHZBNhrgzQjLEg80m5QfVF+pfecKCr4EEqnr3OaENkDQMh9I2UB5pAx/gf LSPtQ73x1/ATx4mNnDtlmftPL686oyX6CauRP4V4wL2C4yLsQkj0BJ1BLxw+6ZMVZSHO2t2/2 UEx7XjB1E2NmE2NP3Xf+N0//GLkDiCLeB3PJTyzxhdxMBwVSU/P7km1gAif0FvGTndJBRHlqC zLCSsnvagmt798COuEDh32Ojdxw3l4v7idb1XXMQ34OhWwRtmiNRq070eYQjNZZenfnKqkE37 RmVJ8fQx8eextm5q0yFr5Vs3Tg2rbO8fRHFR39YVA8j3n6fnCyVG93QuIL0EHgd6DZBcX4Ko4 j1ACJBIXEqFFgu7KEifLzSw5GbUlwWBKTyBWbmwKK85ZWhub1fod5J9sAy17Ca8oTzoS1RGbS i8mNJYYFIUEAPLv+FkpP5QM1DBb0K8sceZmJwtnuCcoRA87vFBmTISMPehUKoXWOq7gQaMh24 38+69bN0L8OfIN8NEY7Q00EZccG8ahaUAn2T/qK57rYyEZMHyJ1jqYBI7+3xzwtGlGH5sn5SQ 4QZIDcKZVVZnK0VCHpOFFDRg7CBWp3Ji6cHA6g== Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }