summaryrefslogtreecommitdiff
path: root/common/usb_storage.c
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-12-12 17:55:29 -0800
committerMarek Vasut <marex@denx.de>2012-12-17 15:38:15 +0100
commit8b57e2f0814a2fd9aed1fa09d8279eaf90764560 (patch)
tree9c20381ef2e51866360af00489c968a1b3c2b026 /common/usb_storage.c
parent359439d2888fdc3797903963607bb0bbd4582e08 (diff)
downloadu-boot-imx-8b57e2f0814a2fd9aed1fa09d8279eaf90764560.zip
u-boot-imx-8b57e2f0814a2fd9aed1fa09d8279eaf90764560.tar.gz
u-boot-imx-8b57e2f0814a2fd9aed1fa09d8279eaf90764560.tar.bz2
usb: properly detect empty mass storage media reader
When a USB card reader is empty, it will return "Not Ready - medium not present" as Key Code Qualifier. In that situation, it's useless waiting for the full timeout since the result won't change until the user inserts a card. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/usb_storage.c')
-rw-r--r--common/usb_storage.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 2d92ee1..fb322b4 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -970,6 +970,16 @@ static int usb_test_unit_ready(ccb *srb, struct us_data *ss)
return 0;
}
usb_request_sense(srb, ss);
+ /*
+ * Check the Key Code Qualifier, if it matches
+ * "Not Ready - medium not present"
+ * (the sense Key equals 0x2 and the ASC is 0x3a)
+ * return immediately as the medium being absent won't change
+ * unless there is a user action.
+ */
+ if ((srb->sense_buf[2] == 0x02) &&
+ (srb->sense_buf[12] == 0x3a))
+ return -1;
mdelay(100);
} while (retries--);