From patchwork Mon Nov 27 13:19:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 119702 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp257667qgn; Mon, 27 Nov 2017 05:20:39 -0800 (PST) X-Google-Smtp-Source: AGs4zMbC9YjE3vekUNzpyhLlzSTZv3qUgwAUnNZplOA8OK3gSraTspQ4+Y0Ru67shdoo8DP7nMdz X-Received: by 10.98.163.73 with SMTP id s70mr36198894pfe.64.1511788839111; Mon, 27 Nov 2017 05:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511788839; cv=none; d=google.com; s=arc-20160816; b=cQTrXo+0x89Hyu7OlIc+rsk9giMaSjs61B8SN1vg31pGz4enrS3dxRtvAWrIYuh2Fw FON/3HqHNYjGYt6k68xzuyAcfldOFwYxQnK75wgCjyxltFsaV/oiwZxwB6O6b4ZL2vcD lq3TXfyHsaOo0+8KTVVNLlcKA/+vtBKa4d3xltBFNFlJPVPFnM5Bk0NF1ALNhaOHu39Y F0V9I7GSvox8RPtF+LLqUqUuUnwXRu6x8GtdnxzD5pKpE1Ph1ICV+Vm2RHOKdPGCVm0/ 9dDxQNOtFF6+doByc2LSfQXi6wbKnm87dikmCRqv79DDKscF+PQaMmpviBKP/BzrrqAp nTUA== 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=jUz3DkOjE43gYJlqCxhafCsC/V3bDbiJv8qev0S1hfw=; b=YjQ8S3UrtIzswLULswaQeCiXWbkaQEp156iPetXBipLM53M1mMm+2MYwC0bGaJ/sMB ppNemLDum157sOD/U/vFRCpEXqaKYP6aACww3Wj/i6l1oc/okh71S3lvJ2UDbeA39+bE gTARxs+Tr/OUWCYIvAU7r6kWTupV4RVi5EhVdPgCyM3ZLzUq+iAFPi8gh+yuIqilpA+k SnBeQoAWpXCMIsAS/aq83YEaO0ZzBC5Xq4T0gF1fpD3QbkhNqWxcnFDrRZalPfddG9Qu IHlvxwsXv3uLam5jP1tACmm8/cgiFHgZhnJAhk/RcT2ggtmB0mcCsFgBG2n+As3lq9F3 xaHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 u12si22998688plz.394.2017.11.27.05.20.38; Mon, 27 Nov 2017 05:20:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752215AbdK0NUi (ORCPT + 4 others); Mon, 27 Nov 2017 08:20:38 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:55950 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752083AbdK0NUh (ORCPT ); Mon, 27 Nov 2017 08:20:37 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MduOr-1eTY5B36YX-00PbPY; Mon, 27 Nov 2017 14:20:28 +0100 From: Arnd Bergmann To: Laurent Pinchart , Mauro Carvalho Chehab Cc: y2038@lists.linaro.org, Arnd Bergmann , Kieran Bingham , Guennadi Liakhovetski , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] [media] uvc_video: use ktime_t for stats Date: Mon, 27 Nov 2017 14:19:53 +0100 Message-Id: <20171127132027.1734806-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:cYz7XyslFcyisyesdMZLDqD82b+IQ0U5MRriYwn2qXYFGJ012o5 sed48L9dSKObQ/C9SLSuYp6Nc12EykuL6GmooDB2qC1QR425uRPFUh5tSs+sS3Umkkxfcs0 nc16eaByvpiJQOiKIbSH1YW2TqQIRTNhe+kQUrLOqw0xSOFYhMH0Y6kqdPaMmwSusKHOd8d uD8J+uiIn+oOHBCtQH8iw== X-UI-Out-Filterresults: notjunk:1; V01:K0:GHDkNlDZSmo=:Zax3Rjzq6HtRfRC5gK0si6 aWzjqwDuUVf31TyUa3NaVMsfcqoDOKUcgYKspRCqkn9VqufCrne2fYFDMKRoHI3HNJee6ivmY pi7pHElepk6HE3Fej5lgT6IlgpUclZ+AkRNBSEWfxDTAaehvkw3cHYNNF80IbL1DvEcmL3nou Fg1CoJ2jXMXxUY0yPPbS4gUeuGIgeXLaqhuYeHwsvKR0jneIOtN6HxO/TXjPiFL0tkLUWc294 Bs7tnmVXiKTi4WfCZsgkAfLZ3GqP19/mmFc7t46iM0MefS0APB4Hfph0Txmdf3FVL3QExV/XT naKpQWCGicWpzQwH4z/qxh+UEclMWdb9gASBH3Aq8pW9GSxnuOLzULkaheXlmP4Pem3K5uZk0 Cw1Z96vFgBQ/e87sIdOjsCklUxdmbmoRitwgHMNGDAAN1cukVfHq74ZyMrL0+3og+2iumvIUy MTXodPxKTKPX+FnftiSDZC4C+8d+9opyKyBn/FSybSdOiVELtl3JhVpqNnVuqCZTdDehGjOer j5Qg9pSMjvmMJm6YyxA0lLWH30fxktWkJaToolrYiqt9pBTDJAneVFxnMD2+RsQEwUMwuzXkQ P+BCev7y+0Sk9jPzj/x6hCictbnHUp5eZqs3X54P/YAX0NwNHQMMoLQ+0gDKVRSc/cCYWjdlT afUt3nXy9kMPwUxGcL/QvxV/RVUK0vANDcj4jNppL65xhSNFBzNfoFPq8OcDx2enuswHsxDer 3jQJTYnuCbE7653inbIzXKzL8vY95nsTGoyPhw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 'struct timespec' works fine here, but we try to migrate away from it in favor of ktime_t or timespec64. In this case, using ktime_t produces the simplest code. Signed-off-by: Arnd Bergmann --- drivers/media/usb/uvc/uvc_video.c | 11 ++++------- drivers/media/usb/uvc/uvcvideo.h | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) -- 2.9.0 diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index fb86d6af398d..d6bee37cd1b8 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -725,7 +725,7 @@ static void uvc_video_stats_decode(struct uvc_streaming *stream, if (stream->stats.stream.nb_frames == 0 && stream->stats.frame.nb_packets == 0) - ktime_get_ts(&stream->stats.stream.start_ts); + stream->stats.stream.start_ts = ktime_get(); switch (data[1] & (UVC_STREAM_PTS | UVC_STREAM_SCR)) { case UVC_STREAM_PTS | UVC_STREAM_SCR: @@ -865,16 +865,13 @@ size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, { unsigned int scr_sof_freq; unsigned int duration; - struct timespec ts; size_t count = 0; - ts = timespec_sub(stream->stats.stream.stop_ts, - stream->stats.stream.start_ts); - /* Compute the SCR.SOF frequency estimate. At the nominal 1kHz SOF * frequency this will not overflow before more than 1h. */ - duration = ts.tv_sec * 1000 + ts.tv_nsec / 1000000; + duration = ktime_ms_delta(stream->stats.stream.stop_ts, + stream->stats.stream.start_ts); if (duration != 0) scr_sof_freq = stream->stats.stream.scr_sof_count * 1000 / duration; @@ -915,7 +912,7 @@ static void uvc_video_stats_start(struct uvc_streaming *stream) static void uvc_video_stats_stop(struct uvc_streaming *stream) { - ktime_get_ts(&stream->stats.stream.stop_ts); + stream->stats.stream.stop_ts = ktime_get(); } /* ------------------------------------------------------------------------ diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 05398784d1c8..a2c190937067 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -452,8 +452,8 @@ struct uvc_stats_frame { }; struct uvc_stats_stream { - struct timespec start_ts; /* Stream start timestamp */ - struct timespec stop_ts; /* Stream stop timestamp */ + ktime_t start_ts; /* Stream start timestamp */ + ktime_t stop_ts; /* Stream stop timestamp */ unsigned int nb_frames; /* Number of frames */