$OpenBSD: patch-usbctl_c,v 1.3 2009/01/14 00:58:39 sthen Exp $
--- usbctl.c.orig	Mon Feb 25 00:50:55 2002
+++ usbctl.c	Mon Dec 15 17:43:07 2008
@@ -62,6 +62,7 @@
 #endif
 
 #define NSTRINGS
+#define STRINGLANG
 
 int num = 0;
 
@@ -80,17 +81,43 @@ getstring(int si, char *s)
 	int r, i, n;
 	u_int16_t c;
 	usb_string_descriptor_t us;
+	int lang = 0;
 
 	if (si == 0 || num) {
 		*s = 0;
 		return;
 	}
+
+#ifdef STRINGLANG
 	req.ucr_addr = usbaddr;
 	req.ucr_request.bmRequestType = UT_READ_DEVICE;
 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
 	req.ucr_data = &us;
-	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
+	USETW2(req.ucr_request.wValue, UDESC_STRING, 0);
 	USETW(req.ucr_request.wIndex, 0);
+	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
+	req.ucr_flags = USBD_SHORT_XFER_OK;
+	r = ioctl(usbf, USB_REQUEST, &req);
+	if (r < 0) {
+		fprintf(stderr, "get lang tbl failed (error=%d)\n", errno);
+		*s = 0;
+		return;
+	}
+	if (req.ucr_actlen > 0 && us.bLength >= 4) {
+		lang = UGETW(us.bString[0]);
+#if 0
+		printf("getstring: %d langs, using %d\n",
+		       (us.bLength - 2) / 2, lang);
+#endif
+	}
+#endif
+
+	req.ucr_addr = usbaddr;
+	req.ucr_request.bmRequestType = UT_READ_DEVICE;
+	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
+	req.ucr_data = &us;
+	USETW2(req.ucr_request.wValue, UDESC_STRING, si);
+	USETW(req.ucr_request.wIndex, lang);
 #ifdef NSTRINGS
 	USETW(req.ucr_request.wLength, sizeof(usb_string_descriptor_t));
 	req.ucr_flags = USBD_SHORT_XFER_OK;
@@ -384,7 +411,7 @@ struct usb_cdc_union_descriptor {
 };
 
 void
-prcdcd(usb_descriptor_t *ud)
+prcdcd(struct usb_cdc_header_descriptor *ud)
 {
 	if (ud->bDescriptorType != UDESC_CS_INTERFACE)
 		printf("prcdcd: strange bDescriptorType=%d\n", 
@@ -630,7 +657,7 @@ gethubdesc(int f, usb_hub_descriptor_t *d, int addr)
 	req.ucr_addr = addr;
 	req.ucr_request.bmRequestType = UT_READ_CLASS_DEVICE;
 	req.ucr_request.bRequest = UR_GET_DESCRIPTOR;
-	USETW(req.ucr_request.wValue, 0);
+	USETW2(req.ucr_request.wValue, UDESC_HUB, 0);
 	USETW(req.ucr_request.wIndex, 0);
 	USETW(req.ucr_request.wLength, USB_HUB_DESCRIPTOR_SIZE);
 	req.ucr_data = d;
@@ -1243,8 +1270,8 @@ prdesc(void *p, int *class, int *subclass, int *iface,
 	default:
 	def:
 		printf("Unknown descriptor (class %d/%d):\n", *class, *subclass);
-		printf("bLength=%d bDescriptorType=%d bDescriptorSubtype=%d ...\n", d->bLength, 
-		       d->bDescriptorType, d->bDescriptorSubtype
+		printf("bLength=%d bDescriptorType=%d ...\n", d->bLength, 
+		       d->bDescriptorType
 		       );
 		break;
 	}
@@ -1321,6 +1348,7 @@ main(int argc, char **argv)
 
 	if (!doaddr)
 		prunits(f);
+#ifndef __OpenBSD__
 	if (!nodisc) {
 		r = ioctl(f, USB_DISCOVER);
 		if (r < 0)
@@ -1329,6 +1357,7 @@ main(int argc, char **argv)
 		if (disconly)
 			exit(0);
 	}
+#endif
 
 	for(addr = 0; addr < USB_MAX_DEVICES; addr++) {
 		if (doaddr != -1 && addr != doaddr)
