All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, laurent.pinchart@ideasonboard.com,
	paul.elder@ideasonboard.com, kernel@pengutronix.de
Subject: [PATCH] usb: gadget: uvc: consistently use define for headerlen
Date: Mon, 18 Oct 2021 02:11:39 +0200	[thread overview]
Message-ID: <20211018001139.29284-1-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20211017215017.18392-2-m.grzeschik@pengutronix.de>

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 <paul.elder@ideasonboard.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v3: - fixed wrong use of define
    - added missing use of define in uvc_video_encode_header
v4: - fixed headersize in struct uvc_request to also use the define

 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 9d5f17b551bbd..c3607a32b9862 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -68,6 +68,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
  */
@@ -76,7 +78,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 1bfca3cb42f9b..7bc865eab27b3 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
@@ -307,8 +307,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 9bf19475f6f9a..03adeefa343b7 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.30.2


  reply	other threads:[~2021-10-18  0:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-17 21:50 [PATCH v3 0/6] usb: gadget: uvc: smaller fixes for stability Michael Grzeschik
2021-10-17 21:50 ` [PATCH v3 1/6] usb: gadget: uvc: consistently use define for headerlen Michael Grzeschik
2021-10-18  0:11   ` Michael Grzeschik [this message]
2021-10-18  7:20     ` [PATCH] " Michael Grzeschik
2021-10-18  7:20   ` [PATCH v4] " Michael Grzeschik
2021-10-18  7:45     ` Laurent Pinchart
2021-10-17 21:50 ` [PATCH v3 2/6] usb: gadget: uvc: rename function to be more consistent Michael Grzeschik
2021-10-17 21:50 ` [PATCH v3 3/6] usb: gadget: uvc: test if ep->desc is valid on ep_queue Michael Grzeschik
2021-10-17 21:50 ` [PATCH v3 4/6] usb: gadget: uvc: only schedule stream in streaming state Michael Grzeschik
2021-10-17 21:50 ` [PATCH v3 5/6] usb: gadget: uvc: only pump video data if necessary Michael Grzeschik
2021-10-17 21:50 ` [PATCH v3 6/6] usb: gadget: uvc: ensure the vdev is unset Michael Grzeschik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018001139.29284-1-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=balbi@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul.elder@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.