From 7e70f0b07cd3b52eecdfdd51d0360772f5ba7131 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 06:34:21 +0000 Subject: [PATCH] Fix MTP transfer completion detection for exact-length packets Change condition from `>` to `>=` to properly detect completion when xferred_len equals total_len. This fixes the bug where transfers of exactly bulk_mps length (e.g., 64 bytes for low speed) would never complete, such as GetHandles responses with 12 elements. Co-authored-by: hathach <249515+hathach@users.noreply.github.com> --- src/class/mtp/mtp_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/class/mtp/mtp_device.c b/src/class/mtp/mtp_device.c index 764019e42..4942a105a 100644 --- a/src/class/mtp/mtp_device.c +++ b/src/class/mtp/mtp_device.c @@ -422,10 +422,10 @@ bool mtpd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t cb_data.total_xferred_bytes = p_mtp->xferred_len; bool is_complete = false; - // complete if ZLP or short packet or overflow + // complete if ZLP or short packet or total length reached if (xferred_bytes == 0 || // ZLP (xferred_bytes & (bulk_mps - 1)) || // short packet - p_mtp->xferred_len > p_mtp->total_len) { + p_mtp->xferred_len >= p_mtp->total_len) { // total length reached is_complete = true; }