public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Andy Walls <awalls@md.metrocast.net>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Pawel Osciak <pawel@osciak.com>,
	Tomasz Stanislawski <t.stanislaws@samsung.com>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [RFCv1 PATCH 29/32] v4l2-dev.c: also add debug support for the fops.
Date: Mon, 18 Jun 2012 12:01:47 +0200	[thread overview]
Message-ID: <7168376.Vf6x0R8Nod@avalon> (raw)
In-Reply-To: <5b43d9cfe9cf989cc2fd23140b7d76d2255b49f3.1339321562.git.hans.verkuil@cisco.com>

Hi Hans,

Thanks for the patch.

On Sunday 10 June 2012 12:25:51 Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/video/v4l2-dev.c |   41 ++++++++++++++++++++++++++-----------
>  1 file changed, 29 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
> index 5c0bb18..54f387d 100644
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -305,6 +305,9 @@ static ssize_t v4l2_read(struct file *filp, char __user
> *buf, ret = vdev->fops->read(filp, buf, sz, off);
>  	if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
>  		mutex_unlock(vdev->lock);
> +	if (vdev->debug)

As vdev->debug is a bitmask, shouldn't we add an fops debug bit ?

> +		pr_info("%s: read: %zd (%d)\n",
> +			video_device_node_name(vdev), sz, ret);

Shouldn't we use KERN_DEBUG instead of KERN_INFO ? BTW, what about replacing 
the pr_* calls with dev_* calls ?

>  	return ret;
>  }
> 
> @@ -323,6 +326,9 @@ static ssize_t v4l2_write(struct file *filp, const char
> __user *buf, ret = vdev->fops->write(filp, buf, sz, off);
>  	if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
>  		mutex_unlock(vdev->lock);
> +	if (vdev->debug)
> +		pr_info("%s: write: %zd (%d)\n",
> +			video_device_node_name(vdev), sz, ret);
>  	return ret;
>  }
> 
> @@ -339,6 +345,9 @@ static unsigned int v4l2_poll(struct file *filp, struct
> poll_table_struct *poll) ret = vdev->fops->poll(filp, poll);
>  	if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
>  		mutex_unlock(vdev->lock);
> +	if (vdev->debug)
> +		pr_info("%s: poll: %08x\n",
> +			video_device_node_name(vdev), ret);
>  	return ret;
>  }
> 
> @@ -348,20 +357,14 @@ static long v4l2_ioctl(struct file *filp, unsigned int
> cmd, unsigned long arg) int ret = -ENODEV;
> 
>  	if (vdev->fops->unlocked_ioctl) {
> -		bool locked = false;
> +		struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd);
> 
> -		if (vdev->lock) {
> -			/* always lock unless the cmd is marked as "don't use lock" */
> -			locked = !v4l2_is_known_ioctl(cmd) ||
> -				 !test_bit(_IOC_NR(cmd), vdev->disable_locking);
> -
> -			if (locked && mutex_lock_interruptible(vdev->lock))
> -				return -ERESTARTSYS;
> -		}
> +		if (lock && mutex_lock_interruptible(lock))
> +			return -ERESTARTSYS;
>  		if (video_is_registered(vdev))
>  			ret = vdev->fops->unlocked_ioctl(filp, cmd, arg);
> -		if (locked)
> -			mutex_unlock(vdev->lock);
> +		if (lock)
> +			mutex_unlock(lock);
>  	} else if (vdev->fops->ioctl) {
>  		/* This code path is a replacement for the BKL. It is a major
>  		 * hack but it will have to do for those drivers that are not
> @@ -409,12 +412,17 @@ static unsigned long v4l2_get_unmapped_area(struct
> file *filp, unsigned long flags)
>  {
>  	struct video_device *vdev = video_devdata(filp);
> +	int ret;
> 
>  	if (!vdev->fops->get_unmapped_area)
>  		return -ENOSYS;
>  	if (!video_is_registered(vdev))
>  		return -ENODEV;
> -	return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
> +	ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
> +	if (vdev->debug)
> +		pr_info("%s: get_unmapped_area (%d)\n",
> +			video_device_node_name(vdev), ret);
> +	return ret;
>  }
>  #endif
> 
> @@ -432,6 +440,9 @@ static int v4l2_mmap(struct file *filp, struct
> vm_area_struct *vm) ret = vdev->fops->mmap(filp, vm);
>  	if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
>  		mutex_unlock(vdev->lock);
> +	if (vdev->debug)
> +		pr_info("%s: mmap (%d)\n",
> +			video_device_node_name(vdev), ret);
>  	return ret;
>  }
> 
> @@ -470,6 +481,9 @@ err:
>  	/* decrease the refcount in case of an error */
>  	if (ret)
>  		video_put(vdev);
> +	if (vdev->debug)
> +		pr_info("%s: open (%d)\n",
> +			video_device_node_name(vdev), ret);
>  	return ret;
>  }
> 
> @@ -489,6 +503,9 @@ static int v4l2_release(struct inode *inode, struct file
> *filp) /* decrease the refcount unconditionally since the release()
>  	   return value is ignored. */
>  	video_put(vdev);
> +	if (vdev->debug)
> +		pr_info("%s: release\n",
> +			video_device_node_name(vdev));
>  	return ret;
>  }
-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2012-06-18 10:01 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-10 10:25 [RFCv1 PATCH 00/32] Core and vb2 enhancements Hans Verkuil
2012-06-10 10:25 ` [RFCv1 PATCH 01/32] Regression fixes Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 02/32] v4l2-ioctl.c: move a block of code down, no other changes Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 03/32] v4l2-ioctl.c: introduce INFO_FL_CLEAR to replace switch Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 04/32] v4l2-ioctl.c: v4l2-ioctl: add debug and callback/offset functionality Hans Verkuil
2012-06-18  9:47     ` Laurent Pinchart
2012-06-18 11:25       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 05/32] v4l2-ioctl.c: remove an unnecessary #ifdef Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 06/32] v4l2-ioctl.c: use the new table for querycap and i/o ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 07/32] v4l2-ioctl.c: use the new table for priority ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 08/32] v4l2-ioctl.c: use the new table for format/framebuffer ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 09/32] v4l2-ioctl.c: use the new table for overlay/streamon/off ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 10/32] v4l2-ioctl.c: use the new table for std/tuner/modulator ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 11/32] v4l2-ioctl.c: use the new table for queuing/parm ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 12/32] v4l2-ioctl.c: use the new table for control ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 13/32] v4l2-ioctl.c: use the new table for selection ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 14/32] v4l2-ioctl.c: use the new table for compression ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 15/32] v4l2-ioctl.c: use the new table for debug ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 16/32] v4l2-ioctl.c: use the new table for preset/timings ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 17/32] v4l2-ioctl.c: use the new table for the remaining ioctls Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 18/32] v4l2-ioctl.c: finalize table conversion Hans Verkuil
2012-06-18  9:46     ` Laurent Pinchart
2012-06-18 10:50       ` Mauro Carvalho Chehab
2012-06-18 11:03         ` Laurent Pinchart
2012-06-18 11:49         ` Hans Verkuil
2012-06-18 12:03           ` Mauro Carvalho Chehab
2012-06-18 12:22             ` Hans Verkuil
2012-06-18 11:17       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 19/32] v4l2-dev.c: add debug sysfs entry Hans Verkuil
2012-06-18  9:48     ` Laurent Pinchart
2012-06-18 11:30       ` Hans Verkuil
2012-06-18 11:36         ` Laurent Pinchart
2012-06-10 10:25   ` [RFCv1 PATCH 20/32] v4l2-ioctl: remove v4l_(i2c_)print_ioctl Hans Verkuil
2012-06-18  9:50     ` Laurent Pinchart
2012-06-18 11:33       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 21/32] ivtv: don't mess with vfd->debug Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 22/32] cx18: " Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 23/32] v4l2-dev/ioctl.c: add vb2_queue support to video_device Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 24/32] videobuf2-core: add helper functions Hans Verkuil
2012-06-18 10:23     ` Laurent Pinchart
2012-06-18 11:49       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 25/32] create_bufs: handle count == 0 Hans Verkuil
2012-06-18 10:11     ` Laurent Pinchart
2012-06-18 11:43       ` Hans Verkuil
2012-06-18 12:20         ` Laurent Pinchart
2012-06-10 10:25   ` [RFCv1 PATCH 26/32] vivi: remove pointless g/s_std support Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 27/32] vivi: embed struct video_device instead of allocating it Hans Verkuil
2012-06-18 10:13     ` Laurent Pinchart
2012-06-18 11:44       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 28/32] vivi: use vb2 helper functions Hans Verkuil
2012-06-18 10:08     ` Laurent Pinchart
2012-06-18 11:40       ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 29/32] v4l2-dev.c: also add debug support for the fops Hans Verkuil
2012-06-18 10:01     ` Laurent Pinchart [this message]
2012-06-18 11:40       ` Hans Verkuil
2012-06-18 12:19         ` Laurent Pinchart
2012-06-18 12:48           ` Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 30/32] v4l2-ioctl.c: shorten the lines of the table Hans Verkuil
2012-06-18  9:57     ` Laurent Pinchart
2012-06-18 11:34       ` Hans Verkuil
2012-06-18 12:15         ` Laurent Pinchart
2012-06-10 10:25   ` [RFCv1 PATCH 31/32] pwc: use the new vb2 helpers Hans Verkuil
2012-06-10 10:25   ` [RFCv1 PATCH 32/32] pwc: v4l2-compliance fixes Hans Verkuil
2012-06-10 16:46 ` [RFCv1 PATCH 00/32] Core and vb2 enhancements Mauro Carvalho Chehab
2012-06-10 17:32   ` Hans Verkuil
2012-06-10 19:27     ` Hans Verkuil
2012-06-12 11:35       ` Mauro Carvalho Chehab
2012-06-12 13:21         ` Hans Verkuil
2012-06-12 13:24         ` Hans de Goede

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=7168376.Vf6x0R8Nod@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=awalls@md.metrocast.net \
    --cc=g.liakhovetski@gmx.de \
    --cc=hans.verkuil@cisco.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=pawel@osciak.com \
    --cc=t.stanislaws@samsung.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox