summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-06-04 20:46:49 +0700
committerhathach <[email protected]>2026-06-04 20:46:49 +0700
commita900ea93db686cacde5e595dc09fdfeaa334d556 (patch)
tree056aeccd4c5cd55f506181222b530136d3cf70ab
parentb5e080732e67a52afefa6966ca33474c91a53d0c (diff)
dwc2: cleanup setup_packet pointer cast (review feedback)
Cast DOEPDMA0 through uintptr_t and use sizeof(tusb_control_request_t) instead of the magic constant 8, matching project convention. Add a reference to Programming Guide v4.20a 9.1.2.1 for the DOEPDMAn-8 rule. Addresses Copilot review comment; no functional change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index ee52ef1e7..e1a2f6cf2 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -1031,7 +1031,9 @@ static void handle_epout_dma(uint8_t rhport, uint8_t epnum, dwc2_doepint_t doepi
dcd_dcache_invalidate(_dcd_usbbuf.setup_buffer, sizeof(_dcd_usbbuf.setup_buffer));
- tusb_control_request_t *setup_packet = (tusb_control_request_t *) (epout0->doepdma - 8);
+ // DOEPDMA0 has advanced past the last received SETUP packet; back up one packet to the latest valid one
+ // (Programming Guide v4.20a section 9.1.2.1: "DOEPDMAn-8 provides the pointer to the last valid SETUP data")
+ tusb_control_request_t *setup_packet = (tusb_control_request_t *) (uintptr_t) (epout0->doepdma - sizeof(tusb_control_request_t));
dcd_event_setup_received(rhport, (uint8_t*)setup_packet, true);
// Prepare EP0 for next setup if this setup has no data stage