Skip to content

Commit b5c84aa

Browse files
author
hathach
committed
device/msc: only defer prepare_cbw() from STATUS_SENT when EP OUT stalled
1 parent 697f6b3 commit b5c84aa

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/class/msc/msc_device.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,7 @@ TU_ATTR_ALWAYS_INLINE static inline bool send_csw(mscd_interface_t* p_msc) {
121121
TU_ATTR_ALWAYS_INLINE static inline bool prepare_cbw(mscd_interface_t* p_msc) {
122122
uint8_t rhport = p_msc->rhport;
123123
p_msc->stage = MSC_STAGE_CMD;
124-
// Skip command stage until Clear Stall request if endpoint is stalled
125-
if (!usbd_edpt_stalled(rhport, p_msc->ep_out)) {
126-
return usbd_edpt_xfer(rhport, p_msc->ep_out, _mscd_epbuf.buf, sizeof(msc_cbw_t), false);
127-
} else {
128-
return true;
129-
}
124+
return usbd_edpt_xfer(rhport, p_msc->ep_out, _mscd_epbuf.buf, sizeof(msc_cbw_t), false);
130125
}
131126

132127
static void fail_scsi_op(mscd_interface_t* p_msc, uint8_t status) {
@@ -651,7 +646,11 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
651646
break;
652647
}
653648

654-
TU_ASSERT(prepare_cbw(p_msc));
649+
if (!usbd_edpt_stalled(rhport, p_msc->ep_out)) {
650+
TU_ASSERT(prepare_cbw(p_msc));
651+
} else {
652+
p_msc->stage = MSC_STAGE_CMD;
653+
}
655654
} else {
656655
// Any xfer ended here is considered unknown error, ignore it
657656
TU_LOG1(" Warning expect SCSI Status but received unknown data\r\n");

0 commit comments

Comments
 (0)