From patchwork Sun Feb 10 17:52:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 2122601 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 25FF63FCFC for ; Sun, 10 Feb 2013 17:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756246Ab3BJRxK (ORCPT ); Sun, 10 Feb 2013 12:53:10 -0500 Received: from smtp-vbr15.xs4all.nl ([194.109.24.35]:1703 "EHLO smtp-vbr15.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756201Ab3BJRxJ (ORCPT ); Sun, 10 Feb 2013 12:53:09 -0500 Received: from alastor.dyndns.org (166.80-203-20.nextgentel.com [80.203.20.166] (may be forged)) (authenticated bits=0) by smtp-vbr15.xs4all.nl (8.13.8/8.13.8) with ESMTP id r1AHqxhq089473 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sun, 10 Feb 2013 18:53:01 +0100 (CET) (envelope-from hverkuil@xs4all.nl) Received: from tschai.lan (tschai.lan [192.168.1.10]) (Authenticated sender: hans) by alastor.dyndns.org (Postfix) with ESMTPSA id B9A7111E0142; Sun, 10 Feb 2013 18:52:54 +0100 (CET) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans de Goede , Hans Verkuil Subject: [RFCv2 PATCH 08/12] stk-webcam: zero the priv field of v4l2_pix_format. Date: Sun, 10 Feb 2013 18:52:49 +0100 Message-Id: <13d5570e9ad90f25bb2bc50e957f3692a6788888.1360518391.git.hans.verkuil@cisco.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360518773-1065-1-git-send-email-hverkuil@xs4all.nl> References: <1360518773-1065-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: <21a2f157a80755483630be6aab26f67dc9f041c6.1360518390.git.hans.verkuil@cisco.com> References: <21a2f157a80755483630be6aab26f67dc9f041c6.1360518390.git.hans.verkuil@cisco.com> X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Hans Verkuil The priv field should be set to 0. In this case the driver abused the priv field for internal housekeeping. Modify the code so priv is no longer used for that purpose. Signed-off-by: Hans Verkuil Tested-by: Arvydas Sidorenko --- drivers/media/usb/stkwebcam/stk-webcam.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index c72a1c4..ce802f7 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c @@ -859,11 +859,12 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp, pix_format->bytesperline = 2 * pix_format->width; pix_format->sizeimage = pix_format->bytesperline * pix_format->height; + pix_format->priv = 0; return 0; } -static int stk_vidioc_try_fmt_vid_cap(struct file *filp, - void *priv, struct v4l2_format *fmtd) +static int stk_try_fmt_vid_cap(struct file *filp, + struct v4l2_format *fmtd, int *idx) { int i; switch (fmtd->fmt.pix.pixelformat) { @@ -885,11 +886,13 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp, < abs(fmtd->fmt.pix.width - stk_sizes[i].w))) { fmtd->fmt.pix.height = stk_sizes[i-1].h; fmtd->fmt.pix.width = stk_sizes[i-1].w; - fmtd->fmt.pix.priv = i - 1; + if (idx) + *idx = i - 1; } else { fmtd->fmt.pix.height = stk_sizes[i].h; fmtd->fmt.pix.width = stk_sizes[i].w; - fmtd->fmt.pix.priv = i; + if (idx) + *idx = i; } fmtd->fmt.pix.field = V4L2_FIELD_NONE; @@ -900,9 +903,16 @@ static int stk_vidioc_try_fmt_vid_cap(struct file *filp, fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width; fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline * fmtd->fmt.pix.height; + fmtd->fmt.pix.priv = 0; return 0; } +static int stk_vidioc_try_fmt_vid_cap(struct file *filp, + void *priv, struct v4l2_format *fmtd) +{ + return stk_try_fmt_vid_cap(filp, fmtd, NULL); +} + static int stk_setup_format(struct stk_camera *dev) { int i = 0; @@ -943,6 +953,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, void *priv, struct v4l2_format *fmtd) { int ret; + int idx; struct stk_camera *dev = video_drvdata(filp); if (dev == NULL) @@ -953,7 +964,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, return -EBUSY; if (dev->owner && dev->owner != filp) return -EBUSY; - ret = stk_vidioc_try_fmt_vid_cap(filp, priv, fmtd); + ret = stk_try_fmt_vid_cap(filp, fmtd, &idx); if (ret) return ret; dev->owner = filp; @@ -961,7 +972,7 @@ static int stk_vidioc_s_fmt_vid_cap(struct file *filp, dev->vsettings.palette = fmtd->fmt.pix.pixelformat; stk_free_buffers(dev); dev->frame_size = fmtd->fmt.pix.sizeimage; - dev->vsettings.mode = stk_sizes[fmtd->fmt.pix.priv].m; + dev->vsettings.mode = stk_sizes[idx].m; stk_initialise(dev); return stk_setup_format(dev);