diff mbox

[RFCv3,14/16] radio-maxiradio: convert to core-assisted locking

Message ID ff51bbdf849ecc23a25603412c0c18c5dbd423bc.1294493428.git.hverkuil@xs4all.nl (mailing list archive)
State RFC
Headers show

Commit Message

Hans Verkuil Jan. 8, 2011, 1:36 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 6459a22..1323a56 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -98,12 +98,10 @@  struct maxiradio
 
 	u16	io;	/* base of radio io */
 	u16	muted;	/* VIDEO_AUDIO_MUTE */
-	u16	stereo;	/* VIDEO_TUNER_STEREO_ON */
-	u16	tuned;	/* signal strength (0 or 0xffff) */
 
 	unsigned long freq;
 
-	struct mutex lock;
+	struct mutex v4l2_lock;
 };
 
 static inline struct maxiradio *to_maxiradio(struct v4l2_device *v4l2_dev)
@@ -208,7 +206,6 @@  static int vidioc_g_tuner(struct file *file, void *priv,
 	if (v->index > 0)
 		return -EINVAL;
 
-	mutex_lock(&dev->lock);
 	strlcpy(v->name, "FM", sizeof(v->name));
 	v->type = V4L2_TUNER_RADIO;
 	v->rangelow = FREQ_LO;
@@ -220,8 +217,6 @@  static int vidioc_g_tuner(struct file *file, void *priv,
 	else
 		v->audmode = V4L2_TUNER_MODE_MONO;
 	v->signal = 0xffff * get_tune(dev->io);
-	mutex_unlock(&dev->lock);
-
 	return 0;
 }
 
@@ -274,12 +269,9 @@  static int vidioc_s_frequency(struct file *file, void *priv,
 		return -EINVAL;
 	}
 
-	mutex_lock(&dev->lock);
 	dev->freq = f->frequency;
 	set_freq(dev, dev->freq);
 	msleep(125);
-	mutex_unlock(&dev->lock);
-
 	return 0;
 }
 
@@ -331,13 +323,11 @@  static int vidioc_s_ctrl(struct file *file, void *priv,
 
 	switch (ctrl->id) {
 	case V4L2_CID_AUDIO_MUTE:
-		mutex_lock(&dev->lock);
 		dev->muted = ctrl->value;
 		if (dev->muted)
 			turn_power(dev, 0);
 		else
 			set_freq(dev, dev->freq);
-		mutex_unlock(&dev->lock);
 		return 0;
 	}
 
@@ -377,7 +367,7 @@  static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d
 	}
 
 	v4l2_dev = &dev->v4l2_dev;
-	mutex_init(&dev->lock);
+	mutex_init(&dev->v4l2_lock);
 	dev->pdev = pdev;
 	dev->muted = 1;
 	dev->freq = FREQ_LO;
@@ -405,6 +395,7 @@  static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d
 	dev->vdev.fops = &maxiradio_fops;
 	dev->vdev.ioctl_ops = &maxiradio_ioctl_ops;
 	dev->vdev.release = video_device_release_empty;
+	dev->vdev.lock = &dev->v4l2_lock;
 	video_set_drvdata(&dev->vdev, dev);
 
 	if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {