|
|
@@ -43,6 +43,7 @@ struct usb_msc {
|
|
|
unsigned int config; /* configuration value, for recovery */
|
|
|
unsigned int timeout_ms; /* bulk-IN deadline */
|
|
|
unsigned int first_read; /* media not read since the probe */
|
|
|
+ int failed; /* last media read failed */
|
|
|
unsigned int sectors;
|
|
|
unsigned int tag;
|
|
|
unsigned int last_status, last_residue;
|
|
|
@@ -65,8 +66,15 @@ void usbmsc_begin_full_scan(void)
|
|
|
unsigned int i;
|
|
|
|
|
|
for (i = 0; i < USB_MSC_MAX; i++)
|
|
|
- if (msc[i].present)
|
|
|
+ if (msc[i].present) {
|
|
|
msc[i].first_read = 1;
|
|
|
+ msc[i].failed = 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int usbmsc_slot_failed(unsigned int unit)
|
|
|
+{
|
|
|
+ return unit < USB_MSC_MAX && msc[unit].present && msc[unit].failed;
|
|
|
}
|
|
|
|
|
|
static unsigned int rd32le(const unsigned char *p)
|
|
|
@@ -503,6 +511,7 @@ static int device_probe(unsigned int ctrl, unsigned int addr,
|
|
|
m->config = 0;
|
|
|
m->timeout_ms = MSC_TIMEOUT_MS;
|
|
|
m->first_read = 0;
|
|
|
+ m->failed = 0;
|
|
|
|
|
|
if (msc_config(m) != 0)
|
|
|
return 0;
|
|
|
@@ -629,6 +638,7 @@ static int msc_read_claimed(unsigned int unit, unsigned int lba, void *buf,
|
|
|
(m->sense_asc << 8) |
|
|
|
m->sense_ascq);
|
|
|
io_putchar('\n');
|
|
|
+ m->failed = 1;
|
|
|
return -1;
|
|
|
}
|
|
|
} else {
|
|
|
@@ -638,6 +648,7 @@ static int msc_read_claimed(unsigned int unit, unsigned int lba, void *buf,
|
|
|
io_puthex((m->sense_key << 16) |
|
|
|
(m->sense_asc << 8) | m->sense_ascq);
|
|
|
io_putchar('\n');
|
|
|
+ m->failed = 1;
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
@@ -645,6 +656,7 @@ static int msc_read_claimed(unsigned int unit, unsigned int lba, void *buf,
|
|
|
p += n * 512u;
|
|
|
count -= n;
|
|
|
}
|
|
|
+ m->failed = 0;
|
|
|
return 0;
|
|
|
}
|
|
|
|