All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>
Subject: [RFC PATCH 4/8] tea5764: convert to unlocked_ioctl
Date: Sun, 14 Nov 2010 14:22:30 +0100	[thread overview]
Message-ID: <f68e17ac4762a21cd0a2806f7da5a10c9c5866a3.1289740431.git.hverkuil@xs4all.nl> (raw)
In-Reply-To: <cover.1289740431.git.hverkuil@xs4all.nl>

Convert from ioctl to unlocked_ioctl using the v4l2 core lock.

Also removed the 'exclusive access' limitation. There was no need for it
and it violates the v4l2 spec as well.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
---
 drivers/media/radio/radio-tea5764.c |   49 ++++++----------------------------
 1 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 789d2ec..0e71d81 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -142,7 +142,6 @@ struct tea5764_device {
 	struct video_device		*videodev;
 	struct tea5764_regs		regs;
 	struct mutex			mutex;
-	int				users;
 };
 
 /* I2C code related */
@@ -458,41 +457,10 @@ static int vidioc_s_audio(struct file *file, void *priv,
 	return 0;
 }
 
-static int tea5764_open(struct file *file)
-{
-	/* Currently we support only one device */
-	struct tea5764_device *radio = video_drvdata(file);
-
-	mutex_lock(&radio->mutex);
-	/* Only exclusive access */
-	if (radio->users) {
-		mutex_unlock(&radio->mutex);
-		return -EBUSY;
-	}
-	radio->users++;
-	mutex_unlock(&radio->mutex);
-	file->private_data = radio;
-	return 0;
-}
-
-static int tea5764_close(struct file *file)
-{
-	struct tea5764_device *radio = video_drvdata(file);
-
-	if (!radio)
-		return -ENODEV;
-	mutex_lock(&radio->mutex);
-	radio->users--;
-	mutex_unlock(&radio->mutex);
-	return 0;
-}
-
 /* File system interface */
 static const struct v4l2_file_operations tea5764_fops = {
 	.owner		= THIS_MODULE,
-	.open           = tea5764_open,
-	.release        = tea5764_close,
-	.ioctl		= video_ioctl2,
+	.unlocked_ioctl	= video_ioctl2,
 };
 
 static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
@@ -527,7 +495,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
 	int ret;
 
 	PDEBUG("probe");
-	radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL);
+	radio = kzalloc(sizeof(struct tea5764_device), GFP_KERNEL);
 	if (!radio)
 		return -ENOMEM;
 
@@ -555,12 +523,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, radio);
 	video_set_drvdata(radio->videodev, radio);
-
-	ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
-	if (ret < 0) {
-		PWARN("Could not register video device!");
-		goto errrel;
-	}
+	radio->videodev->lock = &radio->mutex;
 
 	/* initialize and power off the chip */
 	tea5764_i2c_read(radio);
@@ -568,6 +531,12 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
 	tea5764_mute(radio, 1);
 	tea5764_power_down(radio);
 
+	ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
+	if (ret < 0) {
+		PWARN("Could not register video device!");
+		goto errrel;
+	}
+
 	PINFO("registered.");
 	return 0;
 errrel:
-- 
1.7.0.4


  parent reply	other threads:[~2010-11-14 13:22 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-14 13:21 [RFC PATCH 0/8] V4L BKL removal: first round Hans Verkuil
2010-11-14 13:22 ` [RFC PATCH 1/8] v4l2-dev: use mutex_lock_interruptible instead of plain mutex_lock Hans Verkuil
2010-11-14 13:22 ` [RFC PATCH 2/8] BKL: trivial BKL removal from V4L2 radio drivers Hans Verkuil
2010-11-14 13:22 ` [RFC PATCH 3/8] cadet: use unlocked_ioctl Hans Verkuil
2010-11-14 13:22 ` Hans Verkuil [this message]
2010-11-14 13:22 ` [RFC PATCH 5/8] si4713: convert to unlocked_ioctl Hans Verkuil
2010-11-14 13:22 ` [RFC PATCH 6/8] typhoon: " Hans Verkuil
2010-11-14 13:23 ` [RFC PATCH 7/8] dsbr100: " Hans Verkuil
2010-11-14 13:23 ` [RFC PATCH 8/8] BKL: trivial ioctl -> unlocked_ioctl video driver conversions Hans Verkuil
2010-11-14 21:53 ` [RFC PATCH 0/8] V4L BKL removal: first round Arnd Bergmann
2010-11-14 22:48   ` Hans Verkuil
2010-11-15  9:17     ` Arnd Bergmann
2010-11-15  9:49       ` Hans Verkuil
2010-11-16 12:19         ` Mauro Carvalho Chehab
2010-11-16 12:35           ` Hans Verkuil
2010-11-16 13:06             ` Mauro Carvalho Chehab
2010-11-16 13:20               ` Hans Verkuil
2010-11-16 14:22                 ` Arnd Bergmann
2010-11-16 14:50                   ` Hans Verkuil
2010-11-16 15:13                     ` Arnd Bergmann
2010-11-16 15:27                       ` Hans Verkuil
2010-11-16 15:30                         ` Hans Verkuil
2010-11-16 16:01                           ` Arnd Bergmann
2010-11-16 16:32                             ` Mauro Carvalho Chehab
2010-11-16 16:49                             ` Hans Verkuil
2010-11-16 18:38                               ` Hans Verkuil
2010-11-16 19:23                                 ` Arnd Bergmann
2010-11-16 19:59                                 ` Andy Walls
2010-11-16 20:29                                   ` Hans Verkuil
2010-11-16 21:10                                     ` Hans Verkuil
2010-11-16 21:32                                       ` David Ellingsworth
2010-11-16 21:42                                         ` Hans Verkuil
2010-11-17 15:36                                           ` David Ellingsworth

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=f68e17ac4762a21cd0a2806f7da5a10c9c5866a3.1289740431.git.hverkuil@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=arnd@arndb.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.