summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFan Ye <fy15309206903@gmail.com>2026-08-10 09:38:43 +0000
committerMika Westerberg <mika.westerberg@linux.intel.com>2026-08-10 13:29:23 +0200
commite8158c8a6a232a70ae70c5acfaf7008a99b716c1 (patch)
treebe79d5ebd8df794c2ff1f05a54daddb52788f248
parentf7c0e02eb61284395f74424edaefbbd323f83c4e (diff)
downloadlinux-stable-e8158c8a6a232a70ae70c5acfaf7008a99b716c1.tar.gz
linux-stable-e8158c8a6a232a70ae70c5acfaf7008a99b716c1.zip
thunderbolt: Use min() for the DMA path credit cap
tb_dma_reserve_credits() caps the request against what the adapter has left by decrementing one credit at a time. The other arm of the same if() already caps with min(port->total_credits, credits); use min() here too. No functional change: the object code is unchanged. Assisted-by: Claude:claude-opus-5 Signed-off-by: Fan Ye <fy15309206903@gmail.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-rw-r--r--drivers/thunderbolt/tunnel.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index b7f32305f14a..e9214de5f3b7 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -1778,8 +1778,7 @@ static int tb_dma_reserve_credits(struct tb_path_hop *hop, unsigned int credits)
if (available < TB_MIN_DMA_CREDITS)
return -ENOSPC;
- while (credits > available)
- credits--;
+ credits = min(credits, available);
tb_port_dbg(port, "reserving %u credits for DMA path\n",
credits);