diff options
-rw-r--r-- | firmware/drivers/ata_mmc.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 447bd8bec6..1040ab067f 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -643,7 +643,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
643 | rc = -3; | 643 | rc = -3; |
644 | goto error; | 644 | goto error; |
645 | } | 645 | } |
646 | while (incount-- > lastblock) | 646 | while (--incount >= lastblock) |
647 | { | 647 | { |
648 | rc = receive_block(inbuf, card->read_timeout); | 648 | rc = receive_block(inbuf, card->read_timeout); |
649 | if (rc) | 649 | if (rc) |
@@ -730,25 +730,17 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
730 | rc = -2; | 730 | rc = -2; |
731 | goto error; | 731 | goto error; |
732 | } | 732 | } |
733 | 733 | while (--count >= 0) | |
734 | while (--count > 0) | ||
735 | { | 734 | { |
736 | rc = send_block_send(start_token, card->write_timeout, true); | 735 | rc = send_block_send(start_token, card->write_timeout, count > 0); |
737 | if (rc) | 736 | if (rc) |
738 | { | 737 | { |
739 | rc = rc * 10 - 3; | 738 | rc = rc * 10 - 3; |
740 | break; | 739 | break; |
740 | /* If an error occurs during multiple block writing, | ||
741 | * the STOP_TRAN token still needs to be sent. */ | ||
741 | } | 742 | } |
742 | } | 743 | } |
743 | if (rc == 0) | ||
744 | { | ||
745 | rc = send_block_send(start_token, card->write_timeout, false); | ||
746 | if (rc) | ||
747 | rc = rc * 10 - 4; | ||
748 | } | ||
749 | /* If an error occurs during multiple block writing, the STOP_TRAN token | ||
750 | * still needs to be sent, hence the special error handling above. */ | ||
751 | |||
752 | if (write_cmd == CMD_WRITE_MULTIPLE_BLOCK) | 744 | if (write_cmd == CMD_WRITE_MULTIPLE_BLOCK) |
753 | { | 745 | { |
754 | static const unsigned char stop_tran = DT_STOP_TRAN; | 746 | static const unsigned char stop_tran = DT_STOP_TRAN; |