Commit 8ecb17a8 authored by Michael Grzeschik's avatar Michael Grzeschik Committed by Greg Kroah-Hartman

usb: uvc: make uvc_format_desc table const

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarDaniel Scally <dan.scally@ideasonboard.com>
Tested-by: default avatarDaniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: default avatarMichael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20230126231456.3402323-5-m.grzeschik@pengutronix.deSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 466be4c9
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Video formats * Video formats
*/ */
static struct uvc_format_desc uvc_fmts[] = { static const struct uvc_format_desc uvc_fmts[] = {
{ {
.name = "YUV 4:2:2 (YUYV)", .name = "YUV 4:2:2 (YUYV)",
.guid = UVC_GUID_FORMAT_YUY2, .guid = UVC_GUID_FORMAT_YUY2,
...@@ -204,7 +204,7 @@ static struct uvc_format_desc uvc_fmts[] = { ...@@ -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 len = ARRAY_SIZE(uvc_fmts);
unsigned int i; unsigned int i;
......
...@@ -225,7 +225,7 @@ static int uvc_parse_format(struct uvc_device *dev, ...@@ -225,7 +225,7 @@ static int uvc_parse_format(struct uvc_device *dev,
{ {
struct usb_interface *intf = streaming->intf; struct usb_interface *intf = streaming->intf;
struct usb_host_interface *alts = intf->cur_altsetting; struct usb_host_interface *alts = intf->cur_altsetting;
struct uvc_format_desc *fmtdesc; const struct uvc_format_desc *fmtdesc;
struct uvc_frame *frame; struct uvc_frame *frame;
const unsigned char *start = buffer; const unsigned char *start = buffer;
unsigned int width_multiplier = 1; unsigned int width_multiplier = 1;
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#include "uvc_v4l2.h" #include "uvc_v4l2.h"
#include "uvc_configfs.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; char guid[16] = UVC_GUID_FORMAT_MJPEG;
struct uvc_format_desc *format; const struct uvc_format_desc *format;
struct uvcg_uncompressed *unc; struct uvcg_uncompressed *unc;
if (uformat->type == UVCG_UNCOMPRESSED) { if (uformat->type == UVCG_UNCOMPRESSED) {
...@@ -119,7 +119,7 @@ static struct uvcg_format *find_format_by_pix(struct uvc_device *uvc, ...@@ -119,7 +119,7 @@ static struct uvcg_format *find_format_by_pix(struct uvc_device *uvc,
struct uvcg_format *uformat = NULL; struct uvcg_format *uformat = NULL;
list_for_each_entry(format, &uvc->header->formats, entry) { 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) { if (fmtdesc->fcc == pixelformat) {
uformat = format->fmt; uformat = format->fmt;
...@@ -364,7 +364,7 @@ uvc_v4l2_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f) ...@@ -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 video_device *vdev = video_devdata(file);
struct uvc_device *uvc = video_get_drvdata(vdev); struct uvc_device *uvc = video_get_drvdata(vdev);
struct uvc_format_desc *fmtdesc; const struct uvc_format_desc *fmtdesc;
struct uvcg_format *uformat; struct uvcg_format *uformat;
if (f->index >= uvc->header->num_fmt) if (f->index >= uvc->header->num_fmt)
......
...@@ -154,6 +154,6 @@ struct uvc_format_desc { ...@@ -154,6 +154,6 @@ struct uvc_format_desc {
u32 fcc; 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 */ #endif /* __LINUX_V4L2_UVC_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment