From: Ezequiel Garcia <ezequiel@collabora.com>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
kernel@collabora.com, Ezequiel Garcia <ezequiel@collabora.com>
Subject: [PATCH 2/4] media: v4l: Improve debug dprintk macro
Date: Mon, 18 Feb 2019 17:15:26 -0300 [thread overview]
Message-ID: <20190218201528.21545-3-ezequiel@collabora.com> (raw)
In-Reply-To: <20190218201528.21545-1-ezequiel@collabora.com>
Instead of checking the dev_debug flags before each dprintk call,
make the macro smarter by passing the parameters.
This makes the code simpler and will allow to add more debug logic.
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
---
drivers/media/v4l2-core/v4l2-dev.c | 38 +++++++++++++-----------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 34e4958663bf..35e429ac888f 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -36,7 +36,8 @@
#define VIDEO_NUM_DEVICES 256
#define VIDEO_NAME "video4linux"
-#define dprintk(fmt, arg...) do { \
+#define dprintk(vdev, flags, fmt, arg...) do { \
+ if (vdev->dev_debug & flags) \
printk(KERN_DEBUG pr_fmt("%s: " fmt), \
__func__, ##arg); \
} while (0)
@@ -315,9 +316,8 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
return -EINVAL;
if (video_is_registered(vdev))
ret = vdev->fops->read(filp, buf, sz, off);
- if (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)
- dprintk("%s: read: %zd (%d)\n",
- video_device_node_name(vdev), sz, ret);
+ dprintk(vdev, V4L2_DEV_DEBUG_STREAMING, "%s: read: %zd (%d)\n",
+ video_device_node_name(vdev), sz, ret);
return ret;
}
@@ -331,9 +331,8 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
return -EINVAL;
if (video_is_registered(vdev))
ret = vdev->fops->write(filp, buf, sz, off);
- if (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)
- dprintk("%s: write: %zd (%d)\n",
- video_device_node_name(vdev), sz, ret);
+ dprintk(vdev, V4L2_DEV_DEBUG_STREAMING, "%s: write: %zd (%d)\n",
+ video_device_node_name(vdev), sz, ret);
return ret;
}
@@ -346,9 +345,8 @@ static __poll_t v4l2_poll(struct file *filp, struct poll_table_struct *poll)
return DEFAULT_POLLMASK;
if (video_is_registered(vdev))
res = vdev->fops->poll(filp, poll);
- if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL)
- dprintk("%s: poll: %08x\n",
- video_device_node_name(vdev), res);
+ dprintk(vdev, V4L2_DEV_DEBUG_POLL, "%s: poll: %08x\n",
+ video_device_node_name(vdev), res);
return res;
}
@@ -381,9 +379,8 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp,
if (!video_is_registered(vdev))
return -ENODEV;
ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
- if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
- dprintk("%s: get_unmapped_area (%d)\n",
- video_device_node_name(vdev), ret);
+ dprintk(vdev, V4L2_DEV_DEBUG_FOP, "%s: get_unmapped_area (%d)\n",
+ video_device_node_name(vdev), ret);
return ret;
}
#endif
@@ -397,9 +394,8 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
return -ENODEV;
if (video_is_registered(vdev))
ret = vdev->fops->mmap(filp, vm);
- if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
- dprintk("%s: mmap (%d)\n",
- video_device_node_name(vdev), ret);
+ dprintk(vdev, V4L2_DEV_DEBUG_FOP, "%s: mmap (%d)\n",
+ video_device_node_name(vdev), ret);
return ret;
}
@@ -427,9 +423,8 @@ static int v4l2_open(struct inode *inode, struct file *filp)
ret = -ENODEV;
}
- if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
- dprintk("%s: open (%d)\n",
- video_device_node_name(vdev), ret);
+ dprintk(vdev, V4L2_DEV_DEBUG_FOP, "%s: open (%d)\n",
+ video_device_node_name(vdev), ret);
/* decrease the refcount in case of an error */
if (ret)
video_put(vdev);
@@ -458,9 +453,8 @@ static int v4l2_release(struct inode *inode, struct file *filp)
}
}
- if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
- dprintk("%s: release\n",
- video_device_node_name(vdev));
+ dprintk(vdev, V4L2_DEV_DEBUG_FOP, "%s: release\n",
+ video_device_node_name(vdev));
/* decrease the refcount unconditionally since the release()
return value is ignored. */
--
2.20.1
next prev parent reply other threads:[~2019-02-18 20:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 20:15 [PATCH 0/4] Add debug messages to v4l2-ctrls Ezequiel Garcia
2019-02-18 20:15 ` [PATCH 1/4] media: v4l: Simplify dev_debug flags Ezequiel Garcia
2019-02-18 20:15 ` Ezequiel Garcia [this message]
2019-02-18 20:15 ` [PATCH 3/4] media: v4l: Add a module parameter to control global debugging Ezequiel Garcia
2019-02-18 20:15 ` [PATCH 4/4] media: v4l: ctrls: Add debug messages Ezequiel Garcia
2019-02-25 21:25 ` Ezequiel Garcia
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=20190218201528.21545-3-ezequiel@collabora.com \
--to=ezequiel@collabora.com \
--cc=hans.verkuil@cisco.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox