Commit ed4c5fa4 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Mauro Carvalho Chehab
Browse files

media: uvcvideo: use dev_printk() for uvc_trace()



Instead of calling prink() inside uvc_trace, use dev_printk(), which adds
context to the output.

Now that we are at it, regroup the strings so the messages can be easily
"grepable".

Suggested-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 59e92bf6
Loading
Loading
Loading
Loading
+35 −31
Original line number Original line Diff line number Diff line
@@ -906,8 +906,8 @@ static struct uvc_control *uvc_find_control(struct uvc_video_chain *chain,
	}
	}


	if (ctrl == NULL && !next)
	if (ctrl == NULL && !next)
		uvc_trace(UVC_TRACE_CONTROL, "Control 0x%08x not found.\n",
		uvc_trace(chain->dev, UVC_TRACE_CONTROL,
				v4l2_id);
			  "Control 0x%08x not found.\n", v4l2_id);


	return ctrl;
	return ctrl;
}
}
@@ -1800,7 +1800,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
	ret = uvc_query_ctrl(dev, UVC_GET_LEN, ctrl->entity->id, dev->intfnum,
	ret = uvc_query_ctrl(dev, UVC_GET_LEN, ctrl->entity->id, dev->intfnum,
			     info->selector, data, 2);
			     info->selector, data, 2);
	if (ret < 0) {
	if (ret < 0) {
		uvc_trace(UVC_TRACE_CONTROL,
		uvc_trace(dev, UVC_TRACE_CONTROL,
			  "GET_LEN failed on control %pUl/%u (%d).\n",
			  "GET_LEN failed on control %pUl/%u (%d).\n",
			  info->entity, info->selector, ret);
			  info->entity, info->selector, ret);
		goto done;
		goto done;
@@ -1813,7 +1813,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,


	ret = uvc_ctrl_get_flags(dev, ctrl, info);
	ret = uvc_ctrl_get_flags(dev, ctrl, info);
	if (ret < 0) {
	if (ret < 0) {
		uvc_trace(UVC_TRACE_CONTROL,
		uvc_trace(dev, UVC_TRACE_CONTROL,
			  "Failed to get flags for control %pUl/%u (%d).\n",
			  "Failed to get flags for control %pUl/%u (%d).\n",
			  info->entity, info->selector, ret);
			  info->entity, info->selector, ret);
		goto done;
		goto done;
@@ -1821,8 +1821,8 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,


	uvc_ctrl_fixup_xu_info(dev, ctrl, info);
	uvc_ctrl_fixup_xu_info(dev, ctrl, info);


	uvc_trace(UVC_TRACE_CONTROL, "XU control %pUl/%u queried: len %u, "
	uvc_trace(dev, UVC_TRACE_CONTROL,
		  "flags { get %u set %u auto %u }.\n",
		  "XU control %pUl/%u queried: len %u, flags { get %u set %u auto %u }.\n",
		  info->entity, info->selector, info->size,
		  info->entity, info->selector, info->size,
		  (info->flags & UVC_CTRL_FLAG_GET_CUR) ? 1 : 0,
		  (info->flags & UVC_CTRL_FLAG_GET_CUR) ? 1 : 0,
		  (info->flags & UVC_CTRL_FLAG_SET_CUR) ? 1 : 0,
		  (info->flags & UVC_CTRL_FLAG_SET_CUR) ? 1 : 0,
@@ -1851,9 +1851,10 @@ static int uvc_ctrl_init_xu_ctrl(struct uvc_device *dev,


	ret = uvc_ctrl_add_info(dev, ctrl, &info);
	ret = uvc_ctrl_add_info(dev, ctrl, &info);
	if (ret < 0)
	if (ret < 0)
		uvc_trace(UVC_TRACE_CONTROL, "Failed to initialize control "
		uvc_trace(dev, UVC_TRACE_CONTROL,
			  "%pUl/%u on device %s entity %u\n", info.entity,
			  "Failed to initialize control %pUl/%u on device %s entity %u\n",
			  info.selector, dev->udev->devpath, ctrl->entity->id);
			  info.entity, info.selector, dev->udev->devpath,
			  ctrl->entity->id);


	return ret;
	return ret;
}
}
@@ -1881,8 +1882,8 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
	}
	}


	if (!found) {
	if (!found) {
		uvc_trace(UVC_TRACE_CONTROL, "Extension unit %u not found.\n",
		uvc_trace(chain->dev, UVC_TRACE_CONTROL,
			xqry->unit);
			  "Extension unit %u not found.\n", xqry->unit);
		return -ENOENT;
		return -ENOENT;
	}
	}


@@ -1897,8 +1898,9 @@ int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
	}
	}


	if (!found) {
	if (!found) {
		uvc_trace(UVC_TRACE_CONTROL, "Control %pUl/%u not found.\n",
		uvc_trace(chain->dev, UVC_TRACE_CONTROL,
			entity->guid, xqry->selector);
			  "Control %pUl/%u not found.\n", entity->guid,
			  xqry->selector);
		return -ENOENT;
		return -ENOENT;
	}
	}


@@ -2046,9 +2048,10 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl,


	ctrl->initialized = 1;
	ctrl->initialized = 1;


	uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s "
	uvc_trace(dev, UVC_TRACE_CONTROL,
		"entity %u\n", ctrl->info.entity, ctrl->info.selector,
		  "Added control %pUl/%u to device %s entity %u\n",
		dev->udev->devpath, ctrl->entity->id);
		  ctrl->info.entity, ctrl->info.selector, dev->udev->devpath,
		  ctrl->entity->id);


	return 0;
	return 0;
}
}
@@ -2085,7 +2088,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_device *dev,
		map->set = uvc_set_le_value;
		map->set = uvc_set_le_value;


	list_add_tail(&map->list, &ctrl->info.mappings);
	list_add_tail(&map->list, &ctrl->info.mappings);
	uvc_trace(UVC_TRACE_CONTROL,
	uvc_trace(dev, UVC_TRACE_CONTROL,
		  "Adding mapping '%s' to control %pUl/%u.\n",
		  "Adding mapping '%s' to control %pUl/%u.\n",
		  map->name, ctrl->info.entity, ctrl->info.selector);
		  map->name, ctrl->info.entity, ctrl->info.selector);


