public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: David Ellingsworth <david@identd.dyndns.org>
To: linux-media@vger.kernel.org, klimov.linux@gmail.com
Subject: [RFC/RFT 05/10] radio-mr800: simplify access to amradio_device
Date: Sat, 12 Sep 2009 10:49:39 -0400	[thread overview]
Message-ID: <4AABB503.5030902@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 4591 bytes --]

 From 762337020b7744f791fc02fff7eb983e3e4a2346 Mon Sep 17 00:00:00 2001
From: David Ellingsworth <david@identd.dyndns.org>
Date: Sat, 12 Sep 2009 00:45:28 -0400
Subject: [PATCH 05/10] mr800: simplify access to amradio_device

Signed-off-by: David Ellingsworth <david@identd.dyndns.org>
---
 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


[-- Attachment #2: 0005-mr800-simplify-access-to-amradio_device.patch --]
[-- Type: text/x-diff, Size: 4357 bytes --]

>From 762337020b7744f791fc02fff7eb983e3e4a2346 Mon Sep 17 00:00:00 2001
From: David Ellingsworth <david@identd.dyndns.org>
Date: Sat, 12 Sep 2009 00:45:28 -0400
Subject: [PATCH 05/10] mr800: simplify access to amradio_device

Signed-off-by: David Ellingsworth <david@identd.dyndns.org>
---
 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


                 reply	other threads:[~2009-09-12 14:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AABB503.5030902@gmail.com \
    --to=david@identd.dyndns.org \
    --cc=klimov.linux@gmail.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox