summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2010-12-04 13:56:19 +0000
committerFrank Gevaerts <frank@gevaerts.be>2010-12-04 13:56:19 +0000
commitf9a6bde15fc584574d5b5f11d8767c06dcc24702 (patch)
tree61d999bc08aba9a4e04772982792d74b17d889a3 /firmware
parent911f2a7dac59cab16f6c47420e2d1e12e8b60b70 (diff)
downloadrockbox-f9a6bde15fc584574d5b5f11d8767c06dcc24702.tar.gz
rockbox-f9a6bde15fc584574d5b5f11d8767c06dcc24702.tar.bz2
rockbox-f9a6bde15fc584574d5b5f11d8767c06dcc24702.zip
Handle disk errors properly in USB storage driver. Fixes FS#10873
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28733 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/usbstack/usb_storage.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 567331d714..005697f6fa 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -647,7 +647,16 @@ void usb_storage_transfer_complete(int ep,int dir,int status,int length)
if(status==0) {
if(cur_cmd.count==0) {
//logf("data sent, now send csw");
- send_csw(UMS_STATUS_GOOD);
+ if(cur_cmd.last_result!=0) {
+ /* The last read failed. */
+ send_csw(UMS_STATUS_FAIL);
+ cur_sense_data.sense_key=SENSE_MEDIUM_ERROR;
+ cur_sense_data.asc=ASC_READ_ERROR;
+ cur_sense_data.ascq=0;
+ return;
+ }
+ else
+ send_csw(UMS_STATUS_GOOD);
}
else {
send_and_read_next();
@@ -716,14 +725,6 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* des
static void send_and_read_next(void)
{
- if(cur_cmd.last_result!=0) {
- /* The last read failed. */
- send_csw(UMS_STATUS_FAIL);
- cur_sense_data.sense_key=SENSE_MEDIUM_ERROR;
- cur_sense_data.asc=ASC_READ_ERROR;
- cur_sense_data.ascq=0;
- return;
- }
send_block_data(cur_cmd.data[cur_cmd.data_select],
MIN(READ_BUFFER_SIZE,cur_cmd.count*SECTOR_SIZE));
@@ -741,10 +742,13 @@ static void send_and_read_next(void)
ramdisk_buffer + cur_cmd.sector*SECTOR_SIZE,
MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count)*SECTOR_SIZE);
#else
- cur_cmd.last_result = storage_read_sectors(IF_MD2(cur_cmd.lun,)
+ int result = storage_read_sectors(IF_MD2(cur_cmd.lun,)
cur_cmd.sector,
MIN(READ_BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count),
cur_cmd.data[cur_cmd.data_select]);
+ if(cur_cmd.last_result == 0)
+ cur_cmd.last_result = result;
+
#endif
}
}