Commit dc0f755b authored by Laurent Pinchart's avatar Laurent Pinchart

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: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarPaul Elder <paul.elder@ideasonboard.com>
Tested-by: default avatarPaul Elder <paul.elder@ideasonboard.com>
Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
parent 8dbf9c7a
No related merge requests found
...@@ -232,13 +232,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) ...@@ -232,13 +232,8 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
struct v4l2_event v4l2_event; struct v4l2_event v4l2_event;
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
/* printk(KERN_INFO "setup request %02x %02x value %04x index %04x %04x\n",
* ctrl->bRequestType, ctrl->bRequest, le16_to_cpu(ctrl->wValue),
* le16_to_cpu(ctrl->wIndex), le16_to_cpu(ctrl->wLength));
*/
if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) { if ((ctrl->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) {
INFO(f->config->cdev, "invalid request type\n"); uvcg_info(f, "invalid request type\n");
return -EINVAL; return -EINVAL;
} }
...@@ -272,7 +267,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface) ...@@ -272,7 +267,7 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
{ {
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
INFO(f->config->cdev, "uvc_function_get_alt(%u)\n", interface); uvcg_info(f, "%s(%u)\n", __func__, interface);
if (interface == uvc->control_intf) if (interface == uvc->control_intf)
return 0; return 0;
...@@ -291,13 +286,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) ...@@ -291,13 +286,13 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
int ret; int ret;
INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); uvcg_info(f, "%s(%u, %u)\n", __func__, interface, alt);
if (interface == uvc->control_intf) { if (interface == uvc->control_intf) {
if (alt) if (alt)
return -EINVAL; return -EINVAL;
INFO(cdev, "reset UVC Control\n"); uvcg_info(f, "reset UVC Control\n");
usb_ep_disable(uvc->control_ep); usb_ep_disable(uvc->control_ep);
if (!uvc->control_ep->desc) if (!uvc->control_ep->desc)
...@@ -348,7 +343,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) ...@@ -348,7 +343,7 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
if (!uvc->video.ep) if (!uvc->video.ep)
return -EINVAL; return -EINVAL;
INFO(cdev, "reset UVC\n"); uvcg_info(f, "reset UVC\n");
usb_ep_disable(uvc->video.ep); usb_ep_disable(uvc->video.ep);
ret = config_ep_by_speed(f->config->cdev->gadget, ret = config_ep_by_speed(f->config->cdev->gadget,
...@@ -373,7 +368,7 @@ uvc_function_disable(struct usb_function *f) ...@@ -373,7 +368,7 @@ uvc_function_disable(struct usb_function *f)
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
struct v4l2_event v4l2_event; struct v4l2_event v4l2_event;
INFO(f->config->cdev, "uvc_function_disable\n"); uvcg_info(f, "%s()\n", __func__);
memset(&v4l2_event, 0, sizeof(v4l2_event)); memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_DISCONNECT; v4l2_event.type = UVC_EVENT_DISCONNECT;
...@@ -392,21 +387,19 @@ uvc_function_disable(struct usb_function *f) ...@@ -392,21 +387,19 @@ uvc_function_disable(struct usb_function *f)
void void
uvc_function_connect(struct uvc_device *uvc) uvc_function_connect(struct uvc_device *uvc)
{ {
struct usb_composite_dev *cdev = uvc->func.config->cdev;
int ret; int ret;
if ((ret = usb_function_activate(&uvc->func)) < 0) if ((ret = usb_function_activate(&uvc->func)) < 0)
INFO(cdev, "UVC connect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC connect failed with %d\n", ret);
} }
void void
uvc_function_disconnect(struct uvc_device *uvc) uvc_function_disconnect(struct uvc_device *uvc)
{ {
struct usb_composite_dev *cdev = uvc->func.config->cdev;
int ret; int ret;
if ((ret = usb_function_deactivate(&uvc->func)) < 0) if ((ret = usb_function_deactivate(&uvc->func)) < 0)
INFO(cdev, "UVC disconnect failed with %d\n", ret); uvcg_info(&uvc->func, "UVC disconnect failed with %d\n", ret);
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
...@@ -605,7 +598,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -605,7 +598,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
struct f_uvc_opts *opts; struct f_uvc_opts *opts;
int ret = -EINVAL; int ret = -EINVAL;
INFO(cdev, "uvc_function_bind\n"); uvcg_info(f, "%s()\n", __func__);
opts = fi_to_f_uvc_opts(f->fi); opts = fi_to_f_uvc_opts(f->fi);
/* Sanity check the streaming endpoint module parameters. /* Sanity check the streaming endpoint module parameters.
...@@ -618,7 +611,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -618,7 +611,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
if (opts->streaming_maxburst && if (opts->streaming_maxburst &&
(opts->streaming_maxpacket % 1024) != 0) { (opts->streaming_maxpacket % 1024) != 0) {
opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024); opts->streaming_maxpacket = roundup(opts->streaming_maxpacket, 1024);
INFO(cdev, "overriding streaming_maxpacket to %d\n", uvcg_info(f, "overriding streaming_maxpacket to %d\n",
opts->streaming_maxpacket); opts->streaming_maxpacket);
} }
...@@ -658,7 +651,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -658,7 +651,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
/* Allocate endpoints. */ /* Allocate endpoints. */
ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep);
if (!ep) { if (!ep) {
INFO(cdev, "Unable to allocate control EP\n"); uvcg_info(f, "Unable to allocate control EP\n");
goto error; goto error;
} }
uvc->control_ep = ep; uvc->control_ep = ep;
...@@ -672,7 +665,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -672,7 +665,7 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep); ep = usb_ep_autoconfig(cdev->gadget, &uvc_fs_streaming_ep);
if (!ep) { if (!ep) {
INFO(cdev, "Unable to allocate streaming EP\n"); uvcg_info(f, "Unable to allocate streaming EP\n");
goto error; goto error;
} }
uvc->video.ep = ep; uvc->video.ep = ep;
...@@ -745,19 +738,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) ...@@ -745,19 +738,19 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
uvc->control_req->context = uvc; uvc->control_req->context = uvc;
if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) {
printk(KERN_INFO "v4l2_device_register failed\n"); uvcg_err(f, "failed to register V4L2 device\n");
goto error; goto error;
} }
/* Initialise video. */ /* Initialise video. */
ret = uvcg_video_init(&uvc->video); ret = uvcg_video_init(&uvc->video, uvc);
if (ret < 0) if (ret < 0)
goto error; goto error;
/* Register a V4L2 device. */ /* Register a V4L2 device. */
ret = uvc_register_video(uvc); ret = uvc_register_video(uvc);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "Unable to register video device\n"); uvcg_err(f, "failed to register video device\n");
goto error; goto error;
} }
...@@ -894,7 +887,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f) ...@@ -894,7 +887,7 @@ static void uvc_unbind(struct usb_configuration *c, struct usb_function *f)
struct usb_composite_dev *cdev = c->cdev; struct usb_composite_dev *cdev = c->cdev;
struct uvc_device *uvc = to_uvc(f); struct uvc_device *uvc = to_uvc(f);
INFO(cdev, "%s\n", __func__); uvcg_info(f, "%s\n", __func__);
device_remove_file(&uvc->vdev.dev, &dev_attr_function_name); device_remove_file(&uvc->vdev.dev, &dev_attr_function_name);
video_unregister_device(&uvc->vdev); video_unregister_device(&uvc->vdev);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
struct usb_ep; struct usb_ep;
struct usb_request; struct usb_request;
struct uvc_descriptor_header; struct uvc_descriptor_header;
struct uvc_device;
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* Debugging, printing and logging * Debugging, printing and logging
...@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param; ...@@ -51,14 +52,12 @@ extern unsigned int uvc_gadget_trace_param;
printk(KERN_DEBUG "uvcvideo: " msg); \ printk(KERN_DEBUG "uvcvideo: " msg); \
} while (0) } while (0)
#define uvc_warn_once(dev, warn, msg...) \ #define uvcg_dbg(f, fmt, args...) \
do { \ dev_dbg(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
if (!test_and_set_bit(warn, &dev->warnings)) \ #define uvcg_info(f, fmt, args...) \
printk(KERN_INFO "uvcvideo: " msg); \ dev_info(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
} while (0) #define uvcg_err(f, fmt, args...) \
dev_err(&(f)->config->cdev->gadget->dev, "%s: " fmt, (f)->name, ##args)
#define uvc_printk(level, msg...) \
printk(level "uvcvideo: " msg)
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* Driver specific constants * Driver specific constants
...@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param; ...@@ -73,6 +72,7 @@ extern unsigned int uvc_gadget_trace_param;
*/ */
struct uvc_video { struct uvc_video {
struct uvc_device *uvc;
struct usb_ep *ep; struct usb_ep *ep;
/* Frame parameters */ /* Frame parameters */
......
...@@ -115,7 +115,7 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt) ...@@ -115,7 +115,7 @@ uvc_v4l2_set_format(struct file *file, void *fh, struct v4l2_format *fmt)
} }
if (i == ARRAY_SIZE(uvc_formats)) { if (i == ARRAY_SIZE(uvc_formats)) {
printk(KERN_INFO "Unsupported format 0x%08x.\n", uvcg_info(&uvc->func, "Unsupported format 0x%08x.\n",
fmt->fmt.pix.pixelformat); fmt->fmt.pix.pixelformat);
return -EINVAL; return -EINVAL;
} }
......
...@@ -131,7 +131,9 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req) ...@@ -131,7 +131,9 @@ static int uvcg_video_ep_queue(struct uvc_video *video, struct usb_request *req)
ret = usb_ep_queue(video->ep, req, GFP_ATOMIC); ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
if (ret < 0) { if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d).\n", ret); uvcg_err(&video->uvc->func, "Failed to queue request (%d).\n",
ret);
/* Isochronous endpoints can't be halted. */ /* Isochronous endpoints can't be halted. */
if (usb_endpoint_xfer_bulk(video->ep->desc)) if (usb_endpoint_xfer_bulk(video->ep->desc))
usb_ep_set_halt(video->ep); usb_ep_set_halt(video->ep);
...@@ -184,12 +186,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) ...@@ -184,12 +186,13 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
break; break;
case -ESHUTDOWN: /* disconnect from host. */ case -ESHUTDOWN: /* disconnect from host. */
printk(KERN_DEBUG "VS request cancelled.\n"); uvcg_dbg(&video->uvc->func, "VS request cancelled.\n");
uvcg_queue_cancel(queue, 1); uvcg_queue_cancel(queue, 1);
goto requeue; goto requeue;
default: default:
printk(KERN_INFO "VS request completed with status %d.\n", uvcg_info(&video->uvc->func,
"VS request completed with status %d.\n",
req->status); req->status);
uvcg_queue_cancel(queue, 0); uvcg_queue_cancel(queue, 0);
goto requeue; goto requeue;
...@@ -354,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable) ...@@ -354,8 +357,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
int ret; int ret;
if (video->ep == NULL) { if (video->ep == NULL) {
printk(KERN_INFO "Video enable failed, device is " uvcg_info(&video->uvc->func,
"uninitialized.\n"); "Video enable failed, device is uninitialized.\n");
return -ENODEV; return -ENODEV;
} }
...@@ -387,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable) ...@@ -387,11 +390,12 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
/* /*
* Initialize the UVC video stream. * Initialize the UVC video stream.
*/ */
int uvcg_video_init(struct uvc_video *video) int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
{ {
INIT_LIST_HEAD(&video->req_free); INIT_LIST_HEAD(&video->req_free);
spin_lock_init(&video->req_lock); spin_lock_init(&video->req_lock);
video->uvc = uvc;
video->fcc = V4L2_PIX_FMT_YUYV; video->fcc = V4L2_PIX_FMT_YUYV;
video->bpp = 16; video->bpp = 16;
video->width = 320; video->width = 320;
......
...@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video); ...@@ -18,6 +18,6 @@ int uvcg_video_pump(struct uvc_video *video);
int uvcg_video_enable(struct uvc_video *video, int enable); int uvcg_video_enable(struct uvc_video *video, int enable);
int uvcg_video_init(struct uvc_video *video); int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
#endif /* __UVC_VIDEO_H__ */ #endif /* __UVC_VIDEO_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