From b41bb4ac6a18c7cacab53e27c11058f71866e6e0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 23 May 2018 23:41:30 +0300 Subject: uvc-gadget: Constify request data pointers The request data passed from the UVC event handler to processing functions should never be modified. Make it const through the code. Signed-off-by: Laurent Pinchart --- uvc-gadget.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/uvc-gadget.c b/uvc-gadget.c index b1c4eeb..560687f 100644 --- a/uvc-gadget.c +++ b/uvc-gadget.c @@ -302,7 +302,8 @@ uvc_fill_streaming_control(struct uvc_device *dev, } static void -uvc_events_process_standard(struct uvc_device *dev, struct usb_ctrlrequest *ctrl, +uvc_events_process_standard(struct uvc_device *dev, + const struct usb_ctrlrequest *ctrl, struct uvc_request_data *resp) { printf("standard request\n"); @@ -372,7 +373,8 @@ uvc_events_process_streaming(struct uvc_device *dev, uint8_t req, uint8_t cs, } static void -uvc_events_process_class(struct uvc_device *dev, struct usb_ctrlrequest *ctrl, +uvc_events_process_class(struct uvc_device *dev, + const struct usb_ctrlrequest *ctrl, struct uvc_request_data *resp) { if ((ctrl->bRequestType & USB_RECIP_MASK) != USB_RECIP_INTERFACE) @@ -393,7 +395,8 @@ uvc_events_process_class(struct uvc_device *dev, struct usb_ctrlrequest *ctrl, } static void -uvc_events_process_setup(struct uvc_device *dev, struct usb_ctrlrequest *ctrl, +uvc_events_process_setup(struct uvc_device *dev, + const struct usb_ctrlrequest *ctrl, struct uvc_request_data *resp) { dev->control = 0; @@ -417,10 +420,12 @@ uvc_events_process_setup(struct uvc_device *dev, struct usb_ctrlrequest *ctrl, } static void -uvc_events_process_data(struct uvc_device *dev, struct uvc_request_data *data) +uvc_events_process_data(struct uvc_device *dev, + const struct uvc_request_data *data) { + const struct uvc_streaming_control *ctrl = + (const struct uvc_streaming_control *)&data->data; struct uvc_streaming_control *target; - struct uvc_streaming_control *ctrl; switch (dev->control) { case UVC_VS_PROBE_CONTROL: @@ -438,8 +443,6 @@ uvc_events_process_data(struct uvc_device *dev, struct uvc_request_data *data) return; } - ctrl = (struct uvc_streaming_control *)&data->data; - uvc_fill_streaming_control(dev, target, ctrl->bFormatIndex, ctrl->bFrameIndex, ctrl->dwFrameInterval); @@ -465,7 +468,7 @@ uvc_events_process(void *d) { struct uvc_device *dev = d; struct v4l2_event v4l2_event; - struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; + const struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; struct uvc_request_data resp; int ret; -- cgit v1.2.3