All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uvcvideo: don't recode timespec_sub
@ 2017-04-03 11:25 Kieran Bingham
  2017-04-03 16:09 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Kieran Bingham @ 2017-04-03 11:25 UTC (permalink / raw)
  To: laurent.pinchart; +Cc: linux-media, Kieran Bingham

From: Kieran Bingham <kieran.bingham@ideasonboard.com>

The statistics function subtracts two timespecs manually. A helper is
provided by the kernel to do this.

Replace the implementation, using the helper.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 drivers/media/usb/uvc/uvc_video.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 7777ed24908b..cff02c6df1b8 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -868,14 +868,8 @@ size_t uvc_video_stats_dump(struct uvc_streaming *stream, char *buf,
 	struct timespec ts;
 	size_t count = 0;
 
-	ts.tv_sec = stream->stats.stream.stop_ts.tv_sec
-		  - stream->stats.stream.start_ts.tv_sec;
-	ts.tv_nsec = stream->stats.stream.stop_ts.tv_nsec
-		   - stream->stats.stream.start_ts.tv_nsec;
-	if (ts.tv_nsec < 0) {
-		ts.tv_sec--;
-		ts.tv_nsec += 1000000000;
-	}
+	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.
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] uvcvideo: don't recode timespec_sub
  2017-04-03 11:25 [PATCH] uvcvideo: don't recode timespec_sub Kieran Bingham
@ 2017-04-03 16:09 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2017-04-03 16:09 UTC (permalink / raw)
  To: Kieran Bingham; +Cc: linux-media, Kieran Bingham

Hi Kieran,

Thank you for the patch.

On Monday 03 Apr 2017 12:25:31 Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> The statistics function subtracts two timespecs manually. A helper is
> provided by the kernel to do this.
> 
> Replace the implementation, using the helper.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

and applied to my tree.

> ---
>  drivers/media/usb/uvc/uvc_video.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_video.c
> b/drivers/media/usb/uvc/uvc_video.c index 7777ed24908b..cff02c6df1b8 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -868,14 +868,8 @@ size_t uvc_video_stats_dump(struct uvc_streaming
> *stream, char *buf, struct timespec ts;
>  	size_t count = 0;
> 
> -	ts.tv_sec = stream->stats.stream.stop_ts.tv_sec
> -		  - stream->stats.stream.start_ts.tv_sec;
> -	ts.tv_nsec = stream->stats.stream.stop_ts.tv_nsec
> -		   - stream->stats.stream.start_ts.tv_nsec;
> -	if (ts.tv_nsec < 0) {
> -		ts.tv_sec--;
> -		ts.tv_nsec += 1000000000;
> -	}
> +	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.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-03 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-03 11:25 [PATCH] uvcvideo: don't recode timespec_sub Kieran Bingham
2017-04-03 16:09 ` Laurent Pinchart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.