summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/ata-nand-telechips.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c
index 30ca302ce9..8bef57ee21 100644
--- a/firmware/target/arm/ata-nand-telechips.c
+++ b/firmware/target/arm/ata-nand-telechips.c
@@ -27,6 +27,7 @@
27#include "nand_id.h" 27#include "nand_id.h"
28#include "storage.h" 28#include "storage.h"
29#include "buffer.h" 29#include "buffer.h"
30#include "led.h"
30 31
31#define SECTOR_SIZE 512 32#define SECTOR_SIZE 512
32 33
@@ -701,7 +702,12 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
701#ifdef HAVE_MULTIVOLUME 702#ifdef HAVE_MULTIVOLUME
702 (void)drive; /* unused for now */ 703 (void)drive; /* unused for now */
703#endif 704#endif
705
706 int ret = 0;
707
704 mutex_lock(&ata_mtx); 708 mutex_lock(&ata_mtx);
709
710 led(true);
705 711
706 while (incount > 0) 712 while (incount > 0)
707 { 713 {
@@ -713,8 +719,8 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
713 { 719 {
714 if (!nand_read_sector_of_logical_segment(segment, secmod, inbuf)) 720 if (!nand_read_sector_of_logical_segment(segment, secmod, inbuf))
715 { 721 {
716 mutex_unlock(&ata_mtx); 722 ret = -1;
717 return -1; 723 goto nand_read_error;
718 } 724 }
719 725
720#ifdef CPU_TCC780X /* 77x doesn't have USEC_TIMER yet */ 726#ifdef CPU_TCC780X /* 77x doesn't have USEC_TIMER yet */
@@ -733,14 +739,18 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
733 739
734 if (done < 0) 740 if (done < 0)
735 { 741 {
736 mutex_unlock(&ata_mtx); 742 ret = -1;
737 return -1; 743 goto nand_read_error;
738 } 744 }
739 start += done; 745 start += done;
740 } 746 }
741 747
748nand_read_error:
749
742 mutex_unlock(&ata_mtx); 750 mutex_unlock(&ata_mtx);
743 return 0; 751 led(false);
752
753 return ret;
744} 754}
745 755
746 756