From patchwork Sat Sep 12 14:49:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ellingsworth X-Patchwork-Id: 47076 X-Patchwork-Delegate: dougsland@redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8CEnnVK027544 for ; Sat, 12 Sep 2009 14:49:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754603AbZILOtp (ORCPT ); Sat, 12 Sep 2009 10:49:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754602AbZILOtp (ORCPT ); Sat, 12 Sep 2009 10:49:45 -0400 Received: from qw-out-2122.google.com ([74.125.92.27]:15620 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754556AbZILOto (ORCPT ); Sat, 12 Sep 2009 10:49:44 -0400 Received: by qw-out-2122.google.com with SMTP id 9so632979qwb.37 for ; Sat, 12 Sep 2009 07:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :reply-to:user-agent:mime-version:to:subject:content-type; bh=hC5MP2vY3USCP2SjbajVRD3x5dzmjYBfw4n+yOTCiYo=; b=au4Xe8aH2y7w7/TDuRMSTIBXRWkq5loCBAsGRrNsQqRXaUg7tOxK4G7Njq8NTYHx/4 jmVtlt08QzJXceCjZmWOGA1RG5u6FtCIvYdyrMzRW7Wv8vOrfzZ66gstsVh68NqgwZTN rb//v4KeQXfkUfV5BBHmOuFyiR99Utad+Vjl4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:content-type; b=wmRTtI3LSEhahiuTPlV+z/07b8elYuqi6Tt8/sHemvIq+li7vQ8If/WjLMlJTi+ybd OdIUAyDKDDtdcjHzoJJwSHWpVYXO9cnvSNuEJOf/TTwY1C1jK2KTQAUEtOVPvfTWrt0v Ptzj8CQAnD8S1M5aaV99/idelG60+HVPsTcS8= Received: by 10.224.43.138 with SMTP id w10mr3764496qae.197.1252766987780; Sat, 12 Sep 2009 07:49:47 -0700 (PDT) Received: from ?192.168.10.110? (cpe-71-72-62-249.neo.res.rr.com [71.72.62.249]) by mx.google.com with ESMTPS id 6sm1462231qwk.31.2009.09.12.07.49.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 12 Sep 2009 07:49:47 -0700 (PDT) Message-ID: <4AABB503.5030902@gmail.com> Date: Sat, 12 Sep 2009 10:49:39 -0400 From: David Ellingsworth Reply-To: david@identd.dyndns.org User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: linux-media@vger.kernel.org, klimov.linux@gmail.com Subject: [RFC/RFT 05/10] radio-mr800: simplify access to amradio_device Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From 762337020b7744f791fc02fff7eb983e3e4a2346 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 00:45:28 -0400 Subject: [PATCH 05/10] mr800: simplify access to amradio_device Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) strlcpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); @@ -294,7 +296,7 @@ static int vidioc_querycap(struct file *file, void *priv, static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -345,7 +347,7 @@ unlock: static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -388,7 +390,7 @@ unlock: static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -415,7 +417,7 @@ unlock: static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = 0; mutex_lock(&radio->lock); @@ -450,7 +452,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = -EINVAL; mutex_lock(&radio->lock); @@ -477,7 +479,7 @@ unlock: static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = -EINVAL; mutex_lock(&radio->lock); @@ -550,7 +552,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) /* open device - amradio_start() and amradio_setfreq() */ static int usb_amradio_open(struct file *file) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = vdev_to_amradio(video_devdata(file)); int retval = 0; mutex_lock(&radio->lock); @@ -560,6 +562,7 @@ static int usb_amradio_open(struct file *file) goto unlock; } + file->private_data = radio; radio->users = 1; radio->muted = 1; @@ -589,7 +592,7 @@ unlock: /*close device */ static int usb_amradio_close(struct file *file) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = 0; mutex_lock(&radio->lock); @@ -674,7 +677,7 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { static void usb_amradio_video_device_release(struct video_device *videodev) { - struct amradio_device *radio = video_get_drvdata(videodev); + struct amradio_device *radio = vdev_to_amradio(videodev); v4l2_device_unregister(&radio->v4l2_dev); From 762337020b7744f791fc02fff7eb983e3e4a2346 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 00:45:28 -0400 Subject: [PATCH 05/10] mr800: simplify access to amradio_device Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 23 +++++++++++++---------- 1 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index fb99c6b..7305c96 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -141,6 +141,8 @@ struct amradio_device { int muted; }; +#define vdev_to_amradio(r) container_of(r, struct amradio_device, videodev) + /* USB Device ID List */ static struct usb_device_id usb_amradio_device_table[] = { {USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT, @@ -280,7 +282,7 @@ static void usb_amradio_disconnect(struct usb_interface *intf) static int vidioc_querycap(struct file *file, void *priv, struct v4l2_capability *v) { - struct amradio_device *radio = video_drvdata(file); + struct amradio_device *radio = file->private_data; strlcpy(v->driver, "radio-mr800", sizeof(v->driver)); strlcpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); @@ -294,7 +296,7 @@ static int vidioc_querycap(struct file *file, void *priv, static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -345,7 +347,7 @@ unlock: static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -388,7 +390,7 @@ unlock: static int vidioc_s_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval; mutex_lock(&radio->lock); @@ -415,7 +417,7 @@ unlock: static int vidioc_g_frequency(struct file *file, void *priv, struct v4l2_frequency *f) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = 0; mutex_lock(&radio->lock); @@ -450,7 +452,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, static int vidioc_g_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = -EINVAL; mutex_lock(&radio->lock); @@ -477,7 +479,7 @@ unlock: static int vidioc_s_ctrl(struct file *file, void *priv, struct v4l2_control *ctrl) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = -EINVAL; mutex_lock(&radio->lock); @@ -550,7 +552,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) /* open device - amradio_start() and amradio_setfreq() */ static int usb_amradio_open(struct file *file) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = vdev_to_amradio(video_devdata(file)); int retval = 0; mutex_lock(&radio->lock); @@ -560,6 +562,7 @@ static int usb_amradio_open(struct file *file) goto unlock; } + file->private_data = radio; radio->users = 1; radio->muted = 1; @@ -589,7 +592,7 @@ unlock: /*close device */ static int usb_amradio_close(struct file *file) { - struct amradio_device *radio = video_get_drvdata(video_devdata(file)); + struct amradio_device *radio = file->private_data; int retval = 0; mutex_lock(&radio->lock); @@ -674,7 +677,7 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { static void usb_amradio_video_device_release(struct video_device *videodev) { - struct amradio_device *radio = video_get_drvdata(videodev); + struct amradio_device *radio = vdev_to_amradio(videodev); v4l2_device_unregister(&radio->v4l2_dev); -- 1.6.3.3