PR/36102: Yojiro UO: Restore revision 1.142's way of reading the descriptor

because uplcom hangs otherwise. Also reported by Anon Ymous.
This commit is contained in:
christos 2007-03-30 16:52:12 +00:00
parent b1bfbbc629
commit e6e1d4eb1a

View File

@ -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 <sys/cdefs.h>
__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));