@@ -2065,9 +2065,12 @@ static int allocate_timeout_image(struct v4l2_loopback_device *dev)
2065
2065
}
2066
2066
2067
2067
/* 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 )
2069
2070
{
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 );
2071
2074
2072
2075
#ifdef V4L2LOOPBACK_WITH_STD
2073
2076
vdev -> tvnorms = V4L2_STD_ALL ;
@@ -2090,6 +2093,17 @@ static void init_vdev(struct video_device *vdev)
2090
2093
vdev -> vfl_dir = VFL_DIR_M2M ;
2091
2094
2092
2095
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 ;
2093
2107
}
2094
2108
2095
2109
/* 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)
2225
2239
goto out_free_idr ;
2226
2240
MARK ();
2227
2241
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 ;
2234
2242
init_capture_param (& dev -> capture_param );
2235
2243
set_timeperframe (dev , & dev -> capture_param .timeperframe );
2236
2244
dev -> keep_format = 0 ;
@@ -2276,7 +2284,7 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
2276
2284
hdl = & dev -> ctrl_handler ;
2277
2285
err = v4l2_ctrl_handler_init (hdl , 4 );
2278
2286
if (err )
2279
- goto out_free_device ;
2287
+ goto out_free_idr ;
2280
2288
v4l2_ctrl_new_custom (hdl , & v4l2loopback_ctrl_keepformat , NULL );
2281
2289
v4l2_ctrl_new_custom (hdl , & v4l2loopback_ctrl_sustainframerate , NULL );
2282
2290
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)
2306
2314
2307
2315
init_waitqueue_head (& dev -> read_event );
2308
2316
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 ))
2314
2321
goto out_free_handler ;
2315
- }
2316
- v4l2loopback_create_sysfs (vdev );
2317
2322
2318
2323
MARK ();
2319
2324
if (ret_nr )
@@ -2322,9 +2327,6 @@ static int v4l2_loopback_add(struct v4l2_loopback_config *conf, int *ret_nr)
2322
2327
2323
2328
out_free_handler :
2324
2329
v4l2_ctrl_handler_free (& dev -> ctrl_handler );
2325
- out_free_device :
2326
- video_device_release_empty (vdev );
2327
- v4l2_device_unregister (& dev -> v4l2_dev );
2328
2330
out_free_idr :
2329
2331
idr_remove (& v4l2loopback_index_idr , output_nr );
2330
2332
idr_remove (& v4l2loopback_index_idr , capture_nr );
0 commit comments