Skip to contentSkip to conversation

uvcvideo: don't recode timespec_sub

PATCH In review Kieran Bingham 2 participants 2 messages Apr 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uvcvideo: don't recode timespec_sub

From: Kieran Bingham <[email protected]>

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

Replace the implementation, using the helper.

---
 drivers/media/usb/uvc/uvc_video.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/media/usb/uvc/uvc_video.c +2 -8
index 7777ed24908b..cff02c6df1b8 100644
@@ -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.
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Kieran,

Thank you for the patch.

Quoted 8 lines · On Monday 03 Apr 2017 12:25:31 Kieran Bingham wrote:

From: Kieran Bingham <[email protected]>

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

Replace the implementation, using the helper.

and applied to my tree.

Quoted 25 lines
---
 drivers/media/usb/uvc/uvc_video.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/media/usb/uvc/uvc_video.c index 7777ed24908b..cff02c6df1b8 100644

drivers/media/usb/uvc/uvc_video.c +2 -8
@@ -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.
Signature · 3 lines
Regards,

Laurent Pinchart