From d80db2f1450c50cdc794cda1ef02bac4e8a761ca Mon Sep 17 00:00:00 2001 From: Michael Grzeschik Date: Mon, 18 Oct 2021 09:20:59 +0200 Subject: [PATCH] usb: gadget: uvc: consistently use define for headerlen commit 859c675d84d488e2f9b515c713ea890c9f045f0c upstream. The uvc request headerlen of 2 was defined as UVCG_REQUEST_HEADER_LEN in commit e81e7f9a0eb9 ("usb: gadget: uvc: add scatter gather support"). We missed to use it consistently. This patch fixes that. Reviewed-by: Paul Elder Signed-off-by: Michael Grzeschik Link: https://lore.kernel.org/r/20211018072059.11465-1-m.grzeschik@pengutronix.de Reviewed-by: Laurent Pinchart Cc: Dan Vacura Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/uvc.h | 4 +++- drivers/usb/gadget/function/uvc_video.c | 6 +++--- drivers/usb/gadget/function/uvc_video.h | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index 0966c5a..97271119 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -69,6 +69,8 @@ extern unsigned int uvc_gadget_trace_param; #define UVC_MAX_REQUEST_SIZE 64 #define UVC_MAX_EVENTS 4 +#define UVCG_REQUEST_HEADER_LEN 2 + /* ------------------------------------------------------------------------ * Structures */ @@ -77,7 +79,7 @@ struct uvc_request { u8 *req_buffer; struct uvc_video *video; struct sg_table sgt; - u8 header[2]; + u8 header[UVCG_REQUEST_HEADER_LEN]; }; struct uvc_video { diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index e170e88..d222200 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -33,7 +33,7 @@ uvc_video_encode_header(struct uvc_video *video, struct uvc_buffer *buf, if (buf->bytesused - video->queue.buf_used <= len - UVCG_REQUEST_HEADER_LEN) data[1] |= UVC_STREAM_EOF; - return 2; + return UVCG_REQUEST_HEADER_LEN; } static int @@ -302,8 +302,8 @@ uvc_video_alloc_requests(struct uvc_video *video) list_add_tail(&video->ureq[i].req->list, &video->req_free); /* req_size/PAGE_SIZE + 1 for overruns and + 1 for header */ sg_alloc_table(&video->ureq[i].sgt, - DIV_ROUND_UP(req_size - 2, PAGE_SIZE) + 2, - GFP_KERNEL); + DIV_ROUND_UP(req_size - UVCG_REQUEST_HEADER_LEN, + PAGE_SIZE) + 2, GFP_KERNEL); } video->req_size = req_size; diff --git a/drivers/usb/gadget/function/uvc_video.h b/drivers/usb/gadget/function/uvc_video.h index 9bf1947..03adeef 100644 --- a/drivers/usb/gadget/function/uvc_video.h +++ b/drivers/usb/gadget/function/uvc_video.h @@ -12,8 +12,6 @@ #ifndef __UVC_VIDEO_H__ #define __UVC_VIDEO_H__ -#define UVCG_REQUEST_HEADER_LEN 2 - struct uvc_video; int uvcg_video_enable(struct uvc_video *video, int enable); -- 2.7.4