aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-maestro.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-maestro.c')
-rw-r--r--drivers/media/radio/radio-maestro.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 9ef0a763eeb7..4bf4d007bcfa 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -75,7 +75,21 @@ static struct v4l2_queryctrl radio_qctrl[] = {
75static int radio_nr = -1; 75static int radio_nr = -1;
76module_param(radio_nr, int, 0); 76module_param(radio_nr, int, 0);
77 77
78static unsigned long in_use;
79
78static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); 80static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
81
82static int maestro_exclusive_open(struct inode *inode, struct file *file)
83{
84 return test_and_set_bit(0, &in_use) ? -EBUSY : 0;
85}
86
87static int maestro_exclusive_release(struct inode *inode, struct file *file)
88{
89 clear_bit(0, &in_use);
90 return 0;
91}
92
79static void maestro_remove(struct pci_dev *pdev); 93static void maestro_remove(struct pci_dev *pdev);
80 94
81static struct pci_device_id maestro_r_pci_tbl[] = { 95static struct pci_device_id maestro_r_pci_tbl[] = {
@@ -98,8 +112,8 @@ static struct pci_driver maestro_r_driver = {
98 112
99static const struct file_operations maestro_fops = { 113static const struct file_operations maestro_fops = {
100 .owner = THIS_MODULE, 114 .owner = THIS_MODULE,
101 .open = video_exclusive_open, 115 .open = maestro_exclusive_open,
102 .release = video_exclusive_release, 116 .release = maestro_exclusive_release,
103 .ioctl = video_ioctl2, 117 .ioctl = video_ioctl2,
104#ifdef CONFIG_COMPAT 118#ifdef CONFIG_COMPAT
105 .compat_ioctl = v4l_compat_ioctl32, 119 .compat_ioctl = v4l_compat_ioctl32,
@@ -196,8 +210,7 @@ static int vidioc_querycap(struct file *file, void *priv,
196static int vidioc_g_tuner(struct file *file, void *priv, 210static int vidioc_g_tuner(struct file *file, void *priv,
197 struct v4l2_tuner *v) 211 struct v4l2_tuner *v)
198{ 212{
199 struct video_device *dev = video_devdata(file); 213 struct radio_device *card = video_drvdata(file);
200 struct radio_device *card = video_get_drvdata(dev);
201 214
202 if (v->index > 0) 215 if (v->index > 0)
203 return -EINVAL; 216 return -EINVAL;
@@ -229,8 +242,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
229static int vidioc_s_frequency(struct file *file, void *priv, 242static int vidioc_s_frequency(struct file *file, void *priv,
230 struct v4l2_frequency *f) 243 struct v4l2_frequency *f)
231{ 244{
232 struct video_device *dev = video_devdata(file); 245 struct radio_device *card = video_drvdata(file);
233 struct radio_device *card = video_get_drvdata(dev);
234 246
235 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) 247 if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
236 return -EINVAL; 248 return -EINVAL;
@@ -241,8 +253,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
241static int vidioc_g_frequency(struct file *file, void *priv, 253static int vidioc_g_frequency(struct file *file, void *priv,
242 struct v4l2_frequency *f) 254 struct v4l2_frequency *f)
243{ 255{
244 struct video_device *dev = video_devdata(file); 256 struct radio_device *card = video_drvdata(file);
245 struct radio_device *card = video_get_drvdata(dev);
246 257
247 f->type = V4L2_TUNER_RADIO; 258 f->type = V4L2_TUNER_RADIO;
248 f->frequency = BITS2FREQ(radio_bits_get(card)); 259 f->frequency = BITS2FREQ(radio_bits_get(card));
@@ -267,8 +278,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
267static int vidioc_g_ctrl(struct file *file, void *priv, 278static int vidioc_g_ctrl(struct file *file, void *priv,
268 struct v4l2_control *ctrl) 279 struct v4l2_control *ctrl)
269{ 280{
270 struct video_device *dev = video_devdata(file); 281 struct radio_device *card = video_drvdata(file);
271 struct radio_device *card = video_get_drvdata(dev);
272 282
273 switch (ctrl->id) { 283 switch (ctrl->id) {
274 case V4L2_CID_AUDIO_MUTE: 284 case V4L2_CID_AUDIO_MUTE:
@@ -281,8 +291,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
281static int vidioc_s_ctrl(struct file *file, void *priv, 291static int vidioc_s_ctrl(struct file *file, void *priv,
282 struct v4l2_control *ctrl) 292 struct v4l2_control *ctrl)
283{ 293{
284 struct video_device *dev = video_devdata(file); 294 struct radio_device *card = video_drvdata(file);
285 struct radio_device *card = video_get_drvdata(dev);
286 register u16 io = card->io; 295 register u16 io = card->io;
287 register u16 omask = inw(io + IO_MASK); 296 register u16 omask = inw(io + IO_MASK);
288 297
@@ -374,6 +383,7 @@ static struct video_device maestro_radio = {
374 .name = "Maestro radio", 383 .name = "Maestro radio",
375 .fops = &maestro_fops, 384 .fops = &maestro_fops,
376 .ioctl_ops = &maestro_ioctl_ops, 385 .ioctl_ops = &maestro_ioctl_ops,
386 .release = video_device_release,
377}; 387};
378 388
379static int __devinit maestro_probe(struct pci_dev *pdev, 389static int __devinit maestro_probe(struct pci_dev *pdev,