aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-aimslab.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-aimslab.c')
-rw-r--r--drivers/media/radio/radio-aimslab.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 1f064f4b32df..9305e958fc66 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -51,6 +51,7 @@ static struct mutex lock;
51 51
52struct rt_device 52struct rt_device
53{ 53{
54 unsigned long in_use;
54 int port; 55 int port;
55 int curvol; 56 int curvol;
56 unsigned long curfreq; 57 unsigned long curfreq;
@@ -245,8 +246,7 @@ static int vidioc_querycap(struct file *file, void *priv,
245static int vidioc_g_tuner(struct file *file, void *priv, 246static int vidioc_g_tuner(struct file *file, void *priv,
246 struct v4l2_tuner *v) 247 struct v4l2_tuner *v)
247{ 248{
248 struct video_device *dev = video_devdata(file); 249 struct rt_device *rt = video_drvdata(file);
249 struct rt_device *rt = dev->priv;
250 250
251 if (v->index > 0) 251 if (v->index > 0)
252 return -EINVAL; 252 return -EINVAL;
@@ -273,8 +273,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
273static int vidioc_s_frequency(struct file *file, void *priv, 273static int vidioc_s_frequency(struct file *file, void *priv,
274 struct v4l2_frequency *f) 274 struct v4l2_frequency *f)
275{ 275{
276 struct video_device *dev = video_devdata(file); 276 struct rt_device *rt = video_drvdata(file);
277 struct rt_device *rt = dev->priv;
278 277
279 rt->curfreq = f->frequency; 278 rt->curfreq = f->frequency;
280 rt_setfreq(rt, rt->curfreq); 279 rt_setfreq(rt, rt->curfreq);
@@ -284,8 +283,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
284static int vidioc_g_frequency(struct file *file, void *priv, 283static int vidioc_g_frequency(struct file *file, void *priv,
285 struct v4l2_frequency *f) 284 struct v4l2_frequency *f)
286{ 285{
287 struct video_device *dev = video_devdata(file); 286 struct rt_device *rt = video_drvdata(file);
288 struct rt_device *rt = dev->priv;
289 287
290 f->type = V4L2_TUNER_RADIO; 288 f->type = V4L2_TUNER_RADIO;
291 f->frequency = rt->curfreq; 289 f->frequency = rt->curfreq;
@@ -310,8 +308,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
310static int vidioc_g_ctrl(struct file *file, void *priv, 308static int vidioc_g_ctrl(struct file *file, void *priv,
311 struct v4l2_control *ctrl) 309 struct v4l2_control *ctrl)
312{ 310{
313 struct video_device *dev = video_devdata(file); 311 struct rt_device *rt = video_drvdata(file);
314 struct rt_device *rt = dev->priv;
315 312
316 switch (ctrl->id) { 313 switch (ctrl->id) {
317 case V4L2_CID_AUDIO_MUTE: 314 case V4L2_CID_AUDIO_MUTE:
@@ -327,8 +324,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
327static int vidioc_s_ctrl(struct file *file, void *priv, 324static int vidioc_s_ctrl(struct file *file, void *priv,
328 struct v4l2_control *ctrl) 325 struct v4l2_control *ctrl)
329{ 326{
330 struct video_device *dev = video_devdata(file); 327 struct rt_device *rt = video_drvdata(file);
331 struct rt_device *rt = dev->priv;
332 328
333 switch (ctrl->id) { 329 switch (ctrl->id) {
334 case V4L2_CID_AUDIO_MUTE: 330 case V4L2_CID_AUDIO_MUTE:
@@ -378,10 +374,21 @@ static int vidioc_s_audio(struct file *file, void *priv,
378 374
379static struct rt_device rtrack_unit; 375static struct rt_device rtrack_unit;
380 376
377static int rtrack_exclusive_open(struct inode *inode, struct file *file)
378{
379 return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0;
380}
381
382static int rtrack_exclusive_release(struct inode *inode, struct file *file)
383{
384 clear_bit(0, &rtrack_unit.in_use);
385 return 0;
386}
387
381static const struct file_operations rtrack_fops = { 388static const struct file_operations rtrack_fops = {
382 .owner = THIS_MODULE, 389 .owner = THIS_MODULE,
383 .open = video_exclusive_open, 390 .open = rtrack_exclusive_open,
384 .release = video_exclusive_release, 391 .release = rtrack_exclusive_release,
385 .ioctl = video_ioctl2, 392 .ioctl = video_ioctl2,
386#ifdef CONFIG_COMPAT 393#ifdef CONFIG_COMPAT
387 .compat_ioctl = v4l_compat_ioctl32, 394 .compat_ioctl = v4l_compat_ioctl32,
@@ -408,6 +415,7 @@ static struct video_device rtrack_radio = {
408 .name = "RadioTrack radio", 415 .name = "RadioTrack radio",
409 .fops = &rtrack_fops, 416 .fops = &rtrack_fops,
410 .ioctl_ops = &rtrack_ioctl_ops, 417 .ioctl_ops = &rtrack_ioctl_ops,
418 .release = video_device_release_empty,
411}; 419};
412 420
413static int __init rtrack_init(void) 421static int __init rtrack_init(void)
@@ -424,7 +432,7 @@ static int __init rtrack_init(void)
424 return -EBUSY; 432 return -EBUSY;
425 } 433 }
426 434
427 rtrack_radio.priv=&rtrack_unit; 435 video_set_drvdata(&rtrack_radio, &rtrack_unit);
428 436
429 if (video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr) < 0) { 437 if (video_register_device(&rtrack_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
430 release_region(io, 2); 438 release_region(io, 2);