]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
media: vim2m: initialize the media device earlier
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 2 Feb 2021 14:49:23 +0000 (15:49 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 22 Mar 2021 09:14:23 +0000 (10:14 +0100)
Before the video device node is registered, the v4l2_dev.mdev
pointer must be set in order to correctly associate the video
device with the media device. Move the initialization of the
media device up.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/test-drivers/vim2m.c

index 331a9053a0ed7ee0ce2062bbef7d22cda656dd94..a24624353f9ed9d388dbcd291dce209f46d1fe0e 100644 (file)
@@ -1339,12 +1339,6 @@ static int vim2m_probe(struct platform_device *pdev)
                goto error_dev;
        }
 
-       ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
-       if (ret) {
-               v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
-               goto error_m2m;
-       }
-
 #ifdef CONFIG_MEDIA_CONTROLLER
        dev->mdev.dev = &pdev->dev;
        strscpy(dev->mdev.model, "vim2m", sizeof(dev->mdev.model));
@@ -1353,7 +1347,15 @@ static int vim2m_probe(struct platform_device *pdev)
        media_device_init(&dev->mdev);
        dev->mdev.ops = &m2m_media_ops;
        dev->v4l2_dev.mdev = &dev->mdev;
+#endif
 
+       ret = video_register_device(vfd, VFL_TYPE_VIDEO, 0);
+       if (ret) {
+               v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
+               goto error_m2m;
+       }
+
+#ifdef CONFIG_MEDIA_CONTROLLER
        ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd,
                                                 MEDIA_ENT_F_PROC_VIDEO_SCALER);
        if (ret) {