From patchwork Tue Dec 19 11:18:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10123053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 20715603B5 for ; Tue, 19 Dec 2017 11:18:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B0E42928A for ; Tue, 19 Dec 2017 11:18:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F08112928D; Tue, 19 Dec 2017 11:18:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F8EC2928A for ; Tue, 19 Dec 2017 11:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762264AbdLSLSa (ORCPT ); Tue, 19 Dec 2017 06:18:30 -0500 Received: from osg.samsung.com ([64.30.133.232]:56082 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762260AbdLSLS3 (ORCPT ); Tue, 19 Dec 2017 06:18:29 -0500 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 4D383371D2; Tue, 19 Dec 2017 03:18:28 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at dev.s-opensource.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from osg.samsung.com ([127.0.0.1]) by localhost (localhost [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e-GZxmXCd4ah; Tue, 19 Dec 2017 03:18:27 -0800 (PST) Received: from smtp.s-opensource.com (201.86.134.76.dynamic.adsl.gvt.net.br [201.86.134.76]) by osg.samsung.com (Postfix) with ESMTPSA id EEEA1371B9; Tue, 19 Dec 2017 03:18:26 -0800 (PST) Received: from mchehab by smtp.s-opensource.com with local (Exim 4.89) (envelope-from ) id 1eRFui-0003JT-Oh; Tue, 19 Dec 2017 09:18:24 -0200 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Laurent Pinchart , Evgeni Raikhel , Ramesh Shanmugasundaram , Tomasz Figa , Ricardo Ribalda Delgado Subject: [PATCH v2 2/8] media: v4l2-ioctl.h: convert debug into an enum of bits Date: Tue, 19 Dec 2017 09:18:18 -0200 Message-Id: <333b63fa1857f6819ce64666beba969c22e2f468.1513682135.git.mchehab@s-opensource.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The V4L2_DEV_DEBUG_IOCTL macros actually define a bitmask, but without using Kernel's modern standards. Also, documentation looks akward. So, convert them into an enum with valid bits, adding the correspoinding kernel-doc documentation for it. In order to avoid possible conflicts, rename them from V4L2_DEV_DEBUG_foo to V4L2_DEBUG_foo. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dev.c | 18 +++++++++--------- drivers/media/v4l2-core/v4l2-ioctl.c | 7 ++++--- include/media/v4l2-ioctl.h | 33 +++++++++++++++++++-------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index d5e0e536ef04..ab876ddaa707 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -307,8 +307,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_FOP) && - (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) + if ((vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) && + (vdev->dev_debug & BIT(V4L2_DEBUG_STREAMING))) printk(KERN_DEBUG "%s: read: %zd (%d)\n", video_device_node_name(vdev), sz, ret); return ret; @@ -324,8 +324,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_FOP) && - (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) + if ((vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) && + (vdev->dev_debug & BIT(V4L2_DEBUG_STREAMING))) printk(KERN_DEBUG "%s: write: %zd (%d)\n", video_device_node_name(vdev), sz, ret); return ret; @@ -340,7 +340,7 @@ static unsigned int 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) + if (vdev->dev_debug & BIT(V4L2_DEBUG_POLL)) printk(KERN_DEBUG "%s: poll: %08x\n", video_device_node_name(vdev), res); return res; @@ -381,7 +381,7 @@ 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) + if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n", video_device_node_name(vdev), ret); return ret; @@ -397,7 +397,7 @@ 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) + if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) printk(KERN_DEBUG "%s: mmap (%d)\n", video_device_node_name(vdev), ret); return ret; @@ -427,7 +427,7 @@ static int v4l2_open(struct inode *inode, struct file *filp) ret = -ENODEV; } - if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) + if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) printk(KERN_DEBUG "%s: open (%d)\n", video_device_node_name(vdev), ret); /* decrease the refcount in case of an error */ @@ -444,7 +444,7 @@ static int v4l2_release(struct inode *inode, struct file *filp) if (vdev->fops->release) ret = vdev->fops->release(filp); - if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) + if (vdev->dev_debug & BIT(V4L2_DEBUG_FOP)) printk(KERN_DEBUG "%s: release\n", video_device_node_name(vdev)); diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 79614992ee21..cdd1e9470dbe 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2760,15 +2760,16 @@ static long __video_do_ioctl(struct file *file, } done: - if (dev_debug & (V4L2_DEV_DEBUG_IOCTL | V4L2_DEV_DEBUG_IOCTL_ARG)) { - if (!(dev_debug & V4L2_DEV_DEBUG_STREAMING) && + if (dev_debug & (BIT(V4L2_DEBUG_IOCTL) + | BIT(V4L2_DEBUG_IOCTL_ARG))) { + if (!(dev_debug & BIT(V4L2_DEBUG_STREAMING)) && (cmd == VIDIOC_QBUF || cmd == VIDIOC_DQBUF)) return ret; v4l_printk_ioctl(video_device_node_name(vfd), cmd); if (ret < 0) pr_cont(": error %ld", ret); - if (!(dev_debug & V4L2_DEV_DEBUG_IOCTL_ARG)) + if (!(dev_debug & BIT(V4L2_DEBUG_IOCTL_ARG))) pr_cont("\n"); else if (_IOC_DIR(cmd) == _IOC_NONE) info->debug(arg, write_only); diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index a7b3f7c75d62..9f8d04ad4bdd 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -589,20 +589,25 @@ struct v4l2_ioctl_ops { }; -/* v4l debugging and diagnostics */ - -/* Device debug flags to be used with the video device debug attribute */ - -/* Just log the ioctl name + error code */ -#define V4L2_DEV_DEBUG_IOCTL 0x01 -/* Log the ioctl name arguments + error code */ -#define V4L2_DEV_DEBUG_IOCTL_ARG 0x02 -/* Log the file operations open, release, mmap and get_unmapped_area */ -#define V4L2_DEV_DEBUG_FOP 0x04 -/* Log the read and write file operations and the VIDIOC_(D)QBUF ioctls */ -#define V4L2_DEV_DEBUG_STREAMING 0x08 -/* Log poll() */ -#define V4L2_DEV_DEBUG_POLL 0x10 +/** + * enum v4l2_debug_bits - Device debug bits to be used with the video + * device debug attribute + * + * @V4L2_DEBUG_IOCTL: Just log the ioctl name + error code. + * @V4L2_DEBUG_IOCTL_ARG: Log the ioctl name arguments + error code. + * @V4L2_DEBUG_FOP: Log the file operations and open, release, + * mmap and get_unmapped_area syscalls. + * @V4L2_DEBUG_STREAMING: Log the read and write syscalls and + * :c:ref:`VIDIOC_[Q|DQ]BUF ` ioctls. + * @V4L2_DEBUG_POLL: Log poll syscalls. + */ +enum v4l2_debug_bits { + V4L2_DEBUG_IOCTL = 0, + V4L2_DEBUG_IOCTL_ARG = 1, + V4L2_DEBUG_FOP = 2, + V4L2_DEBUG_STREAMING = 3, + V4L2_DEBUG_POLL = 4, +}; /* Video standard functions */