aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-08-10 08:48:02 -0400
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-09-25 11:41:00 -0400
commitdc0f755b421d5aac9052f43c9d0e7285607d446c (patch)
tree4cd86aff472490e5fd3e3bc844b208e94d380ccf /drivers/usb/gadget
parent8dbf9c7abefd5c1434a956d5c6b25e11183061a3 (diff)
usb: gadget: uvc: Replace plain printk() with dev_*()
Adding device context to the kernel log messages make them more useful. Add new uvcg_* macros based on dev_*() that print both the gadget device name and the function name. While at it, remove a commented out printk statement and an unused printk-based macro. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/function/f_uvc.c41
-rw-r--r--drivers/usb/gadget/function/uvc.h16
-rw-r--r--drivers/usb/gadget/function/uvc_v4l2.c4
-rw-r--r--drivers/usb/gadget/function/uvc_video.c18
-rw-r--r--drivers/usb/gadget/function/uvc_video.h2
5 files changed, 39 insertions, 42 deletions
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 4ea987741e6e..0cc4a6220050 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -232,13 +232,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
232 struct v4l2_event v4l2_event; 232 struct v4l2_event v4l2_event;
233 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; 233 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
234 234
235 /* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n",
236 * ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue),
237 * le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength));
238 */
239
240 if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) { 235 if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) {
241 INFO(f->config->cdev, "invalid request type\n"); 236 uvcg_info(f, "invalid request type\n");
242 return -EINVAL; 237 return -EINVAL;
243 } 238 }
244 239
@@ -272,7 +267,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
272{ 267{
273 struct uvc_device *uvc = to_uvc(f); 268 struct uvc_device *uvc = to_uvc(f);
274 269
275 INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface); 270 uvcg_info(f, "%s(%u)\n", __func__, interface);
276 271
277 if (interface == uvc->control_intf) 272 if (interface == uvc->control_intf)
278 return 0; 273 return 0;
@@ -291,13 +286,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
291 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; 286 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
292 int ret; 287 int ret;
293 288
294 INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); 289 uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt);
295 290
296 if (interface == uvc->control_intf) { 291 if (interface == uvc->control_intf) {
297 if (alt) 292 if (alt)
298 return -EINVAL; 293 return -EINVAL;
299 294
300 INFO(cdev, "reset UVC Control\n"); 295 uvcg_info(f, "reset UVC Control\n");
301 usb_ep_disable(uvc->control_ep); 296 usb_ep_disable(uvc->control_ep);
302 297
303 if (!uvc->control_ep->desc) 298 if (!uvc->control_ep->desc)
@@ -348,7 +343,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
348 if (!uvc->video.ep) 343 if (!uvc->video.ep)
349 return -EINVAL; 344 return -EINVAL;
350 345
351 INFO(cdev, "reset UVC\n"); 346 uvcg_info(f, "reset UVC\n");
352 usb_ep_disable(uvc->video.ep); 347 usb_ep_disable(uvc->video.ep);
353 348
354 ret = config_ep_by_speed(f->config->cdev->gadget, 349 ret = config_ep_by_speed(f->config->cdev->gadget,
@@ -373,7 +368,7 @@ uvc_function_disable(struct usb_function *f)
373 struct uvc_device *uvc = to_uvc(f); 368 struct uvc_device *uvc = to_uvc(f);
374 struct v4l2_event v4l2_event; 369 struct v4l2_event v4l2_event;
375 370
376 INFO(f->config->cdev, "uvc_function_disable\n"); 371 uvcg_info(f, "%s()\n", __func__);
377 372
378 memset(&v4l2_event, 0, sizeof(v4l2_event)); 373 memset(&v4l2_event, 0, sizeof(v4l2_event));
379 v4l2_event.type = UVC_EVENT_DISCONNECT; 374 v4l2_event.type = UVC_EVENT_DISCONNECT;
@@ -392,21 +387,19 @@ uvc_function_disable(struct usb_function *f)
392void 387void
393uvc_function_connect(struct uvc_device *uvc) 388uvc_function_connect(struct uvc_device *uvc)
394{ 389{
395 struct usb_composite_dev *cdev = uvc->func.config->cdev;
396 int ret; 390 int ret;
397 391
398 if ((ret = usb_function_activate(&uvc->func)) < 0) 392 if ((ret = usb_function_activate(&uvc->func)) < 0)
399 INFO(cdev, "UVC connect failed with %d\n", ret); 393 uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
400} 394}
401 395
402void 396void
403uvc_function_disconnect(struct uvc_device *uvc) 397uvc_function_disconnect(struct uvc_device *uvc)
404{ 398{
405 struct usb_composite_dev *cdev = uvc->func.config->cdev;
406 int ret; 399 int ret;
407 400
408 if ((ret = usb_function_deactivate(&uvc->func)) < 0) 401 if ((ret = usb_function_deactivate(&uvc->func)) < 0)
409 INFO(cdev, "UVC disconnect failed with %d\n", ret); 402 uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
410} 403}
411 404
412/* -------------------------------------------------------------------------- 405/* --------------------------------------------------------------------------
@@ -605,7 +598,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
605 struct f_uvc_opts *opts; 598 struct f_uvc_opts *opts;
606 int ret = -EINVAL; 599 int ret = -EINVAL;
607 600
608 INFO(cdev, "uvc_function_bind\n"); 601 uvcg_info(f, "%s()\n", __func__);
609 602
610 opts = fi_to_f_uvc_opts(f->fi); 603 opts = fi_to_f_uvc_opts(f->fi);
611 /* Sanity check the streaming endpoint module parameters. 604 /* Sanity check the streaming endpoint module parameters.
@@ -618,8 +611,8 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
618 if (opts->streaming_maxburst && 611 if (opts->streaming_maxburst &&
619 (opts->streaming_maxpacket % 1024) != 0) { 612 (opts->streaming_maxpacket % 1024) != 0) {
620 opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024); 613 opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024);
621 INFO(cdev, "overriding streaming_maxpacket to %d\n", 614 uvcg_info(f, "overriding streaming_maxpacket to %d\n",
622 opts->streaming_maxpacket); 615 opts->streaming_maxpacket);
623 } 616 }
624 617
625 /* Fill in the FS/HS/SS Video Streaming specific descriptors from the 618 /* Fill in the FS/HS/SS Video Streaming specific descriptors from the
@@ -658,7 +651,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
658 /* Allocate endpoints. */ 651 /* Allocate endpoints. */
659 ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); 652 ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
660 if (!ep) { 653 if (!ep) {
661 INFO(cdev, "Unable to allocate control EP\n"); 654 uvcg_info(f, "Unable to allocate control EP\n");
662 goto error; 655 goto error;
663 } 656 }
664 uvc->control_ep = ep; 657 uvc->control_ep = ep;
@@ -672,7 +665,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
672 ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); 665 ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep);
673 666
674 if (!ep) { 667 if (!ep) {
675 INFO(cdev, "Unable to allocate streaming EP\n"); 668 uvcg_info(f, "Unable to allocate streaming EP\n");
676 goto error; 669 goto error;
677 } 670 }
678 uvc->video.ep = ep; 671 uvc->video.ep = ep;
@@ -745,19 +738,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
745 uvc->control_req->context = uvc; 738 uvc->control_req->context = uvc;
746 739
747 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { 740 if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
748 printk(KERN_INFO "v4l2_device_register failed\n"); 741 uvcg_err(f, "failed to register V4L2 device\n");
749 goto error; 742 goto error;
750 } 743 }
751 744
752 /* Initialise video. */ 745 /* Initialise video. */
753 ret = uvcg_video_init(&uvc->video); 746 ret = uvcg_video_init(&uvc->video, uvc);
754 if (ret < 0) 747 if (ret < 0)
755 goto error; 748 goto error;
756 749
757 /* Register a V4L2 device. */ 750 /* Register a V4L2 device. */
758 ret = uvc_register_video(uvc); 751 ret = uvc_register_video(uvc);
759 if (ret < 0) { 752 if (ret < 0) {
760 printk(KERN_INFO "Unable to register video device\n"); 753 uvcg_err(f, "failed to register video device\n");
761 goto error; 754 goto error;
762 } 755 }
763 756
@@ -894,7 +887,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f)
894 struct usb_composite_dev *cdev = c->cdev; 887 struct usb_composite_dev *cdev = c->cdev;
895 struct uvc_device *uvc = to_uvc(f); 888 struct uvc_device *uvc = to_uvc(f);
896 889
897 INFO(cdev, "%s\n", __func__); 890 uvcg_info(f, "%s\n", __func__);
898 891
899 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); 892 device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
900 video_unregister_device(&uvc->vdev); 893 video_unregister_device(&uvc->vdev);
diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h
index 93cf78b420fe..099d650082e5 100644
--- a/drivers/usb/gadget/function/uvc.h
+++ b/drivers/usb/gadget/function/uvc.h
@@ -24,6 +24,7 @@
24struct usb_ep; 24struct usb_ep;
25struct usb_request; 25struct usb_request;
26struct uvc_descriptor_header; 26struct uvc_descriptor_header;
27struct uvc_device;
27 28
28/* ------------------------------------------------------------------------ 29/* ------------------------------------------------------------------------
29 * Debugging, printing and logging 30 * Debugging, printing and logging
@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param;
51 printk(KERN_DEBUG "uvcvideo: " msg); \ 52 printk(KERN_DEBUG "uvcvideo: " msg); \
52 } while (0) 53 } while (0)
53 54
54#define uvc_warn_once(dev, warn, msg...) \ 55#define uvcg_dbg(f, fmt, args...) \
55 do { \ 56 dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
56 if (!test_and_set_bit(warn, &dev->warnings)) \ 57#define uvcg_info(f, fmt, args...) \
57 printk(KERN_INFO "uvcvideo: " msg); \ 58 dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
58 } while (0) 59#define uvcg_err(f, fmt, args...) \
59 60 dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
60#define uvc_printk(level, msg...) \
61 printk(level "uvcvideo: " msg)
62 61
63/* ------------------------------------------------------------------------ 62/* ------------------------------------------------------------------------
64 * Driver specific constants 63 * Driver specific constants
@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param;
73 */ 72 */
74 73
75struct uvc_video { 74struct uvc_video {
75 struct uvc_device *uvc;
76 struct usb_ep *ep; 76 struct usb_ep *ep;
77 77
78 /* Frame parameters */ 78 /* Frame parameters */
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index 7f1ca3b57823..a1183eccee22 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -115,8 +115,8 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
115 } 115 }
116 116
117 if (i == ARRAY_SIZE(uvc_formats)) { 117 if (i == ARRAY_SIZE(uvc_formats)) {
118 printk(KERN_INFO "Unsupported format 0x%08x.\n", 118 uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
119 fmt->fmt.pix.pixelformat); 119 fmt->fmt.pix.pixelformat);
120 return -EINVAL; 120 return -EINVAL;
121 } 121 }
122 122
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 2c9821ec836e..5c042f380708 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -131,7 +131,9 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req)
131 131
132 ret = usb_ep_queue(video->ep, req, GFP_ATOMIC); 132 ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
133 if (ret < 0) { 133 if (ret < 0) {
134 printk(KERN_INFO "Failed to queue request (%d).\n", ret); 134 uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n",
135 ret);
136
135 /* Isochronous endpoints can't be halted. */ 137 /* Isochronous endpoints can't be halted. */
136 if (usb_endpoint_xfer_bulk(video->ep->desc)) 138 if (usb_endpoint_xfer_bulk(video->ep->desc))
137 usb_ep_set_halt(video->ep); 139 usb_ep_set_halt(video->ep);
@@ -184,13 +186,14 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
184 break; 186 break;
185 187
186 case -ESHUTDOWN: /* disconnect from host. */ 188 case -ESHUTDOWN: /* disconnect from host. */
187 printk(KERN_DEBUG "VS request cancelled.\n"); 189 uvcg_dbg(&video->uvc->func, "VS request cancelled.\n");
188 uvcg_queue_cancel(queue, 1); 190 uvcg_queue_cancel(queue, 1);
189 goto requeue; 191 goto requeue;
190 192
191 default: 193 default:
192 printk(KERN_INFO "VS request completed with status %d.\n", 194 uvcg_info(&video->uvc->func,
193 req->status); 195 "VS request completed with status %d.\n",
196 req->status);
194 uvcg_queue_cancel(queue, 0); 197 uvcg_queue_cancel(queue, 0);
195 goto requeue; 198 goto requeue;
196 } 199 }
@@ -354,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
354 int ret; 357 int ret;
355 358
356 if (video->ep == NULL) { 359 if (video->ep == NULL) {
357 printk(KERN_INFO "Video enable failed, device is " 360 uvcg_info(&video->uvc->func,
358 "uninitialized.\n"); 361 "Video enable failed, device is uninitialized.\n");
359 return -ENODEV; 362 return -ENODEV;
360 } 363 }
361 364
@@ -387,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
387/* 390/*
388 * Initialize the UVC video stream. 391 * Initialize the UVC video stream.
389 */ 392 */
390int uvcg_video_init(struct uvc_video *video) 393int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
391{ 394{
392 INIT_LIST_HEAD(&video->req_free); 395 INIT_LIST_HEAD(&video->req_free);
393 spin_lock_init(&video->req_lock); 396 spin_lock_init(&video->req_lock);
394 397
398 video->uvc = uvc;
395 video->fcc = V4L2_PIX_FMT_YUYV; 399 video->fcc = V4L2_PIX_FMT_YUYV;
396 video->bpp = 16; 400 video->bpp = 16;
397 video->width = 320; 401 video->width = 320;
diff --git a/drivers/usb/gadget/function/uvc_video.h b/drivers/usb/gadget/function/uvc_video.h
index 7d77122b0ff9..278dc52c7604 100644
--- a/drivers/usb/gadget/function/uvc_video.h
+++ b/drivers/usb/gadget/function/uvc_video.h
@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video);
18 18
19int uvcg_video_enable(struct uvc_video *video, int enable); 19int uvcg_video_enable(struct uvc_video *video, int enable);
20 20
21int uvcg_video_init(struct uvc_video *video); 21int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
22 22
23#endif /* __UVC_VIDEO_H__ */ 23#endif /* __UVC_VIDEO_H__ */