aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-sf16fmr2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-sf16fmr2.c')
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 6290553d24be..b1f47c322e02 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -64,6 +64,7 @@ static struct v4l2_queryctrl radio_qctrl[] = {
64/* this should be static vars for module size */ 64/* this should be static vars for module size */
65struct fmr2_device 65struct fmr2_device
66{ 66{
67 unsigned long in_use;
67 int port; 68 int port;
68 int curvol; /* 0-15 */ 69 int curvol; /* 0-15 */
69 int mute; 70 int mute;
@@ -229,8 +230,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
229 struct v4l2_tuner *v) 230 struct v4l2_tuner *v)
230{ 231{
231 int mult; 232 int mult;
232 struct video_device *dev = video_devdata(file); 233 struct fmr2_device *fmr2 = video_drvdata(file);
233 struct fmr2_device *fmr2 = dev->priv;
234 234
235 if (v->index > 0) 235 if (v->index > 0)
236 return -EINVAL; 236 return -EINVAL;
@@ -262,8 +262,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
262static int vidioc_s_frequency(struct file *file, void *priv, 262static int vidioc_s_frequency(struct file *file, void *priv,
263 struct v4l2_frequency *f) 263 struct v4l2_frequency *f)
264{ 264{
265 struct video_device *dev = video_devdata(file); 265 struct fmr2_device *fmr2 = video_drvdata(file);
266 struct fmr2_device *fmr2 = dev->priv;
267 266
268 if (!(fmr2->flags & V4L2_TUNER_CAP_LOW)) 267 if (!(fmr2->flags & V4L2_TUNER_CAP_LOW))
269 f->frequency *= 1000; 268 f->frequency *= 1000;
@@ -286,8 +285,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
286static int vidioc_g_frequency(struct file *file, void *priv, 285static int vidioc_g_frequency(struct file *file, void *priv,
287 struct v4l2_frequency *f) 286 struct v4l2_frequency *f)
288{ 287{
289 struct video_device *dev = video_devdata(file); 288 struct fmr2_device *fmr2 = video_drvdata(file);
290 struct fmr2_device *fmr2 = dev->priv;
291 289
292 f->type = V4L2_TUNER_RADIO; 290 f->type = V4L2_TUNER_RADIO;
293 f->frequency = fmr2->curfreq; 291 f->frequency = fmr2->curfreq;
@@ -313,8 +311,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
313static int vidioc_g_ctrl(struct file *file, void *priv, 311static int vidioc_g_ctrl(struct file *file, void *priv,
314 struct v4l2_control *ctrl) 312 struct v4l2_control *ctrl)
315{ 313{
316 struct video_device *dev = video_devdata(file); 314 struct fmr2_device *fmr2 = video_drvdata(file);
317 struct fmr2_device *fmr2 = dev->priv;
318 315
319 switch (ctrl->id) { 316 switch (ctrl->id) {
320 case V4L2_CID_AUDIO_MUTE: 317 case V4L2_CID_AUDIO_MUTE:
@@ -330,8 +327,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
330static int vidioc_s_ctrl(struct file *file, void *priv, 327static int vidioc_s_ctrl(struct file *file, void *priv,
331 struct v4l2_control *ctrl) 328 struct v4l2_control *ctrl)
332{ 329{
333 struct video_device *dev = video_devdata(file); 330 struct fmr2_device *fmr2 = video_drvdata(file);
334 struct fmr2_device *fmr2 = dev->priv;
335 331
336 switch (ctrl->id) { 332 switch (ctrl->id) {
337 case V4L2_CID_AUDIO_MUTE: 333 case V4L2_CID_AUDIO_MUTE:
@@ -400,10 +396,21 @@ static int vidioc_s_audio(struct file *file, void *priv,
400 396
401static struct fmr2_device fmr2_unit; 397static struct fmr2_device fmr2_unit;
402 398
399static int fmr2_exclusive_open(struct inode *inode, struct file *file)
400{
401 return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0;
402}
403
404static int fmr2_exclusive_release(struct inode *inode, struct file *file)
405{
406 clear_bit(0, &fmr2_unit.in_use);
407 return 0;
408}
409
403static const struct file_operations fmr2_fops = { 410static const struct file_operations fmr2_fops = {
404 .owner = THIS_MODULE, 411 .owner = THIS_MODULE,
405 .open = video_exclusive_open, 412 .open = fmr2_exclusive_open,
406 .release = video_exclusive_release, 413 .release = fmr2_exclusive_release,
407 .ioctl = video_ioctl2, 414 .ioctl = video_ioctl2,
408#ifdef CONFIG_COMPAT 415#ifdef CONFIG_COMPAT
409 .compat_ioctl = v4l_compat_ioctl32, 416 .compat_ioctl = v4l_compat_ioctl32,
@@ -430,6 +437,7 @@ static struct video_device fmr2_radio = {
430 .name = "SF16FMR2 radio", 437 .name = "SF16FMR2 radio",
431 .fops = &fmr2_fops, 438 .fops = &fmr2_fops,
432 .ioctl_ops = &fmr2_ioctl_ops, 439 .ioctl_ops = &fmr2_ioctl_ops,
440 .release = video_device_release_empty,
433}; 441};
434 442
435static int __init fmr2_init(void) 443static int __init fmr2_init(void)
@@ -441,7 +449,7 @@ static int __init fmr2_init(void)
441 fmr2_unit.stereo = 1; 449 fmr2_unit.stereo = 1;
442 fmr2_unit.flags = V4L2_TUNER_CAP_LOW; 450 fmr2_unit.flags = V4L2_TUNER_CAP_LOW;
443 fmr2_unit.card_type = 0; 451 fmr2_unit.card_type = 0;
444 fmr2_radio.priv = &fmr2_unit; 452 video_set_drvdata(&fmr2_radio, &fmr2_unit);
445 453
446 mutex_init(&lock); 454 mutex_init(&lock);
447 455