summaryrefslogtreecommitdiff
path: root/sys/dev/usb/usb_subr.c
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2005-10-17 18:00:44 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2005-10-17 18:00:44 +0000
commitb4aac7e1c526df30d06941af1dee24c4751396a2 (patch)
tree08a63ad01028aecbb272cb20a6c8838c02caa4f3 /sys/dev/usb/usb_subr.c
parent96670d31b7bb09681ac167c4251e012c5768ad20 (diff)
Store the usb device names and vendors in more compact structures.
Originally committed in 2001, backed out in a sync, now back in. saves close to 12k of kernel size. commit deraadt@
Diffstat (limited to 'sys/dev/usb/usb_subr.c')
-rw-r--r--sys/dev/usb/usb_subr.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index ceca07f3608..3a11114e216 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.39 2005/10/10 14:20:16 krw Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.40 2005/10/17 18:00:43 drahn 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 $ */
@@ -102,13 +102,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 */
@@ -252,7 +255,8 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev)
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
#ifdef USBVERBOSE
- const struct usb_knowndev *kdp;
+ const struct usb_known_vendor *ukv;
+ const struct usb_known_product *ukp;
#endif
if (dev == NULL) {
@@ -271,20 +275,24 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev)
}
#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 == NULL)
- vendor = kdp->vendorname;
- if (product == NULL)
- 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