From patchwork Thu May 24 20:35:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10425473 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 BE0886053B for ; Thu, 24 May 2018 20:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACA4829718 for ; Thu, 24 May 2018 20:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0D3A2971B; Thu, 24 May 2018 20:36:56 +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 2FB3829718 for ; Thu, 24 May 2018 20:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033132AbeEXUgx (ORCPT ); Thu, 24 May 2018 16:36:53 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:56600 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967325AbeEXUgt (ORCPT ); Thu, 24 May 2018 16:36:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 1FC19286F45 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Abylay Ospan , Hans Verkuil Subject: [PATCH 01/20] pvrusb2: replace pvr2_v4l2_ioctl by video_ioctl2 Date: Thu, 24 May 2018 17:35:01 -0300 Message-Id: <20180524203520.1598-2-ezequiel@collabora.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180524203520.1598-1-ezequiel@collabora.com> References: <20180524203520.1598-1-ezequiel@collabora.com> 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 From: Hans Verkuil This driver is the only V4L driver that does not set unlocked_ioctl to video_ioctl2. The only thing that pvr2_v4l2_ioctl does besides calling video_ioctl2 is calling pvr2_hdw_commit_ctl(). Add pvr2_hdw_commit_ctl() calls to the various ioctls that need this, and we can replace pvr2_v4l2_ioctl by video_ioctl2. Signed-off-by: Hans Verkuil Tested-by: Hans Verkuil --- drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 83 ++++++++++++-------------------- 1 file changed, 31 insertions(+), 52 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 9fdc57c1658f..e53a80b589a1 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -159,9 +159,12 @@ static int pvr2_s_std(struct file *file, void *priv, v4l2_std_id std) { struct pvr2_v4l2_fh *fh = file->private_data; struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; + int ret; - return pvr2_ctrl_set_value( + ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_STDCUR), std); + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_querystd(struct file *file, void *priv, v4l2_std_id *std) @@ -251,12 +254,15 @@ static int pvr2_s_input(struct file *file, void *priv, unsigned int inp) { struct pvr2_v4l2_fh *fh = file->private_data; struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; + int ret; if (inp >= fh->input_cnt) return -EINVAL; - return pvr2_ctrl_set_value( + ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_INPUT), fh->input_map[inp]); + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_enumaudio(struct file *file, void *priv, struct v4l2_audio *vin) @@ -315,13 +321,16 @@ static int pvr2_s_tuner(struct file *file, void *priv, const struct v4l2_tuner * { struct pvr2_v4l2_fh *fh = file->private_data; struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; + int ret; if (vt->index != 0) return -EINVAL; - return pvr2_ctrl_set_value( + ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_AUDIOMODE), vt->audmode); + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_s_frequency(struct file *file, void *priv, const struct v4l2_frequency *vf) @@ -353,8 +362,10 @@ static int pvr2_s_frequency(struct file *file, void *priv, const struct v4l2_fre fv = (fv * 125) / 2; else fv = fv * 62500; - return pvr2_ctrl_set_value( + ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY),fv); + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_g_frequency(struct file *file, void *priv, struct v4l2_frequency *vf) @@ -470,6 +481,7 @@ static int pvr2_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format vcp = pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_VRES); pvr2_ctrl_set_value(hcp, vf->fmt.pix.width); pvr2_ctrl_set_value(vcp, vf->fmt.pix.height); + pvr2_hdw_commit_ctl(hdw); return 0; } @@ -597,9 +609,12 @@ static int pvr2_s_ctrl(struct file *file, void *priv, struct v4l2_control *vc) { struct pvr2_v4l2_fh *fh = file->private_data; struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; + int ret; - return pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw, vc->id), + ret = pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw, vc->id), vc->value); + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_g_ext_ctrls(struct file *file, void *priv, @@ -658,10 +673,12 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv, ctrl->value); if (ret) { ctls->error_idx = idx; - return ret; + goto commit; } } - return 0; +commit: + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_try_ext_ctrls(struct file *file, void *priv, @@ -764,23 +781,23 @@ static int pvr2_s_selection(struct file *file, void *priv, pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), sel->r.left); if (ret != 0) - return -EINVAL; + goto commit; ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPT), sel->r.top); if (ret != 0) - return -EINVAL; + goto commit; ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPW), sel->r.width); if (ret != 0) - return -EINVAL; + goto commit; ret = pvr2_ctrl_set_value( pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPH), sel->r.height); - if (ret != 0) - return -EINVAL; - return 0; +commit: + pvr2_hdw_commit_ctl(hdw); + return ret; } static int pvr2_log_status(struct file *file, void *priv) @@ -905,44 +922,6 @@ static void pvr2_v4l2_internal_check(struct pvr2_channel *chp) } -static long pvr2_v4l2_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) -{ - - struct pvr2_v4l2_fh *fh = file->private_data; - struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; - long ret = -EINVAL; - - if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) - v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); - - if (!pvr2_hdw_dev_ok(hdw)) { - pvr2_trace(PVR2_TRACE_ERROR_LEGS, - "ioctl failed - bad or no context"); - return -EFAULT; - } - - ret = video_ioctl2(file, cmd, arg); - - pvr2_hdw_commit_ctl(hdw); - - if (ret < 0) { - if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) { - pvr2_trace(PVR2_TRACE_V4LIOCTL, - "pvr2_v4l2_do_ioctl failure, ret=%ld command was:", -ret); - v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); - } - } else { - pvr2_trace(PVR2_TRACE_V4LIOCTL, - "pvr2_v4l2_do_ioctl complete, ret=%ld (0x%lx)", - ret, ret); - } - return ret; - -} - - static int pvr2_v4l2_release(struct file *file) { struct pvr2_v4l2_fh *fhp = file->private_data; @@ -1205,7 +1184,7 @@ static const struct v4l2_file_operations vdev_fops = { .open = pvr2_v4l2_open, .release = pvr2_v4l2_release, .read = pvr2_v4l2_read, - .unlocked_ioctl = pvr2_v4l2_ioctl, + .unlocked_ioctl = video_ioctl2, .poll = pvr2_v4l2_poll, };