[media] meye: embed video_device
authorHans Verkuil <hans.verkuil@cisco.com>
Mon, 9 Mar 2015 16:34:01 +0000 (13:34 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 3 Apr 2015 02:35:01 +0000 (23:35 -0300)
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>
drivers/media/pci/meye/meye.c
drivers/media/pci/meye/meye.h

index 9d9f90cb774050df5e228861bf250be66ae83583..ba887e8e1b171110f2bac5716fc8a24f38f69230 100644 (file)
@@ -1546,7 +1546,7 @@ static struct video_device meye_template = {
        .name           = "meye",
        .fops           = &meye_fops,
        .ioctl_ops      = &meye_ioctl_ops,
-       .release        = video_device_release,
+       .release        = video_device_release_empty,
 };
 
 static const struct v4l2_ctrl_ops meye_ctrl_ops = {
@@ -1623,7 +1623,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 
        if (meye.mchip_dev != NULL) {
                printk(KERN_ERR "meye: only one device allowed!\n");
-               goto outnotdev;
+               return ret;
        }
 
        ret = v4l2_device_register(&pcidev->dev, v4l2_dev);
@@ -1633,11 +1633,6 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
        }
        ret = -ENOMEM;
        meye.mchip_dev = pcidev;
-       meye.vdev = video_device_alloc();
-       if (!meye.vdev) {
-               v4l2_err(v4l2_dev, "video_device_alloc() failed!\n");
-               goto outnotdev;
-       }
 
        meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
        if (!meye.grab_temp) {
@@ -1658,8 +1653,8 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
                goto outkfifoalloc2;
        }
 
-       memcpy(meye.vdev, &meye_template, sizeof(meye_template));
-       meye.vdev->v4l2_dev = &meye.v4l2_dev;
+       meye.vdev = meye_template;
+       meye.vdev.v4l2_dev = &meye.v4l2_dev;
 
        ret = -EIO;
        if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
@@ -1743,9 +1738,9 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
        }
 
        v4l2_ctrl_handler_setup(&meye.hdl);
-       meye.vdev->ctrl_handler = &meye.hdl;
+       meye.vdev.ctrl_handler = &meye.hdl;
 
-       if (video_register_device(meye.vdev, VFL_TYPE_GRABBER,
+       if (video_register_device(&meye.vdev, VFL_TYPE_GRABBER,
                                  video_nr) < 0) {
                v4l2_err(v4l2_dev, "video_register_device failed\n");
                goto outvideoreg;
@@ -1777,14 +1772,12 @@ outkfifoalloc2:
 outkfifoalloc1:
        vfree(meye.grab_temp);
 outvmalloc:
-       video_device_release(meye.vdev);
-outnotdev:
        return ret;
 }
 
 static void meye_remove(struct pci_dev *pcidev)
 {
-       video_unregister_device(meye.vdev);
+       video_unregister_device(&meye.vdev);
 
        mchip_hic_stop();
 
index 6fed9274cfa530ad5904b669dda6a586373bec09..751be5e533c7e12eeff2ff40a78396223b4943b6 100644 (file)
@@ -311,7 +311,7 @@ struct meye {
        struct kfifo doneq;             /* queue for grabbed buffers */
        spinlock_t doneq_lock;          /* lock protecting the queue */
        wait_queue_head_t proc_list;    /* wait queue */
-       struct video_device *vdev;      /* video device parameters */
+       struct video_device vdev;       /* video device parameters */
        u16 brightness;
        u16 hue;
        u16 contrast;