Commit a2bdc5e6 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB: radio-am800: let v4l2_device_(un)register handle usb_get/set_intfdata

v4l2_device_register already sets the usb intfdata to v4l2_dev. So use
that instead.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent dd0daf2a
...@@ -144,7 +144,10 @@ struct amradio_device { ...@@ -144,7 +144,10 @@ struct amradio_device {
int initialized; int initialized;
}; };
#define vdev_to_amradio(r) container_of(r, struct amradio_device, videodev) static inline struct amradio_device *to_amradio_dev(struct v4l2_device *v4l2_dev)
{
return container_of(v4l2_dev, struct amradio_device, v4l2_dev);
}
/* USB Device ID List */ /* USB Device ID List */
static struct usb_device_id usb_amradio_device_table[] = { static struct usb_device_id usb_amradio_device_table[] = {
...@@ -284,13 +287,12 @@ static int amradio_set_stereo(struct amradio_device *radio, char argument) ...@@ -284,13 +287,12 @@ static int amradio_set_stereo(struct amradio_device *radio, char argument)
*/ */
static void usb_amradio_disconnect(struct usb_interface *intf) static void usb_amradio_disconnect(struct usb_interface *intf)
{ {
struct amradio_device *radio = usb_get_intfdata(intf); struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
mutex_lock(&radio->lock); mutex_lock(&radio->lock);
radio->usbdev = NULL; radio->usbdev = NULL;
mutex_unlock(&radio->lock); mutex_unlock(&radio->lock);
usb_set_intfdata(intf, NULL);
v4l2_device_disconnect(&radio->v4l2_dev); v4l2_device_disconnect(&radio->v4l2_dev);
video_unregister_device(&radio->videodev); video_unregister_device(&radio->videodev);
} }
...@@ -500,7 +502,7 @@ static int usb_amradio_init(struct amradio_device *radio) ...@@ -500,7 +502,7 @@ static int usb_amradio_init(struct amradio_device *radio)
/* open device - amradio_start() and amradio_setfreq() */ /* open device - amradio_start() and amradio_setfreq() */
static int usb_amradio_open(struct file *file) static int usb_amradio_open(struct file *file)
{ {
struct amradio_device *radio = vdev_to_amradio(video_devdata(file)); struct amradio_device *radio = video_drvdata(file);
int retval = 0; int retval = 0;
mutex_lock(&radio->lock); mutex_lock(&radio->lock);
...@@ -566,7 +568,7 @@ static long usb_amradio_ioctl(struct file *file, unsigned int cmd, ...@@ -566,7 +568,7 @@ static long usb_amradio_ioctl(struct file *file, unsigned int cmd,
/* Suspend device - stop device. Need to be checked and fixed */ /* Suspend device - stop device. Need to be checked and fixed */
static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message) static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message)
{ {
struct amradio_device *radio = usb_get_intfdata(intf); struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
mutex_lock(&radio->lock); mutex_lock(&radio->lock);
...@@ -584,7 +586,7 @@ static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -584,7 +586,7 @@ static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message)
/* Resume device - start device. Need to be checked and fixed */ /* Resume device - start device. Need to be checked and fixed */
static int usb_amradio_resume(struct usb_interface *intf) static int usb_amradio_resume(struct usb_interface *intf)
{ {
struct amradio_device *radio = usb_get_intfdata(intf); struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
mutex_lock(&radio->lock); mutex_lock(&radio->lock);
...@@ -633,9 +635,7 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { ...@@ -633,9 +635,7 @@ static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = {
static void usb_amradio_video_device_release(struct video_device *videodev) static void usb_amradio_video_device_release(struct video_device *videodev)
{ {
struct amradio_device *radio = vdev_to_amradio(videodev); struct amradio_device *radio = video_get_drvdata(videodev);
v4l2_device_unregister(&radio->v4l2_dev);
/* free rest memory */ /* free rest memory */
kfree(radio->buffer); kfree(radio->buffer);
...@@ -693,7 +693,6 @@ static int usb_amradio_probe(struct usb_interface *intf, ...@@ -693,7 +693,6 @@ static int usb_amradio_probe(struct usb_interface *intf,
goto err_vdev; goto err_vdev;
} }
usb_set_intfdata(intf, radio);
return 0; return 0;
err_vdev: err_vdev:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment