From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 13 Dec 2012 18:37:31 +0100 Subject: [U-Boot] [PATCH 09/11] usb: properly detect empty mass storage media reader In-Reply-To: <1355363731-10103-10-git-send-email-sjg@chromium.org> References: <1355363731-10103-1-git-send-email-sjg@chromium.org> <1355363731-10103-10-git-send-email-sjg@chromium.org> Message-ID: <201212131837.31739.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Simon Glass, > From: Vincent Palatin > > 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. Applied, thanks! > Signed-off-by: Vincent Palatin > Signed-off-by: Vadim Bendebury > Signed-off-by: Simon Glass > --- > common/usb_storage.c | 10 ++++++++++ > 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--); Best regards, Marek Vasut