diff options
author | David Ellingsworth <david@identd.dyndns.org> | 2009-09-23 16:45:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-05 15:40:09 -0500 |
commit | ceb99e1b5a093ae8f439fc55aac28d007145c8ec (patch) | |
tree | 23e2089e0f82b1f4d7560210d50237eafd0c1ce6 /drivers | |
parent | d1939e4c5f053e34dd432b448e221f55586a68ec (diff) |
V4L/DVB (13064): radio-mr800: simplify access to amradio_device
Simplify access to amradio_device.
Signed-off-by: David Ellingsworth <david@identd.dyndns.org>
Acked-by: Alexey Klimov <klimov.linux@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/radio/radio-mr800.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 24c55a5a6cac..5401952004bc 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c | |||
@@ -141,6 +141,8 @@ struct amradio_device { | |||
141 | int muted; | 141 | int muted; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | #define vdev_to_amradio(r) container_of(r, struct amradio_device, videodev) | ||
145 | |||
144 | /* USB Device ID List */ | 146 | /* USB Device ID List */ |
145 | static struct usb_device_id usb_amradio_device_table[] = { | 147 | static struct usb_device_id usb_amradio_device_table[] = { |
146 | {USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT, | 148 | {USB_DEVICE_AND_INTERFACE_INFO(USB_AMRADIO_VENDOR, USB_AMRADIO_PRODUCT, |
@@ -280,7 +282,7 @@ static void usb_amradio_disconnect(struct usb_interface *intf) | |||
280 | static int vidioc_querycap(struct file *file, void *priv, | 282 | static int vidioc_querycap(struct file *file, void *priv, |
281 | struct v4l2_capability *v) | 283 | struct v4l2_capability *v) |
282 | { | 284 | { |
283 | struct amradio_device *radio = video_drvdata(file); | 285 | struct amradio_device *radio = file->private_data; |
284 | 286 | ||
285 | strlcpy(v->driver, "radio-mr800", sizeof(v->driver)); | 287 | strlcpy(v->driver, "radio-mr800", sizeof(v->driver)); |
286 | strlcpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); | 288 | strlcpy(v->card, "AverMedia MR 800 USB FM Radio", sizeof(v->card)); |
@@ -294,7 +296,7 @@ static int vidioc_querycap(struct file *file, void *priv, | |||
294 | static int vidioc_g_tuner(struct file *file, void *priv, | 296 | static int vidioc_g_tuner(struct file *file, void *priv, |
295 | struct v4l2_tuner *v) | 297 | struct v4l2_tuner *v) |
296 | { | 298 | { |
297 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 299 | struct amradio_device *radio = file->private_data; |
298 | int retval; | 300 | int retval; |
299 | 301 | ||
300 | mutex_lock(&radio->lock); | 302 | mutex_lock(&radio->lock); |
@@ -345,7 +347,7 @@ unlock: | |||
345 | static int vidioc_s_tuner(struct file *file, void *priv, | 347 | static int vidioc_s_tuner(struct file *file, void *priv, |
346 | struct v4l2_tuner *v) | 348 | struct v4l2_tuner *v) |
347 | { | 349 | { |
348 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 350 | struct amradio_device *radio = file->private_data; |
349 | int retval; | 351 | int retval; |
350 | 352 | ||
351 | mutex_lock(&radio->lock); | 353 | mutex_lock(&radio->lock); |
@@ -388,7 +390,7 @@ unlock: | |||
388 | static int vidioc_s_frequency(struct file *file, void *priv, | 390 | static int vidioc_s_frequency(struct file *file, void *priv, |
389 | struct v4l2_frequency *f) | 391 | struct v4l2_frequency *f) |
390 | { | 392 | { |
391 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 393 | struct amradio_device *radio = file->private_data; |
392 | int retval; | 394 | int retval; |
393 | 395 | ||
394 | mutex_lock(&radio->lock); | 396 | mutex_lock(&radio->lock); |
@@ -415,7 +417,7 @@ unlock: | |||
415 | static int vidioc_g_frequency(struct file *file, void *priv, | 417 | static int vidioc_g_frequency(struct file *file, void *priv, |
416 | struct v4l2_frequency *f) | 418 | struct v4l2_frequency *f) |
417 | { | 419 | { |
418 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 420 | struct amradio_device *radio = file->private_data; |
419 | int retval = 0; | 421 | int retval = 0; |
420 | 422 | ||
421 | mutex_lock(&radio->lock); | 423 | mutex_lock(&radio->lock); |
@@ -450,7 +452,7 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
450 | static int vidioc_g_ctrl(struct file *file, void *priv, | 452 | static int vidioc_g_ctrl(struct file *file, void *priv, |
451 | struct v4l2_control *ctrl) | 453 | struct v4l2_control *ctrl) |
452 | { | 454 | { |
453 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 455 | struct amradio_device *radio = file->private_data; |
454 | int retval = -EINVAL; | 456 | int retval = -EINVAL; |
455 | 457 | ||
456 | mutex_lock(&radio->lock); | 458 | mutex_lock(&radio->lock); |
@@ -477,7 +479,7 @@ unlock: | |||
477 | static int vidioc_s_ctrl(struct file *file, void *priv, | 479 | static int vidioc_s_ctrl(struct file *file, void *priv, |
478 | struct v4l2_control *ctrl) | 480 | struct v4l2_control *ctrl) |
479 | { | 481 | { |
480 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 482 | struct amradio_device *radio = file->private_data; |
481 | int retval = -EINVAL; | 483 | int retval = -EINVAL; |
482 | 484 | ||
483 | mutex_lock(&radio->lock); | 485 | mutex_lock(&radio->lock); |
@@ -550,7 +552,7 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i) | |||
550 | /* open device - amradio_start() and amradio_setfreq() */ | 552 | /* open device - amradio_start() and amradio_setfreq() */ |
551 | static int usb_amradio_open(struct file *file) | 553 | static int usb_amradio_open(struct file *file) |
552 | { | 554 | { |
553 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 555 | struct amradio_device *radio = vdev_to_amradio(video_devdata(file)); |
554 | int retval = 0; | 556 | int retval = 0; |
555 | 557 | ||
556 | mutex_lock(&radio->lock); | 558 | mutex_lock(&radio->lock); |
@@ -560,6 +562,7 @@ static int usb_amradio_open(struct file *file) | |||
560 | goto unlock; | 562 | goto unlock; |
561 | } | 563 | } |
562 | 564 | ||
565 | file->private_data = radio; | ||
563 | radio->users = 1; | 566 | radio->users = 1; |
564 | radio->muted = 1; | 567 | radio->muted = 1; |
565 | 568 | ||
@@ -589,7 +592,7 @@ unlock: | |||
589 | /*close device */ | 592 | /*close device */ |
590 | static int usb_amradio_close(struct file *file) | 593 | static int usb_amradio_close(struct file *file) |
591 | { | 594 | { |
592 | struct amradio_device *radio = video_get_drvdata(video_devdata(file)); | 595 | struct amradio_device *radio = file->private_data; |
593 | int retval = 0; | 596 | int retval = 0; |
594 | 597 | ||
595 | mutex_lock(&radio->lock); | 598 | mutex_lock(&radio->lock); |
@@ -674,7 +677,7 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { | |||
674 | 677 | ||
675 | static void usb_amradio_video_device_release(struct video_device *videodev) | 678 | static void usb_amradio_video_device_release(struct video_device *videodev) |
676 | { | 679 | { |
677 | struct amradio_device *radio = video_get_drvdata(videodev); | 680 | struct amradio_device *radio = vdev_to_amradio(videodev); |
678 | 681 | ||
679 | v4l2_device_unregister(&radio->v4l2_dev); | 682 | v4l2_device_unregister(&radio->v4l2_dev); |
680 | 683 | ||