[PATCH 3/3] media: uvcvideo: use min() for npacket calculation
From: Ricardo Ribalda
Date: Wed Jan 14 2026 - 05:32:30 EST
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@xxxxxxxxxxxx>
---
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));
/* Retry allocations until one succeed. */
for (; npackets > 0; npackets /= 2) {
--
2.52.0.457.g6b5491de43-goog