From patchwork Sun May 11 20:59:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 4152991 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 71E2C9F3AE for ; Sun, 11 May 2014 20:59:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A63C2017D for ; Sun, 11 May 2014 20:59:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55EE220179 for ; Sun, 11 May 2014 20:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753793AbaEKU65 (ORCPT ); Sun, 11 May 2014 16:58:57 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:35607 "EHLO mail-ee0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751438AbaEKU64 (ORCPT ); Sun, 11 May 2014 16:58:56 -0400 Received: by mail-ee0-f45.google.com with SMTP id d49so4129021eek.4 for ; Sun, 11 May 2014 13:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=z7uT+euf640Oj+aum8Sy8vG078LoICIYh9qAL8HddZA=; b=YFV8AOoWWbwXGv42vezMuQ+/t0JzuN/ql4c/MBlE4J3CHqLlHcgwU1/Z+QRGZpFc0Q Et1MlMVE9/vbY4BxwCJoweQGxdLh+OvqeTJMhMfXzwqtB5Z9MDR3O3lyj7jTZKqEhDUT VbuB4TJLVeJPe/tQzqdVhaS4CGFJKIbCQzBkty+8A/bHRAGDrI8ZvfHMr5itEGCO14a7 fEnnmjCXe3/3NiEsuhp+lrhLiMAJP1p2QBififh6BY3urpxpP0JeLoU6XYSLcW7l5oqz ra9hM8RBZg4QDOaB2hFXgOWWGzbo6oIe9ck7VDt++5lQhzGM9EL2lFYmT1B4iKldkP7k X8sg== X-Received: by 10.15.82.132 with SMTP id a4mr27390353eez.47.1399841933250; Sun, 11 May 2014 13:58:53 -0700 (PDT) Received: from Athlon64X2-5000.lan (ip-109-90-213-136.unitymediagroup.de. [109.90.213.136]) by mx.google.com with ESMTPSA id cb5sm27951171eeb.18.2014.05.11.13.58.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 May 2014 13:58:52 -0700 (PDT) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: hverkuil@xs4all.nl Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 15/19, REBASED] em28xx: move v4l2 user counting fields from struct em28xx to struct v4l2 Date: Sun, 11 May 2014 22:59:04 +0200 Message-Id: <1399841944-3083-1-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-video.c | 27 +++++++++++++++------------ drivers/media/usb/em28xx/em28xx.h | 5 +++-- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 496dcef..aaab111 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -934,7 +934,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) if (rc) return rc; - if (dev->streaming_users == 0) { + if (v4l2->streaming_users == 0) { /* First active streaming user, so allocate all the URBs */ /* Allocate the USB bandwidth */ @@ -972,7 +972,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) 0, tuner, s_frequency, &f); } - dev->streaming_users++; + v4l2->streaming_users++; return rc; } @@ -980,6 +980,7 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count) static void em28xx_stop_streaming(struct vb2_queue *vq) { struct em28xx *dev = vb2_get_drv_priv(vq); + struct em28xx_v4l2 *v4l2 = dev->v4l2; struct em28xx_dmaqueue *vidq = &dev->vidq; unsigned long flags = 0; @@ -987,7 +988,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq) res_free(dev, vq->type); - if (dev->streaming_users-- == 1) { + if (v4l2->streaming_users-- == 1) { /* Last active user, so shutdown all the URBS */ em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); } @@ -1008,6 +1009,7 @@ static void em28xx_stop_streaming(struct vb2_queue *vq) void em28xx_stop_vbi_streaming(struct vb2_queue *vq) { struct em28xx *dev = vb2_get_drv_priv(vq); + struct em28xx_v4l2 *v4l2 = dev->v4l2; struct em28xx_dmaqueue *vbiq = &dev->vbiq; unsigned long flags = 0; @@ -1015,7 +1017,7 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq) res_free(dev, vq->type); - if (dev->streaming_users-- == 1) { + if (v4l2->streaming_users-- == 1) { /* Last active user, so shutdown all the URBS */ em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE); } @@ -1344,8 +1346,9 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct em28xx *dev = video_drvdata(file); + struct em28xx_v4l2 *v4l2 = dev->v4l2; - if (dev->streaming_users > 0) + if (v4l2->streaming_users > 0) return -EBUSY; vidioc_try_fmt_vid_cap(file, priv, f); @@ -1384,7 +1387,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm) if (norm == v4l2->norm) return 0; - if (dev->streaming_users > 0) + if (v4l2->streaming_users > 0) return -EBUSY; v4l2->norm = norm; @@ -1907,7 +1910,7 @@ static int em28xx_v4l2_open(struct file *filp) em28xx_videodbg("open dev=%s type=%s users=%d\n", video_device_node_name(vdev), v4l2_type_names[fh_type], - dev->users); + v4l2->users); if (mutex_lock_interruptible(&dev->lock)) return -ERESTARTSYS; @@ -1922,7 +1925,7 @@ static int em28xx_v4l2_open(struct file *filp) fh->type = fh_type; filp->private_data = fh; - if (dev->users == 0) { + if (v4l2->users == 0) { em28xx_set_mode(dev, EM28XX_ANALOG_MODE); if (vdev->vfl_type != VFL_TYPE_RADIO) @@ -1942,7 +1945,7 @@ static int em28xx_v4l2_open(struct file *filp) kref_get(&dev->ref); kref_get(&v4l2->ref); - dev->users++; + v4l2->users++; mutex_unlock(&dev->lock); v4l2_fh_add(&fh->fh); @@ -2051,12 +2054,12 @@ static int em28xx_v4l2_close(struct file *filp) struct em28xx_v4l2 *v4l2 = dev->v4l2; int errCode; - em28xx_videodbg("users=%d\n", dev->users); + em28xx_videodbg("users=%d\n", v4l2->users); vb2_fop_release(filp); mutex_lock(&dev->lock); - if (dev->users == 1) { + if (v4l2->users == 1) { /* No sense to try to write to the device */ if (dev->disconnected) goto exit; @@ -2078,8 +2081,8 @@ static int em28xx_v4l2_close(struct file *filp) } exit: + v4l2->users--; kref_put(&v4l2->ref, em28xx_free_v4l2); - dev->users--; mutex_unlock(&dev->lock); kref_put(&dev->ref, em28xx_free_device); diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 91bb624..0585217 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -523,6 +523,9 @@ struct em28xx_v4l2 { int sensor_yres; int sensor_xtal; + int users; /* user count for exclusive use */ + int streaming_users; /* number of actively streaming users */ + struct em28xx_fmt *format; v4l2_std_id norm; /* selected tv norm */ @@ -641,8 +644,6 @@ struct em28xx { struct rt_mutex i2c_bus_lock; /* video for linux */ - int users; /* user count for exclusive use */ - int streaming_users; /* Number of actively streaming users */ int ctl_freq; /* selected frequency */ unsigned int ctl_input; /* selected input */ unsigned int ctl_ainput;/* selected audio input */