10000 move all vdev init procedures into init_vdev · v4l2loopback/v4l2loopback@e6e1598 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6e1598

Browse files
committed
move all vdev init procedures into init_vdev
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
1 parent e11e83a commit e6e1598

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

v4l2loopback.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,9 +2065,12 @@ static int allocate_timeout_image(struct v4l2_loopback_device *dev)
20652065
}
20662066

20672067
/* fills and register video device */
2068-
static void init_vdev(struct video_device *vdev)
2068+
static int init_vdev(struct video_device *vdev, int nr,
2069+
struct v4l2_loopback_device *dev)
20692070
{
2070-
MARK();
2071+
snprintf(vdev->name, sizeof(vdev->name), dev->card_label);
2072+
vdev->v4l2_dev = &dev->v4l2_dev;
2073+
video_set_drvdata(vdev, dev);
20712074

20722075
#ifdef V4L2LOOPBACK_WITH_STD
20732076
vdev->tvnorms = V4L2_STD_ALL;
@@ -2090,6 +2093,17 @@ static void init_vdev(struct video_device *vdev)
20902093
vdev->vfl_dir = VFL_DIR_M2M;
20912094

20922095
MARK();
2096+
2097+
/* register the device -> it creates /dev/video* */
2098+
if (video_register_device(vdev, VFL_TYPE_VIDEO, nr) < 0) {
2099+
printk(KERN_ERR
2100+
"v4l2loopback: failed video_register_device()\n");
2101+
return -EFAULT;
2102+
}
2103+
2104+
v4l2loopback_create_sysfs(vdev);
2105+
2106+
return 0;
20932107
}
20942108

20952109
/* init default capture parameters, only fps may be changed in future */
@@ -2225,12 +2239,6 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
22252239
goto out_free_idr;
22262240
MARK();
22272241

2228-
vdev = &dev->capture.vdev;
2229-
video_set_drvdata(vdev, dev);
2230-
snprintf(vdev->name, sizeof(vdev->name), dev->card_label);
2231-
2232-
init_vdev(vdev);
2233-
vdev->v4l2_dev = &dev->v4l2_dev;
22342242
init_capture_param(&dev->capture_param);
22352243
set_timeperframe(dev, &dev->capture_param.timeperframe);
22362244
dev->keep_format = 0;
@@ -2276,7 +2284,7 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
22762284
hdl = &dev->ctrl_handler;
22772285
err = v4l2_ctrl_handler_init(hdl, 4);
22782286
if (err)
2279-
goto out_free_device;
2287+
goto out_free_idr;
22802288
v4l2_ctrl_new_custom(hdl, &v4l2loopback_ctrl_keepformat, NULL);
22812289
v4l2_ctrl_new_custom(hdl, &v4l2loopback_ctrl_sustainframerate, NULL);
22822290
v4l2_ctrl_new_custom(hdl, &v4l2loopback_ctrl_timeout, NULL);
@@ -2306,14 +2314,11 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
23062314

23072315
init_waitqueue_head(&dev->read_event);
23082316

2309-
/* register the device -> it creates /dev/video* */
2310-
if (video_register_device(vdev, VFL_TYPE_VIDEO, capture_nr) < 0) {
2311-
printk(KERN_ERR
2312-
"v4l2loopback: failed video_register_device()\n");
2313-
err = -EFAULT;
2317+
MARK();
2318+
2319+
vdev = &dev->capture.vdev;
2320+
if (init_vdev(vdev, capture_nr, dev))
23142321
goto out_free_handler;
2315-
}
2316-
v4l2loopback_create_sysfs(vdev);
23172322

23182323
MARK();
23192324
if (ret_nr)
@@ -2322,9 +2327,6 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
23222327

23232328
out_free_handler:
23242329
v4l2_ctrl_handler_free(&dev->ctrl_handler);
2325-
out_free_device:
2326-
video_device_release_empty(vdev);
2327-
v4l2_device_unregister(&dev->v4l2_dev);
23282330
out_free_idr:
23292331
idr_remove(&v4l2loopback_index_idr, output_nr);
23302332
idr_remove(&v4l2loopback_index_idr, capture_nr);

0 commit comments

Comments
 (0)
0