@@ -2103,9 +2106,9 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
	int ret;
	int ret;


	if (mapping->id & ~V4L2_CTRL_ID_MASK) {
	if (mapping->id & ~V4L2_CTRL_ID_MASK) {
		uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', control "
		uvc_trace(dev, UVC_TRACE_CONTROL,
			"id 0x%08x is invalid.\n", mapping->name,
			  "Can't add mapping '%s', control id 0x%08x is invalid.\n",
			mapping->id);
			  mapping->name, mapping->id);
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -2150,8 +2153,8 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,


	list_for_each_entry(map, &ctrl->info.mappings, list) {
	list_for_each_entry(map, &ctrl->info.mappings, list) {
		if (mapping->id == map->id) {
		if (mapping->id == map->id) {
			uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', "
			uvc_trace(dev, UVC_TRACE_CONTROL,
				"control id 0x%08x already exists.\n",
				  "Can't add mapping '%s', control id 0x%08x already exists.\n",
				  mapping->name, mapping->id);
				  mapping->name, mapping->id);
			ret = -EEXIST;
			ret = -EEXIST;
			goto done;
			goto done;
@@ -2161,9 +2164,9 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
	/* Prevent excess memory consumption */
	/* Prevent excess memory consumption */
	if (atomic_inc_return(&dev->nmappings) > UVC_MAX_CONTROL_MAPPINGS) {
	if (atomic_inc_return(&dev->nmappings) > UVC_MAX_CONTROL_MAPPINGS) {
		atomic_dec(&dev->nmappings);
		atomic_dec(&dev->nmappings);
		uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', maximum "
		uvc_trace(dev, UVC_TRACE_CONTROL,
			"mappings count (%u) exceeded.\n", mapping->name,
			  "Can't add mapping '%s', maximum mappings count (%u) exceeded.\n",
			UVC_MAX_CONTROL_MAPPINGS);
			  mapping->name, UVC_MAX_CONTROL_MAPPINGS);
		ret = -ENOMEM;
		ret = -ENOMEM;
		goto done;
		goto done;
	}
	}
@@ -2232,8 +2235,9 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev,
		    !uvc_test_bit(controls, blacklist[i].index))
		    !uvc_test_bit(controls, blacklist[i].index))
			continue;
			continue;


		uvc_trace(UVC_TRACE_CONTROL, "%u/%u control is black listed, "
		uvc_trace(dev, UVC_TRACE_CONTROL,
			"removing it.\n", entity->id, blacklist[i].index);
			  "%u/%u control is black listed, removing it.\n",
			  entity->id, blacklist[i].index);


		uvc_clear_bit(controls, blacklist[i].index);
		uvc_clear_bit(controls, blacklist[i].index);
	}
	}
