diff options
Diffstat (limited to 'drivers/media/radio/radio-maxiradio.c')
-rw-r--r-- | drivers/media/radio/radio-maxiradio.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 0cc6fcb041fd..c777a17b00bc 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -85,6 +85,7 @@ static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16 ; | |||
85 | static int radio_nr = -1; | 85 | static int radio_nr = -1; |
86 | module_param(radio_nr, int, 0); | 86 | module_param(radio_nr, int, 0); |
87 | 87 | ||
88 | static unsigned long in_use; | ||
88 | 89 | ||
89 | #define FREQ_LO 50*16000 | 90 | #define FREQ_LO 50*16000 |
90 | #define FREQ_HI 150*16000 | 91 | #define FREQ_HI 150*16000 |
@@ -99,10 +100,21 @@ module_param(radio_nr, int, 0); | |||
99 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) | 100 | #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) |
100 | 101 | ||
101 | 102 | ||
103 | static int maxiradio_exclusive_open(struct inode *inode, struct file *file) | ||
104 | { | ||
105 | return test_and_set_bit(0, &in_use) ? -EBUSY : 0; | ||
106 | } | ||
107 | |||
108 | static int maxiradio_exclusive_release(struct inode *inode, struct file *file) | ||
109 | { | ||
110 | clear_bit(0, &in_use); | ||
111 | return 0; | ||
112 | } | ||
113 | |||
102 | static const struct file_operations maxiradio_fops = { | 114 | static const struct file_operations maxiradio_fops = { |
103 | .owner = THIS_MODULE, | 115 | .owner = THIS_MODULE, |
104 | .open = video_exclusive_open, | 116 | .open = maxiradio_exclusive_open, |
105 | .release = video_exclusive_release, | 117 | .release = maxiradio_exclusive_release, |
106 | .ioctl = video_ioctl2, | 118 | .ioctl = video_ioctl2, |
107 | #ifdef CONFIG_COMPAT | 119 | #ifdef CONFIG_COMPAT |
108 | .compat_ioctl = v4l_compat_ioctl32, | 120 | .compat_ioctl = v4l_compat_ioctl32, |
@@ -219,8 +231,7 @@ static int vidioc_querycap (struct file *file, void *priv, | |||
219 | static int vidioc_g_tuner (struct file *file, void *priv, | 231 | static int vidioc_g_tuner (struct file *file, void *priv, |
220 | struct v4l2_tuner *v) | 232 | struct v4l2_tuner *v) |
221 | { | 233 | { |
222 | struct video_device *dev = video_devdata(file); | 234 | struct radio_device *card = video_drvdata(file); |
223 | struct radio_device *card=dev->priv; | ||
224 | 235 | ||
225 | if (v->index > 0) | 236 | if (v->index > 0) |
226 | return -EINVAL; | 237 | return -EINVAL; |
@@ -290,8 +301,7 @@ static int vidioc_s_audio (struct file *file, void *priv, | |||
290 | static int vidioc_s_frequency (struct file *file, void *priv, | 301 | static int vidioc_s_frequency (struct file *file, void *priv, |
291 | struct v4l2_frequency *f) | 302 | struct v4l2_frequency *f) |
292 | { | 303 | { |
293 | struct video_device *dev = video_devdata(file); | 304 | struct radio_device *card = video_drvdata(file); |
294 | struct radio_device *card=dev->priv; | ||
295 | 305 | ||
296 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { | 306 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) { |
297 | dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", | 307 | dprintk(1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n", |
@@ -312,8 +322,7 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
312 | static int vidioc_g_frequency (struct file *file, void *priv, | 322 | static int vidioc_g_frequency (struct file *file, void *priv, |
313 | struct v4l2_frequency *f) | 323 | struct v4l2_frequency *f) |
314 | { | 324 | { |
315 | struct video_device *dev = video_devdata(file); | 325 | struct radio_device *card = video_drvdata(file); |
316 | struct radio_device *card=dev->priv; | ||
317 | 326 | ||
318 | f->type = V4L2_TUNER_RADIO; | 327 | f->type = V4L2_TUNER_RADIO; |
319 | f->frequency = card->freq; | 328 | f->frequency = card->freq; |
@@ -343,8 +352,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
343 | static int vidioc_g_ctrl (struct file *file, void *priv, | 352 | static int vidioc_g_ctrl (struct file *file, void *priv, |
344 | struct v4l2_control *ctrl) | 353 | struct v4l2_control *ctrl) |
345 | { | 354 | { |
346 | struct video_device *dev = video_devdata(file); | 355 | struct radio_device *card = video_drvdata(file); |
347 | struct radio_device *card=dev->priv; | ||
348 | 356 | ||
349 | switch (ctrl->id) { | 357 | switch (ctrl->id) { |
350 | case V4L2_CID_AUDIO_MUTE: | 358 | case V4L2_CID_AUDIO_MUTE: |
@@ -358,8 +366,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv, | |||
358 | static int vidioc_s_ctrl (struct file *file, void *priv, | 366 | static int vidioc_s_ctrl (struct file *file, void *priv, |
359 | struct v4l2_control *ctrl) | 367 | struct v4l2_control *ctrl) |
360 | { | 368 | { |
361 | struct video_device *dev = video_devdata(file); | 369 | struct radio_device *card = video_drvdata(file); |
362 | struct radio_device *card=dev->priv; | ||
363 | 370 | ||
364 | switch (ctrl->id) { | 371 | switch (ctrl->id) { |
365 | case V4L2_CID_AUDIO_MUTE: | 372 | case V4L2_CID_AUDIO_MUTE: |
@@ -390,9 +397,10 @@ static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = { | |||
390 | }; | 397 | }; |
391 | 398 | ||
392 | static struct video_device maxiradio_radio = { | 399 | static struct video_device maxiradio_radio = { |
393 | .name = "Maxi Radio FM2000 radio", | 400 | .name = "Maxi Radio FM2000 radio", |
394 | .fops = &maxiradio_fops, | 401 | .fops = &maxiradio_fops, |
395 | .ioctl_ops = &maxiradio_ioctl_ops, | 402 | .ioctl_ops = &maxiradio_ioctl_ops, |
403 | .release = video_device_release_empty, | ||
396 | }; | 404 | }; |
397 | 405 | ||
398 | static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | 406 | static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
@@ -408,7 +416,7 @@ static int __devinit maxiradio_init_one(struct pci_dev *pdev, const struct pci_d | |||
408 | 416 | ||
409 | radio_unit.io = pci_resource_start(pdev, 0); | 417 | radio_unit.io = pci_resource_start(pdev, 0); |
410 | mutex_init(&radio_unit.lock); | 418 | mutex_init(&radio_unit.lock); |
411 | maxiradio_radio.priv = &radio_unit; | 419 | video_set_drvdata(&maxiradio_radio, &radio_unit); |
412 | 420 | ||
413 | if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) { | 421 | if (video_register_device(&maxiradio_radio, VFL_TYPE_RADIO, radio_nr) < 0) { |
414 | printk("radio-maxiradio: can't register device!"); | 422 | printk("radio-maxiradio: can't register device!"); |