[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260122014952.GC183118@killaraus>
Date: Thu, 22 Jan 2026 03:49:52 +0200
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Ricardo Ribalda <ribalda@...omium.org>
Cc: Hans de Goede <hansg@...nel.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Johannes Berg <johannes@...solutions.net>,
Laurent Pinchart <laurent.pinchart@...net.be>,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] media: uvcvideo: use min() for npacket calculation
Hi Ricardo,
Thank you for the patch.
On Wed, Jan 14, 2026 at 10:32:15AM +0000, Ricardo Ribalda wrote:
> Make the code slightly more appealing by making use of min(). There
> shall not be any functional change from this patch.
>
> Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
> ---
> drivers/media/usb/uvc/uvc_video.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 59eb95a4b70c05b1a12986e908b7e9979b064fd0..db02080f15772e0bc1d5cfcadd32463f4e6ea045 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -1808,9 +1808,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream,
> * Compute the number of packets. Bulk endpoints might transfer UVC
> * payloads across multiple URBs.
> */
> - npackets = DIV_ROUND_UP(size, psize);
> - if (npackets > UVC_MAX_PACKETS)
> - npackets = UVC_MAX_PACKETS;
> + npackets = min(UVC_MAX_PACKETS, DIV_ROUND_UP(size, psize));
Do you think this improves readability ? I find the existing code easier
to read, its purpose is immediately clear: it computes npackets and
clamps it to a max value. With min() I have to pause and think.
I'll take patches 1/3 and 2/3 in my tree already as 1/3 fixes an issue.
>
> /* Retry allocations until one succeed. */
> for (; npackets > 0; npackets /= 2) {
--
Regards,
Laurent Pinchart
Powered by blists - more mailing lists