Re: [PATCH] usb: gadget: uvc: use pump call conditionally

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 02, 2021 at 01:58:52AM +0100, Michael Grzeschik wrote:
> Preparing the usb request is not very expensive, when using
> scatter gather. In that case we can even remove the overhead
> of the extra pump worker and call the pump function directly.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/function/uvc_v4l2.c  |  8 +++++--
>  drivers/usb/gadget/function/uvc_video.c | 28 +++++++++++++++++++------
>  drivers/usb/gadget/function/uvc_video.h |  2 ++
>  3 files changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
> index a2c78690c5c288..020b4adc7840e0 100644
> --- a/drivers/usb/gadget/function/uvc_v4l2.c
> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
> @@ -169,8 +169,12 @@ uvc_v4l2_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
>  	if (ret < 0)
>  		return ret;
>  
> -	if (uvc->state == UVC_STATE_STREAMING)
> -		schedule_work(&video->pump);
> +	if (uvc->state == UVC_STATE_STREAMING) {
> +		if (!video->queue.use_sg)
> +			schedule_work(&video->pump);
> +		else
> +			uvcg_video_pump(video);

Wouldn't it be easier to understand this if you flip the if test around:
		if (video->queue.use_sg)
			uvcg_video_pump(video);
		else
			schedule_work(&video->pump);
?

Negagive logic is never fun to read...

Also, are you sure that sg really is not expensive on all systems?  What
did you test this on, and what was the results?

thanks,

greg k-h



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux