summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-27 04:02:11 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-27 04:02:11 +0000
commitf2da1011abf4f49badb38104c86b1b6e5c456994 (patch)
treed58421bbe8fad8bf4e96c62dfc02ef4b7628d930
parent4646a15c8dc06936079f6763c94ac8b2f02d7da1 (diff)
re-arrange tables as pcidevs was changed; huge space savings
-rw-r--r--sys/dev/usb/devlist2h.awk32
-rw-r--r--sys/dev/usb/usb_subr.c44
2 files changed, 35 insertions, 41 deletions
diff --git a/sys/dev/usb/devlist2h.awk b/sys/dev/usb/devlist2h.awk
index 9320d9a4bf8..ff4dbc1b863 100644
--- a/sys/dev/usb/devlist2h.awk
+++ b/sys/dev/usb/devlist2h.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $OpenBSD: devlist2h.awk,v 1.4 1999/12/26 15:00:47 fgsch Exp $
+# $OpenBSD: devlist2h.awk,v 1.5 2001/01/27 04:02:10 deraadt Exp $
# $NetBSD: devlist2h.awk,v 1.8 1999/11/18 23:32:25 augustss Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -175,28 +175,12 @@ END {
printf("\n") > dfile
- printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
+ printf("struct usb_known_product usb_known_products[] = {\n") > dfile
for (i = 1; i <= nproducts; i++) {
printf("\t{\n") > dfile
printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
products[i, 1], products[i, 1], products[i, 2]) \
> dfile
- printf("\t ") > dfile
- printf("0") > dfile
- printf(",\n") > dfile
-
- vendi = vendorindex[products[i, 1]];
- printf("\t \"") > dfile
- j = 3;
- needspace = 0;
- while (vendors[vendi, j] != "") {
- if (needspace)
- printf(" ") > dfile
- printf("%s", vendors[vendi, j]) > dfile
- needspace = 1
- j++
- }
- printf("\",\n") > dfile
printf("\t \"") > dfile
j = 4;
@@ -211,12 +195,15 @@ END {
printf("\",\n") > dfile
printf("\t},\n") > dfile
}
+ printf("\t{ 0, 0, NULL }\n") > dfile
+ printf("};\n\n") > dfile
+
+ printf("struct usb_known_vendor usb_known_vendors[] = {\n") > dfile
for (i = 1; i <= nvendors; i++) {
printf("\t{\n") > dfile
- printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
- > dfile
- printf("\t USB_KNOWNDEV_NOPROD,\n") \
+ printf("\t USB_VENDOR_%s,\n", vendors[i, 1]) \
> dfile
+
printf("\t \"") > dfile
j = 3;
needspace = 0;
@@ -228,9 +215,8 @@ END {
j++
}
printf("\",\n") > dfile
- printf("\t NULL,\n") > dfile
printf("\t},\n") > dfile
}
- printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
+ printf("\t{ 0, NULL }\n") > dfile
printf("};\n") > dfile
}
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index cba9455b243..f0eaa01ccdc 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.14 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.15 2001/01/27 04:02:10 deraadt Exp $ */
/* $NetBSD: usb_subr.c,v 1.72 2000/04/14 14:13:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -100,13 +100,16 @@ typedef u_int16_t usb_product_id_t;
/*
* Descriptions of of known vendors and devices ("products").
*/
-struct usb_knowndev {
+struct usb_known_vendor {
+ usb_vendor_id_t vendor;
+ char *vendorname;
+};
+
+struct usb_known_product {
usb_vendor_id_t vendor;
usb_product_id_t product;
- int flags;
- char *vendorname, *productname;
+ char *productname;
};
-#define USB_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
#include <dev/usb/usbdevs_data.h>
#endif /* USBVERBOSE */
@@ -215,7 +218,8 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p)
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
#ifdef USBVERBOSE
- struct usb_knowndev *kdp;
+ struct usb_known_vendor *ukv;
+ struct usb_known_product *ukp;
#endif
if (dev == NULL) {
@@ -227,20 +231,24 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p)
product = usbd_get_string(dev, udd->iProduct, p);
#ifdef USBVERBOSE
if (vendor == NULL || product == NULL) {
- for(kdp = usb_knowndevs;
- kdp->vendorname != NULL;
- kdp++) {
- if (kdp->vendor == UGETW(udd->idVendor) &&
- (kdp->product == UGETW(udd->idProduct) ||
- (kdp->flags & USB_KNOWNDEV_NOPROD) != 0))
+ for(ukv = usb_known_vendors;
+ ukv->vendorname != NULL;
+ ukv++) {
+ if (ukv->vendor == UGETW(udd->idVendor)) {
+ vendor = ukv->vendorname;
break;
+ }
}
- if (kdp->vendorname != NULL) {
- if (!vendor)
- vendor = kdp->vendorname;
- if (!product)
- product = (kdp->flags & USB_KNOWNDEV_NOPROD) == 0 ?
- kdp->productname : NULL;
+ if (vendor != NULL) {
+ for(ukp = usb_known_products;
+ ukp->productname != NULL;
+ ukp++) {
+ if (ukp->vendor == UGETW(udd->idVendor) &&
+ (ukp->product == UGETW(udd->idProduct))) {
+ product = ukp->productname;
+ break;
+ }
+ }
}
}
#endif