From: Ricardo Ribalda <ribalda@chromium.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Johannes Berg <johannes@sipsolutions.net>
Cc: Laurent Pinchart <laurent.pinchart@skynet.be>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH 3/3] media: uvcvideo: use min() for npacket calculation
Date: Wed, 14 Jan 2026 10:32:15 +0000 [thread overview]
Message-ID: <20260114-uvc-alloc-urb-v1-3-cedf3fb66711@chromium.org> (raw)
In-Reply-To: <20260114-uvc-alloc-urb-v1-0-cedf3fb66711@chromium.org>
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@chromium.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));
/* Retry allocations until one succeed. */
for (; npackets > 0; npackets /= 2) {
--
2.52.0.457.g6b5491de43-goog
next prev parent reply other threads:[~2026-01-14 10:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 10:32 [PATCH 0/3] media: uvcvideo: Fix allocation for small frame sizes Ricardo Ribalda
2026-01-14 10:32 ` [PATCH 1/3] " Ricardo Ribalda
2026-01-22 1:45 ` Laurent Pinchart
2026-01-14 10:32 ` [PATCH 2/3] media: uvcvideo: Pass allocation size directly to uvc_alloc_urb_buffer Ricardo Ribalda
2026-01-22 1:47 ` Laurent Pinchart
2026-01-14 10:32 ` Ricardo Ribalda [this message]
2026-01-22 1:49 ` [PATCH 3/3] media: uvcvideo: use min() for npacket calculation Laurent Pinchart
2026-01-22 7:49 ` Ricardo Ribalda
2026-01-14 12:17 ` [PATCH 0/3] media: uvcvideo: Fix allocation for small frame sizes Itay Chamiel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260114-uvc-alloc-urb-v1-3-cedf3fb66711@chromium.org \
--to=ribalda@chromium.org \
--cc=hansg@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=laurent.pinchart@ideasonboard.com \
--cc=laurent.pinchart@skynet.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®