summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2017-11-08 11:17:10 -0500
committerDan Halbert <halbert@halwitz.org>2017-11-08 11:17:10 -0500
commitbfe7e055e9b1dac0411fe975fdf2412029f03b33 (patch)
treed0e4980bd701cd4ee189999c60360c0c8bc99afa
parentb4fc464a4dd260bae9c2a49f996ffeb96268228d (diff)
Revert "atmel-samd: Tweak mass storage code to finish read sooner."
This reverts commit 182a946b0ef12f6f031e846af788cdeb2eecd3a6.
-rw-r--r--ports/atmel-samd/usb_mass_storage.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/atmel-samd/usb_mass_storage.c b/ports/atmel-samd/usb_mass_storage.c
index d9d9d9f39..8001cc097 100644
--- a/ports/atmel-samd/usb_mass_storage.c
+++ b/ports/atmel-samd/usb_mass_storage.c
@@ -259,9 +259,6 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
if (active_read) {
active_addr += 1;
active_nblocks--;
- if (active_nblocks == 0) {
- active_read = false;
- }
}
if (active_write) {
@@ -275,6 +272,10 @@ int32_t usb_msc_xfer_done(uint8_t lun) {
// The start_read callback begins a read transaction which we accept but delay our response until the "main thread" calls usb_msc_background. Once it does, we read immediately from the drive into our cache and trigger the USB DMA to output the sector. Once the sector is transmitted, xfer_done will be called.
void usb_msc_background(void) {
if (active_read && !usb_busy) {
+ if (active_nblocks == 0) {
+ active_read = false;
+ return;
+ }
fs_user_mount_t * vfs = get_vfs(active_lun);
disk_read(vfs, sector_buffer, active_addr, 1);
// TODO(tannewt): Check the read result.