@@ -329,14 +329,12 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream,
329329 * developers test their webcams with the Linux driver as well as with
330330 * the Windows driver).
331331 */
332- mutex_lock (& stream -> mutex );
333332 if (stream -> dev -> quirks & UVC_QUIRK_PROBE_EXTRAFIELDS )
334333 probe -> dwMaxVideoFrameSize =
335334 stream -> ctrl .dwMaxVideoFrameSize ;
336335
337336 /* Probe the device. */
338337 ret = uvc_probe_video (stream , probe );
339- mutex_unlock (& stream -> mutex );
340338 if (ret < 0 )
341339 return ret ;
342340
@@ -395,19 +393,15 @@ static int uvc_ioctl_g_fmt(struct file *file, void *priv,
395393 struct uvc_streaming * stream = handle -> stream ;
396394 const struct uvc_format * format ;
397395 const struct uvc_frame * frame ;
398- int ret = 0 ;
399396
400397 if (fmt -> type != stream -> type )
401398 return - EINVAL ;
402399
403- mutex_lock (& stream -> mutex );
404400 format = stream -> cur_format ;
405401 frame = stream -> cur_frame ;
406402
407- if (format == NULL || frame == NULL ) {
408- ret = - EINVAL ;
409- goto done ;
410- }
403+ if (!format || !frame )
404+ return - EINVAL ;
411405
412406 fmt -> fmt .pix .pixelformat = format -> fcc ;
413407 fmt -> fmt .pix .width = frame -> wWidth ;
@@ -419,9 +413,7 @@ static int uvc_ioctl_g_fmt(struct file *file, void *priv,
419413 fmt -> fmt .pix .xfer_func = format -> xfer_func ;
420414 fmt -> fmt .pix .ycbcr_enc = format -> ycbcr_enc ;
421415
422- done :
423- mutex_unlock (& stream -> mutex );
424- return ret ;
416+ return 0 ;
425417}
426418
427419static int uvc_ioctl_s_fmt (struct file * file , void * priv ,
@@ -441,19 +433,14 @@ static int uvc_ioctl_s_fmt(struct file *file, void *priv,
441433 if (ret < 0 )
442434 return ret ;
443435
444- mutex_lock (& stream -> mutex );
445- if (vb2_is_busy (& stream -> queue .queue )) {
446- ret = - EBUSY ;
447- goto done ;
448- }
436+ if (vb2_is_busy (& stream -> queue .queue ))
437+ return - EBUSY ;
449438
450439 stream -> ctrl = probe ;
451440 stream -> cur_format = format ;
452441 stream -> cur_frame = frame ;
453442
454- done :
455- mutex_unlock (& stream -> mutex );
456- return ret ;
443+ return 0 ;
457444}
458445
459446static int uvc_ioctl_g_parm (struct file * file , void * priv ,
@@ -466,10 +453,7 @@ static int uvc_ioctl_g_parm(struct file *file, void *priv,
466453 if (parm -> type != stream -> type )
467454 return - EINVAL ;
468455
469- mutex_lock (& stream -> mutex );
470456 numerator = stream -> ctrl .dwFrameInterval ;
471- mutex_unlock (& stream -> mutex );
472-
473457 denominator = 10000000 ;
474458 v4l2_simplify_fraction (& numerator , & denominator , 8 , 333 );
475459
@@ -519,12 +503,8 @@ static int uvc_ioctl_s_parm(struct file *file, void *priv,
519503 uvc_dbg (stream -> dev , FORMAT , "Setting frame interval to %u/%u (%u)\n" ,
520504 timeperframe .numerator , timeperframe .denominator , interval );
521505
522- mutex_lock (& stream -> mutex );
523-
524- if (uvc_queue_streaming (& stream -> queue )) {
525- mutex_unlock (& stream -> mutex );
506+ if (uvc_queue_streaming (& stream -> queue ))
526507 return - EBUSY ;
527- }
528508
529509 format = stream -> cur_format ;
530510 frame = stream -> cur_frame ;
@@ -556,14 +536,11 @@ static int uvc_ioctl_s_parm(struct file *file, void *priv,
556536
557537 /* Probe the device with the new settings. */
558538 ret = uvc_probe_video (stream , & probe );
559- if (ret < 0 ) {
560- mutex_unlock (& stream -> mutex );
539+ if (ret < 0 )
561540 return ret ;
562- }
563541
564542 stream -> ctrl = probe ;
565543 stream -> cur_frame = frame ;
566- mutex_unlock (& stream -> mutex );
567544
568545 /* Return the actual frame period. */
569546 timeperframe .numerator = probe .dwFrameInterval ;
@@ -940,10 +917,8 @@ static int uvc_ioctl_g_selection(struct file *file, void *priv,
940917
941918 sel -> r .left = 0 ;
942919 sel -> r .top = 0 ;
943- mutex_lock (& stream -> mutex );
944920 sel -> r .width = stream -> cur_frame -> wWidth ;
945921 sel -> r .height = stream -> cur_frame -> wHeight ;
946- mutex_unlock (& stream -> mutex );
947922
948923 return 0 ;
949924}
0 commit comments