Skip to content

Commit f262ce6

Browse files
mgrzeschikgregkh
authored andcommitted
usb: gadget: uvc: use on returned header len in video_encode_isoc_sg
The function uvc_video_encode_header function returns the number of bytes used for the header. We change the video_encode_isoc_sg function to use the returned header_len rather than UVCG_REQUEST_HEADER_LEN and make the encode function more flexible. Signed-off-by: Michael Grzeschik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d9f2734 commit f262ce6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/usb/gadget/function/uvc_video.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,22 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video,
104104
unsigned int len = video->req_size;
105105
unsigned int sg_left, part = 0;
106106
unsigned int i;
107-
int ret;
107+
int header_len;
108108

109109
sg = ureq->sgt.sgl;
110110
sg_init_table(sg, ureq->sgt.nents);
111111

112112
/* Init the header. */
113-
ret = uvc_video_encode_header(video, buf, ureq->header,
113+
header_len = uvc_video_encode_header(video, buf, ureq->header,
114114
video->req_size);
115-
sg_set_buf(sg, ureq->header, UVCG_REQUEST_HEADER_LEN);
116-
len -= ret;
115+
sg_set_buf(sg, ureq->header, header_len);
116+
len -= header_len;
117117

118118
if (pending <= len)
119119
len = pending;
120120

121121
req->length = (len == pending) ?
122-
len + UVCG_REQUEST_HEADER_LEN : video->req_size;
122+
len + header_len : video->req_size;
123123

124124
/* Init the pending sgs with payload */
125125
sg = sg_next(sg);
@@ -148,7 +148,7 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video,
148148
req->num_sgs = i + 1;
149149

150150
req->length -= len;
151-
video->queue.buf_used += req->length - UVCG_REQUEST_HEADER_LEN;
151+
video->queue.buf_used += req->length - header_len;
152152

153153
if (buf->bytesused == video->queue.buf_used || !buf->sg) {
154154
video->queue.buf_used = 0;

0 commit comments

Comments
 (0)