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: Frank Schaefer X-Patchwork-Id: 23883 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Wjapq-0001WF-7n; Sun, 11 May 2014 22:59:02 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtp id 1Wjapn-0005mc-5h; Sun, 11 May 2014 22:59:01 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753793AbaEKU65 (ORCPT + 1 other); 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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.5.11.205121 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, CT_TEXT_PLAIN_UTF8_CAPS 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __INT_PROD_TV 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' 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 */