Commit 1f4e7241 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: imx: capture: Register the video device after completing init

When the video device is registered, it can get used by userspace
immediately. Its initialization must thus be fully complete. Ensure this
by registering the video device after all initialization steps.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 8e574216
......@@ -723,27 +723,13 @@ int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
vfd->v4l2_dev = v4l2_dev;
ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1);
if (ret) {
dev_err(priv->dev, "Failed to register video device\n");
return ret;
}
/* create the link from the src_sd devnode pad to device node */
ret = media_create_pad_link(&sd->entity, priv->src_sd_pad,
&vfd->entity, 0, 0);
if (ret) {
dev_err(priv->dev, "failed to create link to device node\n");
goto unreg;
}
/* setup default format */
fmt_src.pad = priv->src_sd_pad;
fmt_src.which = V4L2_SUBDEV_FORMAT_ACTIVE;
ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &fmt_src);
if (ret) {
dev_err(priv->dev, "failed to get src_sd format\n");
goto unreg;
return ret;
}
vdev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
......@@ -754,16 +740,29 @@ int imx_media_capture_device_register(struct imx_media_video_dev *vdev)
vdev->cc = imx_media_find_pixel_format(vdev->fmt.fmt.pix.pixelformat,
PIXFMT_SEL_ANY);
/* Register the video device. */
ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1);
if (ret) {
dev_err(priv->dev, "Failed to register video device\n");
return ret;
}
dev_info(priv->dev, "Registered %s as /dev/%s\n", vfd->name,
video_device_node_name(vfd));
/* add vdev to the video device list */
/* Create the link from the src_sd devnode pad to device node. */
ret = media_create_pad_link(&sd->entity, priv->src_sd_pad,
&vfd->entity, 0, 0);
if (ret) {
dev_err(priv->dev, "failed to create link to device node\n");
video_unregister_device(vfd);
return ret;
}
/* Add vdev to the video devices list. */
imx_media_add_video_device(priv->md, vdev);
return 0;
unreg:
video_unregister_device(vfd);
return ret;
}
EXPORT_SYMBOL_GPL(imx_media_capture_device_register);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment