aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-gemtek.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-gemtek.c')
-rw-r--r--drivers/media/radio/radio-gemtek.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 0a0f956bb308..d131a5d38128 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -57,6 +57,7 @@ static int shutdown = 1;
57static int keepmuted = 1; 57static int keepmuted = 1;
58static int initmute = 1; 58static int initmute = 1;
59static int radio_nr = -1; 59static int radio_nr = -1;
60static unsigned long in_use;
60 61
61module_param(io, int, 0444); 62module_param(io, int, 0444);
62MODULE_PARM_DESC(io, "Force I/O port for the GemTek Radio card if automatic " 63MODULE_PARM_DESC(io, "Force I/O port for the GemTek Radio card if automatic "
@@ -393,10 +394,21 @@ static struct v4l2_queryctrl radio_qctrl[] = {
393 } 394 }
394}; 395};
395 396
397static int gemtek_exclusive_open(struct inode *inode, struct file *file)
398{
399 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
400}
401
402static int gemtek_exclusive_release(struct inode *inode, struct file *file)
403{
404 clear_bit(0, &in_use);
405 return 0;
406}
407
396static const struct file_operations gemtek_fops = { 408static const struct file_operations gemtek_fops = {
397 .owner = THIS_MODULE, 409 .owner = THIS_MODULE,
398 .open = video_exclusive_open, 410 .open = gemtek_exclusive_open,
399 .release = video_exclusive_release, 411 .release = gemtek_exclusive_release,
400 .ioctl = video_ioctl2, 412 .ioctl = video_ioctl2,
401#ifdef CONFIG_COMPAT 413#ifdef CONFIG_COMPAT
402 .compat_ioctl = v4l_compat_ioctl32, 414 .compat_ioctl = v4l_compat_ioctl32,
@@ -447,8 +459,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *v)
447static int vidioc_s_frequency(struct file *file, void *priv, 459static int vidioc_s_frequency(struct file *file, void *priv,
448 struct v4l2_frequency *f) 460 struct v4l2_frequency *f)
449{ 461{
450 struct video_device *dev = video_devdata(file); 462 struct gemtek_device *rt = video_drvdata(file);
451 struct gemtek_device *rt = dev->priv;
452 463
453 gemtek_setfreq(rt, f->frequency); 464 gemtek_setfreq(rt, f->frequency);
454 465
@@ -458,8 +469,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
458static int vidioc_g_frequency(struct file *file, void *priv, 469static int vidioc_g_frequency(struct file *file, void *priv,
459 struct v4l2_frequency *f) 470 struct v4l2_frequency *f)
460{ 471{
461 struct video_device *dev = video_devdata(file); 472 struct gemtek_device *rt = video_drvdata(file);
462 struct gemtek_device *rt = dev->priv;
463 473
464 f->type = V4L2_TUNER_RADIO; 474 f->type = V4L2_TUNER_RADIO;
465 f->frequency = rt->lastfreq; 475 f->frequency = rt->lastfreq;
@@ -483,8 +493,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
483static int vidioc_g_ctrl(struct file *file, void *priv, 493static int vidioc_g_ctrl(struct file *file, void *priv,
484 struct v4l2_control *ctrl) 494 struct v4l2_control *ctrl)
485{ 495{
486 struct video_device *dev = video_devdata(file); 496 struct gemtek_device *rt = video_drvdata(file);
487 struct gemtek_device *rt = dev->priv;
488 497
489 switch (ctrl->id) { 498 switch (ctrl->id) {
490 case V4L2_CID_AUDIO_MUTE: 499 case V4L2_CID_AUDIO_MUTE:
@@ -503,8 +512,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
503static int vidioc_s_ctrl(struct file *file, void *priv, 512static int vidioc_s_ctrl(struct file *file, void *priv,
504 struct v4l2_control *ctrl) 513 struct v4l2_control *ctrl)
505{ 514{
506 struct video_device *dev = video_devdata(file); 515 struct gemtek_device *rt = video_drvdata(file);
507 struct gemtek_device *rt = dev->priv;
508 516
509 switch (ctrl->id) { 517 switch (ctrl->id) {
510 case V4L2_CID_AUDIO_MUTE: 518 case V4L2_CID_AUDIO_MUTE:
@@ -569,9 +577,10 @@ static const struct v4l2_ioctl_ops gemtek_ioctl_ops = {
569}; 577};
570 578
571static struct video_device gemtek_radio = { 579static struct video_device gemtek_radio = {
572 .name = "GemTek Radio card", 580 .name = "GemTek Radio card",
573 .fops = &gemtek_fops, 581 .fops = &gemtek_fops,
574 .ioctl_ops = &gemtek_ioctl_ops, 582 .ioctl_ops = &gemtek_ioctl_ops,
583 .release = video_device_release_empty,
575}; 584};
576 585
577/* 586/*
@@ -610,7 +619,7 @@ static int __init gemtek_init(void)
610 return -EINVAL; 619 return -EINVAL;
611 } 620 }
612 621
613 gemtek_radio.priv = &gemtek_unit; 622 video_set_drvdata(&gemtek_radio, &gemtek_unit);
614 623
615 if (video_register_device(&gemtek_radio, VFL_TYPE_RADIO, radio_nr) < 0) { 624 if (video_register_device(&gemtek_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
616 release_region(io, 1); 625 release_region(io, 1);