From: Hans Verkuil Date: Mon, 9 Mar 2015 16:34:07 +0000 (-0300) Subject: [media] wl128x: embed video_device X-Git-Tag: firefly_0821_release~176^2~795^2~1098 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cab9bf11f8ef433151a15b9519e3e0a56302c9a4;p=firefly-linux-kernel-4.4.55.git [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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index a5bd3f674bbd..fb42f0fd0c1f 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c @@ -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);