[media] wl128x: embed video_device

Embed the video_device struct to simplify the error handling and in
order to (eventually) get rid of video_device_alloc/release.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
Hans Verkuil 2015-03-09 13:34:07 -03:00 committed by Mauro Carvalho Chehab
parent 650e629bf7
commit cab9bf11f8

View file

@ -36,7 +36,7 @@
#include "fmdrv_rx.h"
#include "fmdrv_tx.h"
static struct video_device *gradio_dev;
static struct video_device gradio_dev;
static u8 radio_disconnected;
/* -- V4L2 RADIO (/dev/radioX) device file operation interfaces --- */
@ -517,7 +517,7 @@ static struct video_device fm_viddev_template = {
.fops = &fm_drv_fops,
.ioctl_ops = &fm_drv_ioctl_ops,
.name = FM_DRV_NAME,
.release = video_device_release,
.release = video_device_release_empty,
/*
* To ensure both the tuner and modulator ioctls are accessible we
* set the vfl_dir to M2M to indicate this.
@ -543,29 +543,21 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr)
/* Init mutex for core locking */
mutex_init(&fmdev->mutex);
/* Allocate new video device */
gradio_dev = video_device_alloc();
if (NULL == gradio_dev) {
fmerr("Can't allocate video device\n");
return -ENOMEM;
}
/* Setup FM driver's V4L2 properties */
memcpy(gradio_dev, &fm_viddev_template, sizeof(fm_viddev_template));
gradio_dev = fm_viddev_template;
video_set_drvdata(gradio_dev, fmdev);
video_set_drvdata(&gradio_dev, fmdev);
gradio_dev->lock = &fmdev->mutex;
gradio_dev->v4l2_dev = &fmdev->v4l2_dev;
gradio_dev.lock = &fmdev->mutex;
gradio_dev.v4l2_dev = &fmdev->v4l2_dev;
/* Register with V4L2 subsystem as RADIO device */
if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
video_device_release(gradio_dev);
if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) {
fmerr("Could not register video device\n");
return -ENOMEM;
}
fmdev->radio_dev = gradio_dev;
fmdev->radio_dev = &gradio_dev;
/* Register to v4l2 ctrl handler framework */
fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;
@ -611,13 +603,13 @@ void *fm_v4l2_deinit_video_device(void)
struct fmdev *fmdev;
fmdev = video_get_drvdata(gradio_dev);
fmdev = video_get_drvdata(&gradio_dev);
/* Unregister to v4l2 ctrl handler framework*/
v4l2_ctrl_handler_free(&fmdev->ctrl_handler);
/* Unregister RADIO device from V4L2 subsystem */
video_unregister_device(gradio_dev);
video_unregister_device(&gradio_dev);
v4l2_device_unregister(&fmdev->v4l2_dev);