summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/ata_mmc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 6c3f1f6775..d7b734603a 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -575,7 +575,7 @@ static void send_block_prepare(void)
575 575
576/* Send one block with DMA from the current write buffer, possibly preparing 576/* Send one block with DMA from the current write buffer, possibly preparing
577 * the next block within the next write buffer in the background. */ 577 * the next block within the next write buffer in the background. */
578static int send_block_send(unsigned char start_token, long timeout, 578static int send_block_send(unsigned char start_token, long timeout,
579 bool prepare_next) 579 bool prepare_next)
580{ 580{
581 int rc = 0; 581 int rc = 0;
@@ -665,6 +665,9 @@ int ata_read_sectors(IF_MV2(int drive,)
665 rc = receive_block(inbuf, card->read_timeout); 665 rc = receive_block(inbuf, card->read_timeout);
666 if (rc) 666 if (rc)
667 { 667 {
668 /* If an error occurs during multiple block reading, the
669 * host still needs to send CMD_STOP_TRANSMISSION */
670 send_cmd(CMD_STOP_TRANSMISSION, 0, &response);
668 rc = rc * 10 - 4; 671 rc = rc * 10 - 4;
669 goto error; 672 goto error;
670 } 673 }
@@ -755,15 +758,17 @@ int ata_write_sectors(IF_MV2(int drive,)
755 if (rc) 758 if (rc)
756 { 759 {
757 rc = rc * 10 - 3; 760 rc = rc * 10 - 3;
758 goto error; 761 break;
759 } 762 }
760 } 763 }
761 rc = send_block_send(start_token, card->write_timeout, false); 764 if (rc == 0)
762 if (rc)
763 { 765 {
764 rc = rc * 10 - 4; 766 rc = send_block_send(start_token, card->write_timeout, false);
765 goto error; 767 if (rc)
766 } 768 rc = rc * 10 - 4;
769 }
770 /* If an error occurs during multiple block writing, the STOP_TRAN token
771 * still needs to be sent, hence the special error handling above. */
767 772
768 if (write_cmd == CMD_WRITE_MULTIPLE_BLOCK) 773 if (write_cmd == CMD_WRITE_MULTIPLE_BLOCK)
769 { 774 {
@@ -802,7 +807,7 @@ static void mmc_thread(void)
802{ 807{
803 struct queue_event ev; 808 struct queue_event ev;
804 bool idle_notified = false; 809 bool idle_notified = false;
805 810
806 while (1) { 811 while (1) {
807 queue_wait_w_tmo(&mmc_queue, &ev, HZ); 812 queue_wait_w_tmo(&mmc_queue, &ev, HZ);
808 switch ( ev.id ) 813 switch ( ev.id )