Skip to content

Commit

Permalink
media: uvcvideo: Use dev_ printk aliases
Browse files Browse the repository at this point in the history
Replace all the uses of printk() and uvc_printk() with its
equivalent dev_ alias macros.

They are more standard across the kernel tree and provide
more context about the error.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
  • Loading branch information
ribalda committed Nov 4, 2020
1 parent 8035320 commit 83cb6eb
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 88 deletions.
4 changes: 2 additions & 2 deletions drivers/media/usb/uvc/uvc_ctrl.c
Expand Up @@ -1326,8 +1326,8 @@ static void uvc_ctrl_status_event_work(struct work_struct *work)
w->urb->interval = dev->int_ep->desc.bInterval;
ret = usb_submit_urb(w->urb, GFP_KERNEL);
if (ret < 0)
uvc_printk(KERN_ERR, "Failed to resubmit status URB (%d).\n",
ret);
dev_err(&dev->udev->dev,
"Failed to resubmit status URB (%d).\n", ret);
}

bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain,
Expand Down
80 changes: 42 additions & 38 deletions drivers/media/usb/uvc/uvc_driver.c
Expand Up @@ -535,8 +535,8 @@ static int uvc_parse_format(struct uvc_device *dev,
sizeof(format->name));
format->fcc = fmtdesc->fcc;
} else {
uvc_printk(KERN_INFO, "Unknown video format %pUl\n",
&buffer[5]);
dev_info(&streaming->intf->dev,
"Unknown video format %pUl\n", &buffer[5]);
snprintf(format->name, sizeof(format->name), "%pUl\n",
&buffer[5]);
format->fcc = 0;
Expand Down Expand Up @@ -1588,7 +1588,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
switch (UVC_ENTITY_TYPE(entity)) {
case UVC_VC_EXTENSION_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- XU %d", entity->id);
pr_cont(" <- XU %d", entity->id);

if (entity->bNrInPins != 1) {
uvc_trace(UVC_TRACE_DESCR, "Extension unit %d has more "
Expand All @@ -1600,7 +1600,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,

case UVC_VC_PROCESSING_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- PU %d", entity->id);
pr_cont(" <- PU %d", entity->id);

if (chain->processing != NULL) {
uvc_trace(UVC_TRACE_DESCR, "Found multiple "
Expand All @@ -1613,7 +1613,7 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,

case UVC_VC_SELECTOR_UNIT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- SU %d", entity->id);
pr_cont(" <- SU %d", entity->id);

/* Single-input selector units are ignored. */
if (entity->bNrInPins == 1)
Expand All @@ -1632,25 +1632,25 @@ static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
case UVC_ITT_CAMERA:
case UVC_ITT_MEDIA_TRANSPORT_INPUT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- IT %d\n", entity->id);
pr_cont(" <- IT %d\n", entity->id);

break;

case UVC_OTT_VENDOR_SPECIFIC:
case UVC_OTT_DISPLAY:
case UVC_OTT_MEDIA_TRANSPORT_OUTPUT:
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " OT %d", entity->id);
pr_cont(" OT %d", entity->id);

break;

case UVC_TT_STREAMING:
if (UVC_ENTITY_IS_ITERM(entity)) {
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- IT %d\n", entity->id);
pr_cont(" <- IT %d\n", entity->id);
} else {
if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " OT %d", entity->id);
pr_cont(" OT %d", entity->id);
}

break;
Expand Down Expand Up @@ -1700,9 +1700,9 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
list_add_tail(&forward->chain, &chain->entities);
if (uvc_trace_param & UVC_TRACE_PROBE) {
if (!found)
printk(KERN_CONT " (->");
pr_cont(" (->");

printk(KERN_CONT " XU %d", forward->id);
pr_cont(" XU %d", forward->id);
found = 1;
}
break;
Expand All @@ -1720,16 +1720,16 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
list_add_tail(&forward->chain, &chain->entities);
if (uvc_trace_param & UVC_TRACE_PROBE) {
if (!found)
printk(KERN_CONT " (->");
pr_cont(" (->");

printk(KERN_CONT " OT %d", forward->id);
pr_cont(" OT %d", forward->id);
found = 1;
}
break;
}
}
if (found)
printk(KERN_CONT ")");
pr_cont(")");

return 0;
}
Expand All @@ -1755,7 +1755,7 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
}

if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " <- IT");
pr_cont(" <- IT");

chain->selector = entity;
for (i = 0; i < entity->bNrInPins; ++i) {
Expand All @@ -1776,14 +1776,14 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
}

if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT " %d", term->id);
pr_cont(" %d", term->id);

list_add_tail(&term->chain, &chain->entities);
uvc_scan_chain_forward(chain, term, entity);
}

if (uvc_trace_param & UVC_TRACE_PROBE)
printk(KERN_CONT "\n");
pr_cont("\n");

id = 0;
break;
Expand Down Expand Up @@ -2038,7 +2038,7 @@ static int uvc_scan_device(struct uvc_device *dev)
uvc_scan_fallback(dev);

if (list_empty(&dev->chains)) {
uvc_printk(KERN_INFO, "No valid video chain found.\n");
dev_info(&dev->udev->dev, "No valid video chain found.\n");
return -1;
}

