From patchwork Mon Feb 18 20:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10818801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A26CC184E for ; Mon, 18 Feb 2019 20:15:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 924042BAFB for ; Mon, 18 Feb 2019 20:15:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 869302BB22; Mon, 18 Feb 2019 20:15:53 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 EF5542BB37 for ; Mon, 18 Feb 2019 20:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728443AbfBRUPw (ORCPT ); Mon, 18 Feb 2019 15:15:52 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40856 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbfBRUPt (ORCPT ); Mon, 18 Feb 2019 15:15:49 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id BC08627FD0A From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Ezequiel Garcia Subject: [PATCH 1/4] media: v4l: Simplify dev_debug flags Date: Mon, 18 Feb 2019 17:15:25 -0300 Message-Id: <20190218201528.21545-2-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218201528.21545-1-ezequiel@collabora.com> References: <20190218201528.21545-1-ezequiel@collabora.com> MIME-Version: 1.0 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 In preparation to cleanup the debug logic, simplify the dev_debug usage. In particular, make sure that a single flag is used to control each debug print. Before this commit V4L2_DEV_DEBUG_STREAMING and V4L2_DEV_DEBUG_FOP were needed to enable read and write debugging. After this commit only the former is needed. Signed-off-by: Ezequiel Garcia --- drivers/media/v4l2-core/v4l2-dev.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index d7528f82a66a..34e4958663bf 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -315,8 +315,7 @@ 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 & V4L2_DEV_DEBUG_STREAMING) dprintk("%s: read: %zd (%d)\n", video_device_node_name(vdev), sz, ret); return ret; @@ -332,8 +331,7 @@ 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 & V4L2_DEV_DEBUG_STREAMING) dprintk("%s: write: %zd (%d)\n", video_device_node_name(vdev), sz, ret); return ret; From patchwork Mon Feb 18 20:15:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10818803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB4A517D5 for ; Mon, 18 Feb 2019 20:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAAA42BAFB for ; Mon, 18 Feb 2019 20:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ECBF2BB37; Mon, 18 Feb 2019 20:15:54 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 384072BAFB for ; Mon, 18 Feb 2019 20:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729450AbfBRUPx (ORCPT ); Mon, 18 Feb 2019 15:15:53 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40860 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729449AbfBRUPv (ORCPT ); Mon, 18 Feb 2019 15:15:51 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id C116C27FD0B From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Ezequiel Garcia Subject: [PATCH 2/4] media: v4l: Improve debug dprintk macro Date: Mon, 18 Feb 2019 17:15:26 -0300 Message-Id: <20190218201528.21545-3-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218201528.21545-1-ezequiel@collabora.com> References: <20190218201528.21545-1-ezequiel@collabora.com> MIME-Version: 1.0 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 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 --- 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. */ From patchwork Mon Feb 18 20:15:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10818805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C56391390 for ; Mon, 18 Feb 2019 20:15:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2FD02BAFB for ; Mon, 18 Feb 2019 20:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A72232BB37; Mon, 18 Feb 2019 20:15:55 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 3DA7D2BAFB for ; Mon, 18 Feb 2019 20:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729464AbfBRUPy (ORCPT ); Mon, 18 Feb 2019 15:15:54 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40862 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728076AbfBRUPx (ORCPT ); Mon, 18 Feb 2019 15:15:53 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id BE5A527F7BE From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Ezequiel Garcia Subject: [PATCH 3/4] media: v4l: Add a module parameter to control global debugging Date: Mon, 18 Feb 2019 17:15:27 -0300 Message-Id: <20190218201528.21545-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218201528.21545-1-ezequiel@collabora.com> References: <20190218201528.21545-1-ezequiel@collabora.com> MIME-Version: 1.0 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 In addition to the dev_debug device attribute, which controls per-device debugging, we now add a module parameter to control debugging globally. This will allow to add debugging of v4l2 control logic, using the newly introduced debug parameter. In addition, this module parameter adds consistency to the subsystem, since other v4l2 modules expose the same parameter. Signed-off-by: Ezequiel Garcia --- drivers/media/v4l2-core/v4l2-dev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c index 35e429ac888f..4f7821b13721 100644 --- a/drivers/media/v4l2-core/v4l2-dev.c +++ b/drivers/media/v4l2-core/v4l2-dev.c @@ -36,8 +36,16 @@ #define VIDEO_NUM_DEVICES 256 #define VIDEO_NAME "video4linux" +unsigned int videodev_debug; +module_param_named(debug, videodev_debug, uint, 0644); + +/* + * The videodev_debug module parameter controls the global debug level, + * while the dev_debug device attribute controls the local + * per-device debug level. + */ #define dprintk(vdev, flags, fmt, arg...) do { \ - if (vdev->dev_debug & flags) \ + if ((videodev_debug & flags) || (vdev->dev_debug & flags)) \ printk(KERN_DEBUG pr_fmt("%s: " fmt), \ __func__, ##arg); \ } while (0) From patchwork Mon Feb 18 20:15:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10818807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 06F8B17D5 for ; Mon, 18 Feb 2019 20:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C502BAFB for ; Mon, 18 Feb 2019 20:15:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D96402BB37; Mon, 18 Feb 2019 20:15:58 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 40E742BAFB for ; Mon, 18 Feb 2019 20:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729479AbfBRUP5 (ORCPT ); Mon, 18 Feb 2019 15:15:57 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40866 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729465AbfBRUP4 (ORCPT ); Mon, 18 Feb 2019 15:15:56 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id A770627FD0A From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Ezequiel Garcia Subject: [PATCH 4/4] media: v4l: ctrls: Add debug messages Date: Mon, 18 Feb 2019 17:15:28 -0300 Message-Id: <20190218201528.21545-5-ezequiel@collabora.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218201528.21545-1-ezequiel@collabora.com> References: <20190218201528.21545-1-ezequiel@collabora.com> MIME-Version: 1.0 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 Currently, the v4l2 control code is a bit silent on errors. To ease debugging of the control logic, add debug messages on (hopefully) most of the error paths. Signed-off-by: Ezequiel Garcia --- drivers/media/v4l2-core/v4l2-ctrls.c | 63 +++++++++++++++++++++++----- include/media/v4l2-ioctl.h | 2 + 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 99308dac2daa..c9f4e00f2229 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define pr_fmt(fmt) "v4l2-ctrls: " fmt + #include #include #include @@ -28,6 +30,14 @@ #include #include +extern unsigned int videodev_debug; + +#define dprintk(fmt, arg...) do { \ + if (videodev_debug & V4L2_DEV_DEBUG_CTRL) \ + printk(KERN_DEBUG pr_fmt("%s: " fmt), \ + __func__, ##arg); \ +} while (0) + #define has_op(master, op) \ (master->ops && master->ops->op) #define call_op(master, op) \ @@ -1952,8 +1962,11 @@ static int validate_new(const struct v4l2_ctrl *ctrl, union v4l2_ctrl_ptr p_new) unsigned idx; int err = 0; - for (idx = 0; !err && idx < ctrl->elems; idx++) + for (idx = 0; !err && idx < ctrl->elems; idx++) { err = ctrl->type_ops->validate(ctrl, idx, p_new); + if (err) + dprintk("failed to validate control id 0x%x (%d)\n", ctrl->id, err); + } return err; } @@ -3136,20 +3149,28 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, if (cs->which && cs->which != V4L2_CTRL_WHICH_DEF_VAL && cs->which != V4L2_CTRL_WHICH_REQUEST_VAL && - V4L2_CTRL_ID2WHICH(id) != cs->which) + V4L2_CTRL_ID2WHICH(id) != cs->which) { + dprintk("invalid which 0x%x or control id 0x%x\n", cs->which, id); return -EINVAL; + } /* Old-style private controls are not allowed for extended controls */ - if (id >= V4L2_CID_PRIVATE_BASE) + if (id >= V4L2_CID_PRIVATE_BASE) { + dprintk("old-style private controls not allowed for extended controls\n"); return -EINVAL; + } ref = find_ref_lock(hdl, id); - if (ref == NULL) + if (ref == NULL) { + dprintk("cannot find control id 0x%x\n", id); return -EINVAL; + } h->ref = ref; ctrl = ref->ctrl; - if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) + if (ctrl->flags & V4L2_CTRL_FLAG_DISABLED) { + dprintk("control id 0x%x is disabled\n", id); return -EINVAL; + } if (ctrl->cluster[0]->ncontrols > 1) have_clusters = true; @@ -3159,10 +3180,16 @@ static int prepare_ext_ctrls(struct v4l2_ctrl_handler *hdl, unsigned tot_size = ctrl->elems * ctrl->elem_size; if (c->size < tot_size) { + /* + * In the get case the application first queries + * to obtain the size of the control. + */ if (get) { c->size = tot_size; return -ENOSPC; } + dprintk("pointer control id 0x%x size too small, %d bytes but %d bytes needed\n", + id, c->size, tot_size); return -EFAULT; } c->size = tot_size; @@ -3534,16 +3561,20 @@ static int validate_ctrls(struct v4l2_ext_controls *cs, cs->error_idx = i; - if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) + if (ctrl->flags & V4L2_CTRL_FLAG_READ_ONLY) { + dprintk("control id 0x%x is read-only\n", ctrl->id); return -EACCES; + } /* This test is also done in try_set_control_cluster() which is called in atomic context, so that has the final say, but it makes sense to do an up-front check as well. Once an error occurs in try_set_control_cluster() some other controls may have been set already and we want to do a best-effort to avoid that. */ - if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) + if (set && (ctrl->flags & V4L2_CTRL_FLAG_GRABBED)) { + dprintk("control id 0x%x is grabbed, cannot set\n", ctrl->id); return -EBUSY; + } /* * Skip validation for now if the payload needs to be copied * from userspace into kernelspace. We'll validate those later. @@ -3588,13 +3619,17 @@ static int try_set_ext_ctrls_common(struct v4l2_fh *fh, cs->error_idx = cs->count; /* Default value cannot be changed */ - if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) + if (cs->which == V4L2_CTRL_WHICH_DEF_VAL) { + dprintk("cannot change default value\n"); return -EINVAL; + } cs->which = V4L2_CTRL_ID2WHICH(cs->which); - if (hdl == NULL) + if (hdl == NULL) { + dprintk("invalid null control handler\n"); return -EINVAL; + } if (cs->count == 0) return class_check(hdl, cs->which); @@ -3700,21 +3735,27 @@ static int try_set_ext_ctrls(struct v4l2_fh *fh, int ret; if (cs->which == V4L2_CTRL_WHICH_REQUEST_VAL) { - if (!mdev || cs->request_fd < 0) + if (!mdev || cs->request_fd < 0) { + dprintk("missing media device or invalid request fd\n"); return -EINVAL; + } req = media_request_get_by_fd(mdev, cs->request_fd); - if (IS_ERR(req)) + if (IS_ERR(req)) { + dprintk("cannot find request fd %d\n", cs->request_fd); return PTR_ERR(req); + } ret = media_request_lock_for_update(req); if (ret) { + dprintk("cannot lock request fd %d\n", cs->request_fd); media_request_put(req); return ret; } obj = v4l2_ctrls_find_req_obj(hdl, req, set); if (IS_ERR(obj)) { + dprintk("cannot find request object for request fd %d\n", cs->request_fd); media_request_unlock_for_update(req); media_request_put(req); return PTR_ERR(obj); diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index 8533ece5026e..0ecd4e3e76a4 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h @@ -612,6 +612,8 @@ struct v4l2_ioctl_ops { #define V4L2_DEV_DEBUG_STREAMING 0x08 /* Log poll() */ #define V4L2_DEV_DEBUG_POLL 0x10 +/* Log controls */ +#define V4L2_DEV_DEBUG_CTRL 0x20 /* Video standard functions */