All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: laurent.pinchart@ideasonboard.com
Cc: gregkh@linuxfoundation.org, mchehab@kernel.org,
	hverkuil-cisco@xs4all.nl, linux-usb@vger.kernel.org,
	linux-media@vger.kernel.org, kernel@pengutronix.de,
	Daniel Scally <dan.scally@ideasonboard.com>
Subject: [PATCH v3 4/5] usb: uvc: make uvc_format_desc table const
Date: Fri, 27 Jan 2023 00:14:55 +0100	[thread overview]
Message-ID: <20230126231456.3402323-5-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20230126231456.3402323-1-m.grzeschik@pengutronix.de>

Since the uvc_fmts array can not be modified we declare it const and
change every user of the uvc_format_by_guid function aswell.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Tested-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v1 -> v2: - added reviewed and tested tags
v2 -> v3: - no changes

 drivers/media/common/uvc.c             | 4 ++--
 drivers/media/usb/uvc/uvc_driver.c     | 2 +-
 drivers/usb/gadget/function/uvc_v4l2.c | 8 ++++----
 include/linux/usb/uvc.h                | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/common/uvc.c b/drivers/media/common/uvc.c
index bb96d9e26d8019..2b4df3e8f48aa6 100644
--- a/drivers/media/common/uvc.c
+++ b/drivers/media/common/uvc.c
@@ -11,7 +11,7 @@
  * Video formats
  */
 
-static struct uvc_format_desc uvc_fmts[] = {
+static const struct uvc_format_desc uvc_fmts[] = {
 	{
 		.name		= "YUV 4:2:2 (YUYV)",
 		.guid		= UVC_GUID_FORMAT_YUY2,
@@ -204,7 +204,7 @@ static struct uvc_format_desc uvc_fmts[] = {
 	},
 };
 
-struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16])
+const struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16])
 {
 	unsigned int len = ARRAY_SIZE(uvc_fmts);
 	unsigned int i;
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index edf8c4a201a8ab..7aefa76a42b316 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -225,7 +225,7 @@ static int uvc_parse_format(struct uvc_device *dev,
 {
 	struct usb_interface *intf = streaming->intf;
 	struct usb_host_interface *alts = intf->cur_altsetting;
-	struct uvc_format_desc *fmtdesc;
+	const struct uvc_format_desc *fmtdesc;
 	struct uvc_frame *frame;
 	const unsigned char *start = buffer;
 	unsigned int width_multiplier = 1;
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 7435df0cf2a847..21e573e628f4e7 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -27,10 +27,10 @@
 #include "uvc_v4l2.h"
 #include "uvc_configfs.h"
 
-static struct uvc_format_desc *to_uvc_format(struct uvcg_format *uformat)
+static const struct uvc_format_desc *to_uvc_format(struct uvcg_format *uformat)
 {
 	char guid[16] = UVC_GUID_FORMAT_MJPEG;
-	struct uvc_format_desc *format;
+	const struct uvc_format_desc *format;
 	struct uvcg_uncompressed *unc;
 
 	if (uformat->type == UVCG_UNCOMPRESSED) {
@@ -119,7 +119,7 @@ static struct uvcg_format *find_format_by_pix(struct uvc_device *uvc,
 	struct uvcg_format *uformat = NULL;
 
 	list_for_each_entry(format, &uvc->header->formats, entry) {
-		struct uvc_format_desc *fmtdesc = to_uvc_format(format->fmt);
+		const struct uvc_format_desc *fmtdesc = to_uvc_format(format->fmt);
 
 		if (fmtdesc->fcc == pixelformat) {
 			uformat = format->fmt;
@@ -364,7 +364,7 @@ uvc_v4l2_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
 {
 	struct video_device *vdev = video_devdata(file);
 	struct uvc_device *uvc = video_get_drvdata(vdev);
-	struct uvc_format_desc *fmtdesc;
+	const struct uvc_format_desc *fmtdesc;
 	struct uvcg_format *uformat;
 
 	if (f->index >= uvc->header->num_fmt)
diff --git a/include/linux/usb/uvc.h b/include/linux/usb/uvc.h
index 8cebb46602a118..b0210c5c5406b3 100644
--- a/include/linux/usb/uvc.h
+++ b/include/linux/usb/uvc.h
@@ -154,6 +154,6 @@ struct uvc_format_desc {
 	u32 fcc;
 };
 
-struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16]);
+const struct uvc_format_desc *uvc_format_by_guid(const u8 guid[16]);
 
 #endif /* __LINUX_V4L2_UVC_H */
-- 
2.30.2


  parent reply	other threads:[~2023-01-26 23:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 23:14 [PATCH v3 0/5] [PATCH v3] usb: uvc: improve header files and function use Michael Grzeschik
2023-01-26 23:14 ` [PATCH v3 1/5] media: uvcvideo: Add GUID for BGRA/X 8:8:8:8 Michael Grzeschik
2023-01-26 23:14 ` [PATCH v3 2/5] usb: uvc: move media/v4l2-uvc.h to usb/uvc.h Michael Grzeschik
2023-01-26 23:14 ` [PATCH v3 3/5] usb: uvc: move uvc_fmts and uvc_format_by_guid to own compile unit Michael Grzeschik
2023-01-26 23:14 ` Michael Grzeschik [this message]
2023-01-26 23:14 ` [PATCH v3 5/5] usb: uvc: use v4l2_fill_fmtdesc instead of open coded format name Michael Grzeschik
2023-01-26 23:26   ` Laurent Pinchart
2023-01-31  8:41 ` [PATCH v3 0/5] [PATCH v3] usb: uvc: improve header files and function use Greg KH

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=20230126231456.3402323-5-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=dan.scally@ideasonboard.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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.