[PATCH] usb: gadget: uvc: fix interval_duration calculation

Junzhong Pan posted 1 patch 1 month ago
drivers/usb/gadget/function/uvc_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] usb: gadget: uvc: fix interval_duration calculation
Posted by Junzhong Pan 1 month ago
To correctly convert bInterval as interval_duration:
  interval_duration = 2^(bInterval-1) * frame_interval

Current code uses a wrong left shift operand, computing 2^bInterval
instead of 2^(bInterval-1).

Fixes: 010dc57cb516 ("usb: gadget: uvc: fix interval_duration calculation")
Cc: stable@vger.kernel.org
Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>
---
 drivers/usb/gadget/function/uvc_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 7cea641b06b4..2f9700b3f1b6 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -513,7 +513,7 @@ uvc_video_prep_requests(struct uvc_video *video)
 		return;
 	}
 
-	interval_duration = 2 << (video->ep->desc->bInterval - 1);
+	interval_duration = 1 << (video->ep->desc->bInterval - 1);
 	if (cdev->gadget->speed < USB_SPEED_HIGH)
 		interval_duration *= 10000;
 	else

---
base-commit: 5ee8dbf54602dc340d6235b1d6aa17c0f283f48c
change-id: 20260306-fix-uvc-interval-0dc36dbde48e

Best regards,
-- 
Junzhong Pan <panjunzhong@linux.spacemit.com>
Re: [PATCH] usb: gadget: uvc: fix interval_duration calculation
Posted by Xu Yang 1 month ago
On Fri, Mar 06, 2026 at 11:30:09AM +0800, Junzhong Pan wrote:
> To correctly convert bInterval as interval_duration:
>   interval_duration = 2^(bInterval-1) * frame_interval
> 
> Current code uses a wrong left shift operand, computing 2^bInterval
> instead of 2^(bInterval-1).
> 
> Fixes: 010dc57cb516 ("usb: gadget: uvc: fix interval_duration calculation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Junzhong Pan <panjunzhong@linux.spacemit.com>

Reviewed-by: Xu Yang <xu.yang_2@nxp.com>

Thanks,
Xu Yang

> ---
>  drivers/usb/gadget/function/uvc_video.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
> index 7cea641b06b4..2f9700b3f1b6 100644
> --- a/drivers/usb/gadget/function/uvc_video.c
> +++ b/drivers/usb/gadget/function/uvc_video.c
> @@ -513,7 +513,7 @@ uvc_video_prep_requests(struct uvc_video *video)
>  		return;
>  	}
>  
> -	interval_duration = 2 << (video->ep->desc->bInterval - 1);
> +	interval_duration = 1 << (video->ep->desc->bInterval - 1);
>  	if (cdev->gadget->speed < USB_SPEED_HIGH)
>  		interval_duration *= 10000;
>  	else
> 
> ---
> base-commit: 5ee8dbf54602dc340d6235b1d6aa17c0f283f48c
> change-id: 20260306-fix-uvc-interval-0dc36dbde48e
> 
> Best regards,
> -- 
> Junzhong Pan <panjunzhong@linux.spacemit.com>
>