aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio/radio-aztech.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio/radio-aztech.c')
-rw-r--r--drivers/media/radio/radio-aztech.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index 628c689e3ffe..d78489573230 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -70,6 +70,7 @@ static struct mutex lock;
70 70
71struct az_device 71struct az_device
72{ 72{
73 unsigned long in_use;
73 int curvol; 74 int curvol;
74 unsigned long curfreq; 75 unsigned long curfreq;
75 int stereo; 76 int stereo;
@@ -195,8 +196,7 @@ static int vidioc_querycap (struct file *file, void *priv,
195static int vidioc_g_tuner (struct file *file, void *priv, 196static int vidioc_g_tuner (struct file *file, void *priv,
196 struct v4l2_tuner *v) 197 struct v4l2_tuner *v)
197{ 198{
198 struct video_device *dev = video_devdata(file); 199 struct az_device *az = video_drvdata(file);
199 struct az_device *az = dev->priv;
200 200
201 if (v->index > 0) 201 if (v->index > 0)
202 return -EINVAL; 202 return -EINVAL;
@@ -264,8 +264,7 @@ static int vidioc_s_audio (struct file *file, void *priv,
264static int vidioc_s_frequency (struct file *file, void *priv, 264static int vidioc_s_frequency (struct file *file, void *priv,
265 struct v4l2_frequency *f) 265 struct v4l2_frequency *f)
266{ 266{
267 struct video_device *dev = video_devdata(file); 267 struct az_device *az = video_drvdata(file);
268 struct az_device *az = dev->priv;
269 268
270 az->curfreq = f->frequency; 269 az->curfreq = f->frequency;
271 az_setfreq(az, az->curfreq); 270 az_setfreq(az, az->curfreq);
@@ -275,8 +274,7 @@ static int vidioc_s_frequency (struct file *file, void *priv,
275static int vidioc_g_frequency (struct file *file, void *priv, 274static int vidioc_g_frequency (struct file *file, void *priv,
276 struct v4l2_frequency *f) 275 struct v4l2_frequency *f)
277{ 276{
278 struct video_device *dev = video_devdata(file); 277 struct az_device *az = video_drvdata(file);
279 struct az_device *az = dev->priv;
280 278
281 f->type = V4L2_TUNER_RADIO; 279 f->type = V4L2_TUNER_RADIO;
282 f->frequency = az->curfreq; 280 f->frequency = az->curfreq;
@@ -302,8 +300,7 @@ static int vidioc_queryctrl (struct file *file, void *priv,
302static int vidioc_g_ctrl (struct file *file, void *priv, 300static int vidioc_g_ctrl (struct file *file, void *priv,
303 struct v4l2_control *ctrl) 301 struct v4l2_control *ctrl)
304{ 302{
305 struct video_device *dev = video_devdata(file); 303 struct az_device *az = video_drvdata(file);
306 struct az_device *az = dev->priv;
307 304
308 switch (ctrl->id) { 305 switch (ctrl->id) {
309 case V4L2_CID_AUDIO_MUTE: 306 case V4L2_CID_AUDIO_MUTE:
@@ -322,8 +319,7 @@ static int vidioc_g_ctrl (struct file *file, void *priv,
322static int vidioc_s_ctrl (struct file *file, void *priv, 319static int vidioc_s_ctrl (struct file *file, void *priv,
323 struct v4l2_control *ctrl) 320 struct v4l2_control *ctrl)
324{ 321{
325 struct video_device *dev = video_devdata(file); 322 struct az_device *az = video_drvdata(file);
326 struct az_device *az = dev->priv;
327 323
328 switch (ctrl->id) { 324 switch (ctrl->id) {
329 case V4L2_CID_AUDIO_MUTE: 325 case V4L2_CID_AUDIO_MUTE:
@@ -342,10 +338,21 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
342 338
343static struct az_device aztech_unit; 339static struct az_device aztech_unit;
344 340
341static int aztech_exclusive_open(struct inode *inode, struct file *file)
342{
343 return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0;
344}
345
346static int aztech_exclusive_release(struct inode *inode, struct file *file)
347{
348 clear_bit(0, &aztech_unit.in_use);
349 return 0;
350}
351
345static const struct file_operations aztech_fops = { 352static const struct file_operations aztech_fops = {
346 .owner = THIS_MODULE, 353 .owner = THIS_MODULE,
347 .open = video_exclusive_open, 354 .open = aztech_exclusive_open,
348 .release = video_exclusive_release, 355 .release = aztech_exclusive_release,
349 .ioctl = video_ioctl2, 356 .ioctl = video_ioctl2,
350#ifdef CONFIG_COMPAT 357#ifdef CONFIG_COMPAT
351 .compat_ioctl = v4l_compat_ioctl32, 358 .compat_ioctl = v4l_compat_ioctl32,
@@ -369,9 +376,10 @@ static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
369}; 376};
370 377
371static struct video_device aztech_radio = { 378static struct video_device aztech_radio = {
372 .name = "Aztech radio", 379 .name = "Aztech radio",
373 .fops = &aztech_fops, 380 .fops = &aztech_fops,
374 .ioctl_ops = &aztech_ioctl_ops, 381 .ioctl_ops = &aztech_ioctl_ops,
382 .release = video_device_release_empty,
375}; 383};
376 384
377module_param_named(debug,aztech_radio.debug, int, 0644); 385module_param_named(debug,aztech_radio.debug, int, 0644);
@@ -392,7 +400,7 @@ static int __init aztech_init(void)
392 } 400 }
393 401
394 mutex_init(&lock); 402 mutex_init(&lock);
395 aztech_radio.priv=&aztech_unit; 403 video_set_drvdata(&aztech_radio, &aztech_unit);
396 404
397 if (video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr) < 0) { 405 if (video_register_device(&aztech_radio, VFL_TYPE_RADIO, radio_nr) < 0) {
398 release_region(io,2); 406 release_region(io,2);