All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Daniel Almeida <daniel.almeida@collabora.com>,
	Ezequiel Garcia <ezequiel@collabora.com>
Cc: linux-media@vger.kernel.org, kernel@collabora.com
Subject: Re: Add dprintk calls for control validation in v4l2-ctrls.c?
Date: Wed, 28 Apr 2021 09:43:40 +0200	[thread overview]
Message-ID: <4f18966e-1be6-95ed-f6db-eb91a141e1f5@xs4all.nl> (raw)
In-Reply-To: <f7f6d636-1791-fb90-d4f4-0eb58993cb4d@collabora.com>

Hi Daniel,

On 27/04/2021 02:17, Daniel Almeida wrote:
> Hi Hans, Ezequiel & all.
> 
> I find it a bit hard to debug my own code when it invariably sneaks in a 
> bad control value with the VIDIOC_S_EXT_CTRLS ioctl.
> 
> 
> I feel that it would be tremendously beneficial to encourage the use of 
> dprintk calls in v4l2-ctrls.c to inform the user about what pieces of 
> data were actually rejected in the validation functions.

Makes sense!

> 
> #define dprintk(vdev, fmt, arg...) do {					\
> 	if (!WARN_ON(!(vdev)) && ((vdev)->dev_debug & V4L2_DEV_DEBUG_CTRL)) \
> 		printk(KERN_DEBUG pr_fmt("%s: %s: " fmt),		\
> 		       __func__, video_device_node_name(vdev), ##arg);	
> 
> 
> Unfortunately the dprintk macro above takes a pointer to struct 
> video_device as argument. This is not available in the places I want to 
> actually place the calls, as far as I could tell.
> 
> E.g. here:
> 
> static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
> 				 union v4l2_ctrl_ptr ptr)
> 
> I'd like to make the changes to make this possible, if any, or be 
> pointed at another solution if there is one - such as calling pr_err 
> directly or something along these lines - please.

I have no problem with changing the prototypes to pass a vdev pointer
along. The validate_new function is the starting point for that.

However, keep in mind that it can also be called from a driver via e.g.
__v4l2_ctrl_s_ctrl(), in which case there is no video_device, so the
debug code has to be able to handle the case where vdev == NULL, and
not do a WARN_ON in that case.

I would postpone working on this though. Early in the next cycle I want
to merge a large refactor patch found here:

https://git.linuxtv.org/hverkuil/media_tree.git/log/?h=ctrl-refactor

where v4l2-ctrls.c is split up in several pieces. I suggest you wait until
that's merged before making patches for the control framework.

Regards,

	Hans

> 
> Kindly advise?
> 
> -- thanks
> -- Daniel
> 


      reply	other threads:[~2021-04-28  7:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27  0:17 Add dprintk calls for control validation in v4l2-ctrls.c? Daniel Almeida
2021-04-28  7:43 ` Hans Verkuil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f18966e-1be6-95ed-f6db-eb91a141e1f5@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=daniel.almeida@collabora.com \
    --cc=ezequiel@collabora.com \
    --cc=kernel@collabora.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.