[media] go7007: embed struct video_device
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 11 Mar 2013 09:34:22 +0000 (06:34 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Mar 2013 15:51:35 +0000 (12:51 -0300)
Do not allocate it, but just embed in the go7007 struct.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/media/go7007/go7007-driver.c
drivers/staging/media/go7007/go7007-priv.h
drivers/staging/media/go7007/go7007-usb.c
drivers/staging/media/go7007/go7007-v4l2.c
drivers/staging/media/go7007/saa7134-go7007.c

index 075de4d3148486dcda38011983e893b2f4c5c005..0fd3f108be1290c1496ad520375512cb5a071a49 100644 (file)
@@ -639,7 +639,6 @@ struct go7007 *go7007_alloc(struct go7007_board_info *board, struct device *dev)
        mutex_init(&go->hw_lock);
        init_waitqueue_head(&go->frame_waitq);
        spin_lock_init(&go->spinlock);
-       go->video_dev = NULL;
        go->status = STATUS_INIT;
        memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter));
        go->i2c_adapter_online = 0;
index 30148eba44b493eae032ff07b65fb4263792607f..0914fa3452aecdc022cda879a4d16288f1f63c61 100644 (file)
@@ -156,7 +156,7 @@ struct go7007 {
        int tuner_type;
        int channel_number; /* for multi-channel boards like Adlink PCI-MPG24 */
        char name[64];
-       struct video_device *video_dev;
+       struct video_device vdev;
        void *boot_fw;
        unsigned boot_fw_len;
        struct v4l2_device v4l2_dev;
index c95538c735d94d99d55742aa05ef1a91fac06f05..2a1cda22118d51c0193bcde7a0d50e149f353072 100644 (file)
@@ -1324,7 +1324,7 @@ static void go7007_usb_disconnect(struct usb_interface *intf)
 
        go->status = STATUS_SHUTDOWN;
        v4l2_device_disconnect(&go->v4l2_dev);
-       video_unregister_device(go->video_dev);
+       video_unregister_device(&go->vdev);
        mutex_unlock(&go->serialize_lock);
        mutex_unlock(&go->queue_lock);
 
index d210d33a447929b4c32a7603eb1330af7baf195f..3beb7c4bef7509d9aaba7192d3fa0d0f63880c34 100644 (file)
@@ -967,11 +967,6 @@ static int vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop *
        }
 #endif
 
-static void go7007_vfl_release(struct video_device *vfd)
-{
-       video_device_release(vfd);
-}
-
 static struct v4l2_file_operations go7007_fops = {
        .owner          = THIS_MODULE,
        .open           = v4l2_fh_open,
@@ -1022,7 +1017,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 static struct video_device go7007_template = {
        .name           = "go7007",
        .fops           = &go7007_fops,
-       .release        = go7007_vfl_release,
+       .release        = video_device_release_empty,
        .ioctl_ops      = &video_ioctl_ops,
        .tvnorms        = V4L2_STD_ALL,
 };
@@ -1062,6 +1057,7 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
 
 int go7007_v4l2_init(struct go7007 *go)
 {
+       struct video_device *vdev = &go->vdev;
        int rv;
 
        mutex_init(&go->serialize_lock);
@@ -1079,22 +1075,19 @@ int go7007_v4l2_init(struct go7007 *go)
        rv = vb2_queue_init(&go->vidq);
        if (rv)
                return rv;
-       go->video_dev = video_device_alloc();
-       if (go->video_dev == NULL)
-               return -ENOMEM;
-       *go->video_dev = go7007_template;
-       go->video_dev->lock = &go->serialize_lock;
-       go->video_dev->queue = &go->vidq;
-       set_bit(V4L2_FL_USE_FH_PRIO, &go->video_dev->flags);
-       video_set_drvdata(go->video_dev, go);
-       go->video_dev->v4l2_dev = &go->v4l2_dev;
+       *vdev = go7007_template;
+       vdev->lock = &go->serialize_lock;
+       vdev->queue = &go->vidq;
+       set_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags);
+       video_set_drvdata(vdev, go);
+       vdev->v4l2_dev = &go->v4l2_dev;
        if (!v4l2_device_has_op(&go->v4l2_dev, video, querystd))
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_QUERYSTD);
+               v4l2_disable_ioctl(vdev, VIDIOC_QUERYSTD);
        if (!(go->board_info->flags & GO7007_BOARD_HAS_TUNER)) {
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_S_FREQUENCY);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_G_FREQUENCY);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_S_TUNER);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_G_TUNER);
+               v4l2_disable_ioctl(vdev, VIDIOC_S_FREQUENCY);
+               v4l2_disable_ioctl(vdev, VIDIOC_G_FREQUENCY);
+               v4l2_disable_ioctl(vdev, VIDIOC_S_TUNER);
+               v4l2_disable_ioctl(vdev, VIDIOC_G_TUNER);
        } else {
                struct v4l2_frequency f = {
                        .type = V4L2_TUNER_ANALOG_TV,
@@ -1104,16 +1097,16 @@ int go7007_v4l2_init(struct go7007 *go)
                call_all(&go->v4l2_dev, tuner, s_frequency, &f);
        }
        if (!(go->board_info->sensor_flags & GO7007_SENSOR_TV)) {
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_G_STD);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_S_STD);
-               go->video_dev->tvnorms = 0;
+               v4l2_disable_ioctl(vdev, VIDIOC_G_STD);
+               v4l2_disable_ioctl(vdev, VIDIOC_S_STD);
+               vdev->tvnorms = 0;
        }
        if (go->board_info->sensor_flags & GO7007_SENSOR_SCALING)
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_ENUM_FRAMESIZES);
+               v4l2_disable_ioctl(vdev, VIDIOC_ENUM_FRAMESIZES);
        if (go->board_info->num_aud_inputs == 0) {
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_G_AUDIO);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_S_AUDIO);
-               v4l2_disable_ioctl(go->video_dev, VIDIOC_ENUMAUDIO);
+               v4l2_disable_ioctl(vdev, VIDIOC_G_AUDIO);
+               v4l2_disable_ioctl(vdev, VIDIOC_S_AUDIO);
+               v4l2_disable_ioctl(vdev, VIDIOC_ENUMAUDIO);
        }
        /* Setup correct crystal frequency on this board */
        if (go->board_info->sensor_flags & GO7007_SENSOR_SAA7115)
@@ -1124,14 +1117,11 @@ int go7007_v4l2_init(struct go7007 *go)
        go7007_s_input(go);
        if (go->board_info->sensor_flags & GO7007_SENSOR_TV)
                go7007_s_std(go);
-       rv = video_register_device(go->video_dev, VFL_TYPE_GRABBER, -1);
-       if (rv < 0) {
-               video_device_release(go->video_dev);
-               go->video_dev = NULL;
+       rv = video_register_device(vdev, VFL_TYPE_GRABBER, -1);
+       if (rv < 0)
                return rv;
-       }
        dev_info(go->dev, "registered device %s [v4l2]\n",
-                video_device_node_name(go->video_dev));
+                video_device_node_name(vdev));
 
        return 0;
 }
index fa9de3c66dcee6762203ac357088b1b95350a82c..752f1bd6b5a1e3cd33509faef517da9c5ecc3147 100644 (file)
@@ -471,7 +471,7 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
         * V4L2 and ALSA interfaces */
        if (go7007_register_encoder(go, go->board_info->num_i2c_devs) < 0)
                goto initfail;
-       dev->empress_dev = go->video_dev;
+       dev->empress_dev = &go->vdev;
        video_set_drvdata(dev->empress_dev, go);
 
        go->status = STATUS_ONLINE;