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: 10076881 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 DD1C3602BC for ; Mon, 27 Nov 2017 13:20:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC5B228E4B for ; Mon, 27 Nov 2017 13:20:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C14B928E4D; Mon, 27 Nov 2017 13:20:40 +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 B87E728E4B for ; Mon, 27 Nov 2017 13:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752215AbdK0NUi (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP '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 Reviewed-by: Laurent Pinchart --- drivers/media/usb/uvc/uvc_video.c | 11 ++++------- drivers/media/usb/uvc/uvcvideo.h | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) 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 */