From e6e1d4eb1ad13be37416d892478fc786d4c8d120 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 30 Mar 2007 16:52:12 +0000 Subject: [PATCH] PR/36102: Yojiro UO: Restore revision 1.142's way of reading the descriptor because uplcom hangs otherwise. Also reported by Anon Ymous. --- sys/dev/usb/usb_subr.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index 34a12ae70987..7623be70a37e 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.145 2007/03/15 15:11:19 drochner Exp $ */ +/* $NetBSD: usb_subr.c,v 1.146 2007/03/30 16:52:12 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.145 2007/03/15 15:11:19 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.146 2007/03/30 16:52:12 christos Exp $"); #include "opt_compat_netbsd.h" #include "opt_usbverbose.h" @@ -174,12 +174,21 @@ 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, sizeof(usb_string_descriptor_t)); + USETW(req.wLength, 2); /* only size byte first */ err = usbd_do_request_flags(dev, &req, sdesc, USBD_SHORT_XFER_OK, &actlen, USBD_DEFAULT_TIMEOUT); if (err) return (err); + if (actlen < 2) + return (USBD_SHORT_XFER); + + USETW(req.wLength, sdesc->bLength); /* the whole string */ + err = usbd_do_request_flags(dev, &req, sdesc, USBD_SHORT_XFER_OK, + &actlen, USBD_DEFAULT_TIMEOUT); + if (err) + return (err); + if (actlen != sdesc->bLength) { DPRINTFN(-1, ("usbd_get_string_desc: expected %d, got %d\n", sdesc->bLength, actlen));