Expand Down Expand Up @@ -2197,8 +2197,9 @@ int uvc_register_video_device(struct uvc_device *dev,

ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
if (ret < 0) {
uvc_printk(KERN_ERR, "Failed to register %s device (%d).\n",
v4l2_type_names[type], ret);
dev_err(&stream->intf->dev,
"Failed to register %s device (%d).\n",
v4l2_type_names[type], ret);
return ret;
}

Expand All @@ -2214,8 +2215,8 @@ static int uvc_register_video(struct uvc_device *dev,
/* Initialize the streaming interface with default parameters. */
ret = uvc_video_init(stream);
if (ret < 0) {
uvc_printk(KERN_ERR, "Failed to initialize the device (%d).\n",
ret);
dev_err(&stream->intf->dev,
"Failed to initialize the device (%d).\n", ret);
return ret;
}

Expand Down Expand Up @@ -2249,8 +2250,9 @@ static int uvc_register_terms(struct uvc_device *dev,

stream = uvc_stream_by_id(dev, term->id);
if (stream == NULL) {
uvc_printk(KERN_INFO, "No streaming interface found "
"for terminal %u.", term->id);
dev_info(&dev->udev->dev,
"No streaming interface found for terminal %u.",
term->id);
continue;
}

Expand Down Expand Up @@ -2283,8 +2285,8 @@ static int uvc_register_chains(struct uvc_device *dev)
#ifdef CONFIG_MEDIA_CONTROLLER
ret = uvc_mc_register_entities(chain);
if (ret < 0)
uvc_printk(KERN_INFO,
"Failed to register entities (%d).\n", ret);
dev_info(&dev->udev->dev,
"Failed to register entities (%d).\n", ret);
#endif
}

Expand Down Expand Up @@ -2387,17 +2389,19 @@ static int uvc_probe(struct usb_interface *intf,
goto error;
}

uvc_printk(KERN_INFO, "Found UVC %u.%02x device %s (%04x:%04x)\n",
dev->uvc_version >> 8, dev->uvc_version & 0xff,
udev->product ? udev->product : "<unnamed>",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct));
dev_info(&dev->udev->dev,
"Found UVC %u.%02x device %s (%04x:%04x)\n",
dev->uvc_version >> 8, dev->uvc_version & 0xff,
udev->product ? udev->product : "<unnamed>",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct));

if (dev->quirks != dev->info->quirks) {
uvc_printk(KERN_INFO, "Forcing device quirks to 0x%x by module "
"parameter for testing purpose.\n", dev->quirks);
uvc_printk(KERN_INFO, "Please report required quirks to the "
"linux-uvc-devel mailing list.\n");
dev_info(&dev->udev->dev,
"Forcing device quirks to 0x%x by module parameter for testing purpose.\n",
dev->quirks);
dev_info(&dev->udev->dev,
"Please report required quirks to the linux-uvc-devel mailing list.\n");
}

/* Register the V4L2 device. */
Expand Down Expand Up @@ -2426,9 +2430,9 @@ static int uvc_probe(struct usb_interface *intf,

/* Initialize the interrupt URB. */
if ((ret = uvc_status_init(dev)) < 0) {
uvc_printk(KERN_INFO, "Unable to initialize the status "
"endpoint (%d), status interrupt will not be "
"supported.\n", ret);
dev_info(&dev->udev->dev,
"Unable to initialize the status endpoint (%d), status interrupt will not be supported.\n",
ret);
}

uvc_trace(UVC_TRACE_PROBE, "UVC device initialized.\n");
Expand Down
10 changes: 6 additions & 4 deletions drivers/media/usb/uvc/uvc_entity.c
Expand Up @@ -139,17 +139,19 @@ int uvc_mc_register_entities(struct uvc_video_chain *chain)
list_for_each_entry(entity, &chain->entities, chain) {
ret = uvc_mc_init_entity(chain, entity);
if (ret < 0) {
uvc_printk(KERN_INFO, "Failed to initialize entity for "
"entity %u\n", entity->id);
dev_info(&chain->dev->udev->dev,
"Failed to initialize entity for entity %u\n",
entity->id);
return ret;
}
}

list_for_each_entry(entity, &chain->entities, chain) {
ret = uvc_mc_create_links(chain, entity);
if (ret < 0) {
uvc_printk(KERN_INFO, "Failed to create links for "
"entity %u\n", entity->id);
dev_info(&chain->dev->udev->dev,
"Failed to create links for entity %u\n",
entity->id);
return ret;
}
}
Expand Down
13 changes: 7 additions & 6 deletions drivers/media/usb/uvc/uvc_status.c
Expand Up @@ -208,8 +208,9 @@ static void uvc_status_complete(struct urb *urb)
return;

default:
uvc_printk(KERN_WARNING, "Non-zero status (%d) in status "
"completion handler.\n", urb->status);
dev_warn(&dev->udev->dev,
"Non-zero status (%d) in status completion handler.\n",
urb->status);
return;
}

Expand Down Expand Up @@ -243,10 +244,10 @@ static void uvc_status_complete(struct urb *urb)

/* Resubmit the URB. */
urb->interval = dev->int_ep->desc.bInterval;
if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
uvc_printk(KERN_ERR, "Failed to resubmit status URB (%d).\n",
ret);
}
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret < 0)
dev_err(&dev->udev->dev,
"Failed to resubmit status URB (%d).\n", ret);
}

int uvc_status_init(struct uvc_device *dev)
Expand Down

0 comments on commit 83cb6eb

Please sign in to comment.