+155 −143

File changed.

Preview size limit exceeded, changes collapsed.

+9 −7
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
		0xde, 0xad, 0xfa, 0xce
		0xde, 0xad, 0xfa, 0xce
	};
	};


	struct uvc_streaming *stream = uvc_queue_to_stream(queue);
	unsigned int maxlen, nbytes;
	unsigned int maxlen, nbytes;
	u8 *mem;
	u8 *mem;
	int is_header = 0;
	int is_header = 0;
@@ -49,15 +50,16 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,


	if ((len >= 14 && memcmp(&data[2], hdr, 12) == 0) ||
	if ((len >= 14 && memcmp(&data[2], hdr, 12) == 0) ||
	    (len >= 15 && memcmp(&data[3], hdr, 12) == 0)) {
	    (len >= 15 && memcmp(&data[3], hdr, 12) == 0)) {
		uvc_trace(UVC_TRACE_FRAME, "iSight header found\n");
		uvc_trace(stream->dev, UVC_TRACE_FRAME,
			  "iSight header found\n");
		is_header = 1;
		is_header = 1;
	}
	}


	/* Synchronize to the input stream by waiting for a header packet. */
	/* Synchronize to the input stream by waiting for a header packet. */
	if (buf->state != UVC_BUF_STATE_ACTIVE) {
	if (buf->state != UVC_BUF_STATE_ACTIVE) {
		if (!is_header) {
		if (!is_header) {
			uvc_trace(UVC_TRACE_FRAME, "Dropping packet (out of "
			uvc_trace(stream->dev, UVC_TRACE_FRAME,
				  "sync).\n");
				  "Dropping packet (out of sync).\n");
			return 0;
			return 0;
		}
		}


@@ -85,8 +87,8 @@ static int isight_decode(struct uvc_video_queue *queue, struct uvc_buffer *buf,
		buf->bytesused += nbytes;
		buf->bytesused += nbytes;


		if (len > maxlen || buf->bytesused == buf->length) {
		if (len > maxlen || buf->bytesused == buf->length) {
			uvc_trace(UVC_TRACE_FRAME, "Frame complete "
			uvc_trace(stream->dev, UVC_TRACE_FRAME,
				  "(overflow).\n");
				  "Frame complete (overflow).\n");
			buf->state = UVC_BUF_STATE_DONE;
			buf->state = UVC_BUF_STATE_DONE;
		}
		}
	}
	}
@@ -103,8 +105,8 @@ void uvc_video_decode_isight(struct uvc_urb *uvc_urb, struct uvc_buffer *buf,


	for (i = 0; i < urb->number_of_packets; ++i) {
	for (i = 0; i < urb->number_of_packets; ++i) {
		if (urb->iso_frame_desc[i].status < 0) {
		if (urb->iso_frame_desc[i].status < 0) {
			uvc_trace(UVC_TRACE_FRAME, "USB isochronous frame "
			uvc_trace(stream->dev, UVC_TRACE_FRAME,
				  "lost (%d).\n",
				  "USB isochronous frame lost (%d).\n",
				  urb->iso_frame_desc[i].status);
				  urb->iso_frame_desc[i].status);
		}
		}


+2 −7
Original line number Original line Diff line number Diff line
@@ -32,12 +32,6 @@
 * the driver.
 * the driver.
 */
 */


static inline struct uvc_streaming *
uvc_queue_to_stream(struct uvc_video_queue *queue)
{
	return container_of(queue, struct uvc_streaming, queue);
}

static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf)
static inline struct uvc_buffer *uvc_vbuf_to_buffer(struct vb2_v4l2_buffer *buf)
{
{
	return container_of(buf, struct uvc_buffer, buf);
	return container_of(buf, struct uvc_buffer, buf);
@@ -109,7 +103,8 @@ static int uvc_buffer_prepare(struct vb2_buffer *vb)


	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT &&
	    vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
	    vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0)) {
		uvc_trace(UVC_TRACE_CAPTURE, "[E] Bytes used out of bounds.\n");
		uvc_trace(uvc_queue_to_stream(queue)->dev, UVC_TRACE_CAPTURE,
			  "[E] Bytes used out of bounds.\n");
		return -EINVAL;
		return -EINVAL;
	}
	}


+10 −9

File changed.

Preview size limit exceeded, changes collapsed.

Loading