From 5e3dc8f8338bcf21dc8909030473022b5b5f85d1 Mon Sep 17 00:00:00 2001 From: fgsch Date: Mon, 28 Jul 2008 20:49:28 +0000 Subject: [PATCH] When getting the string descriptors, fetch 2 bytes (size and type) first, and then the whole string based on the returned size, not just one byte. The Lexar card reader kindly loaned by Denis Doroshenko (denis dot doroshenko at gmail.com) it's happy now, and after further inspection it's what other OSs do. Discussed with yuo@. krw@ yuo@ ok. --- sys/dev/usb/usb_subr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 0b682d87a09..eaad41a74c6 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.69 2008/06/29 10:04:15 yuo Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.70 2008/07/28 20:49:28 fgsch Exp $ */ /* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -127,13 +127,13 @@ usbd_get_string_desc(usbd_device_handle dev, int sindex, int langid, req.bRequest = UR_GET_DESCRIPTOR; USETW2(req.wValue, UDESC_STRING, sindex); USETW(req.wIndex, langid); - USETW(req.wLength, 1); /* only size byte first */ + USETW(req.wLength, 2); /* size and descriptor type first */ err = usbd_do_request_flags(dev, &req, sdesc, USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT); if (err) return (err); - if (actlen < 1) + if (actlen < 2) return (USBD_SHORT_XFER); USETW(req.wLength, sdesc->bLength); /* the whole string */ -- 2.20.1