aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-terratec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-terratec.c')
-rw-r--r--drivers/media/radio/radio-terratec.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index 0876fecc5f27..0abb186a9473 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -79,6 +79,7 @@ static spinlock_t lock;
79 79
80struct tt_device 80struct tt_device
81{ 81{
82 unsigned long in_use;
82 int port; 83 int port;
83 int curvol; 84 int curvol;
84 unsigned long curfreq; 85 unsigned long curfreq;
@@ -220,8 +221,7 @@ static int vidioc_querycap(struct file *file, void *priv,
220static int vidioc_g_tuner(struct file *file, void *priv, 221static int vidioc_g_tuner(struct file *file, void *priv,
221 struct v4l2_tuner *v) 222 struct v4l2_tuner *v)
222{ 223{
223 struct video_device *dev = video_devdata(file); 224 struct tt_device *tt = video_drvdata(file);
224 struct tt_device *tt = dev->priv;
225 225
226 if (v->index > 0) 226 if (v->index > 0)
227 return -EINVAL; 227 return -EINVAL;
@@ -248,8 +248,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
248static int vidioc_s_frequency(struct file *file, void *priv, 248static int vidioc_s_frequency(struct file *file, void *priv,
249 struct v4l2_frequency *f) 249 struct v4l2_frequency *f)
250{ 250{
251 struct video_device *dev = video_devdata(file); 251 struct tt_device *tt = video_drvdata(file);
252 struct tt_device *tt = dev->priv;
253 252
254 tt->curfreq = f->frequency; 253 tt->curfreq = f->frequency;
255 tt_setfreq(tt, tt->curfreq); 254 tt_setfreq(tt, tt->curfreq);
@@ -259,8 +258,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
259static int vidioc_g_frequency(struct file *file, void *priv, 258static int vidioc_g_frequency(struct file *file, void *priv,
260 struct v4l2_frequency *f) 259 struct v4l2_frequency *f)
261{ 260{
262 struct video_device *dev = video_devdata(file); 261 struct tt_device *tt = video_drvdata(file);
263 struct tt_device *tt = dev->priv;
264 262
265 f->type = V4L2_TUNER_RADIO; 263 f->type = V4L2_TUNER_RADIO;
266 f->frequency = tt->curfreq; 264 f->frequency = tt->curfreq;
@@ -285,8 +283,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
285static int vidioc_g_ctrl(struct file *file, void *priv, 283static int vidioc_g_ctrl(struct file *file, void *priv,
286 struct v4l2_control *ctrl) 284 struct v4l2_control *ctrl)
287{ 285{
288 struct video_device *dev = video_devdata(file); 286 struct tt_device *tt = video_drvdata(file);
289 struct tt_device *tt = dev->priv;
290 287
291 switch (ctrl->id) { 288 switch (ctrl->id) {
292 case V4L2_CID_AUDIO_MUTE: 289 case V4L2_CID_AUDIO_MUTE:
@@ -305,8 +302,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
305static int vidioc_s_ctrl(struct file *file, void *priv, 302static int vidioc_s_ctrl(struct file *file, void *priv,
306 struct v4l2_control *ctrl) 303 struct v4l2_control *ctrl)
307{ 304{
308 struct video_device *dev = video_devdata(file); 305 struct tt_device *tt = video_drvdata(file);
309 struct tt_device *tt = dev->priv;
310 306
311 switch (ctrl->id) { 307 switch (ctrl->id) {
312 case V4L2_CID_AUDIO_MUTE: 308 case V4L2_CID_AUDIO_MUTE:
@@ -356,10 +352,21 @@ static int vidioc_s_audio(struct file *file, void *priv,
356 352
357static struct tt_device terratec_unit; 353static struct tt_device terratec_unit;
358 354
355static int terratec_exclusive_open(struct inode *inode, struct file *file)
356{
357 return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0;
358}
359
360static int terratec_exclusive_release(struct inode *inode, struct file *file)
361{
362 clear_bit(0, &terratec_unit.in_use);
363 return 0;
364}
365
359static const struct file_operations terratec_fops = { 366static const struct file_operations terratec_fops = {
360 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
361 .open = video_exclusive_open, 368 .open = terratec_exclusive_open,
362 .release = video_exclusive_release, 369 .release = terratec_exclusive_release,
363 .ioctl = video_ioctl2, 370 .ioctl = video_ioctl2,
364#ifdef CONFIG_COMPAT 371#ifdef CONFIG_COMPAT
365 .compat_ioctl = v4l_compat_ioctl32, 372 .compat_ioctl = v4l_compat_ioctl32,
@@ -386,6 +393,7 @@ static struct video_device terratec_radio = {
386 .name = "TerraTec ActiveRadio", 393 .name = "TerraTec ActiveRadio",
387 .fops = &terratec_fops, 394 .fops = &terratec_fops,
388 .ioctl_ops = &terratec_ioctl_ops, 395 .ioctl_ops = &terratec_ioctl_ops,
396 .release = video_device_release_empty,
389}; 397};
390 398
391static int __init terratec_init(void) 399static int __init terratec_init(void)
@@ -401,7 +409,7 @@ static int __init terratec_init(void)
401 return -EBUSY; 409 return -EBUSY;
402 } 410 }
403 411
404 terratec_radio.priv=&terratec_unit; 412 video_set_drvdata(&terratec_radio, &terratec_unit);
405 413
406 spin_lock_init(&lock); 414 spin_lock_init(&lock);
407 415