I was having some issues with `lsusb -t` (the tree view mode) in that it doesn't show the vendor and product (which is default behaviour with lsusb and no arguments). This patch should take care of that. -Dafydd Crosby diff --git a/devtree.c b/devtree.c index 69c93ac..83ce8e1 100644 --- a/devtree.c +++ b/devtree.c @@ -38,6 +38,7 @@ #include <string.h> #include <unistd.h> +#include "names.h" #include "devtree.h" /* ---------------------------------------------------------------------- */ @@ -81,6 +82,30 @@ void devtree_markdeleted(void) } } +static int get_vendor_string(char *buf, size_t size, u_int16_t vid) +{ + const char *cp; + + if (size < 1) + return 0; + *buf = 0; + if (!(cp = names_vendor(vid))) + return 0; + return snprintf(buf, size, "%s", cp); +} + +static int get_product_string(char *buf, size_t size, u_int16_t vid, u_int16_t pid) +{ + const char *cp; + + if (size < 1) + return 0; + *buf = 0; + if (!(cp = names_product(vid, pid))) + return 0; + return snprintf(buf, size, "%s", cp); +} + struct usbbusnode *devtree_findbus(unsigned int busn) { struct usbbusnode *bus; @@ -299,6 +324,7 @@ static void dumpdevlist(struct list_head *list, unsigned int level, struct usbdevnode *dev; struct list_head *list2; char buf[512]; + char vendor[128], product[128]; char *cp; unsigned int i; @@ -317,9 +343,11 @@ static void dumpdevlist(struct list_head *list, unsigned int level, *cp++ = '`'; } *cp++ = '-'; + get_vendor_string(vendor, sizeof(vendor), dev->vendorid); + get_product_string(product, sizeof(product), dev->vendorid, dev->productid); snprintf(cp, buf + sizeof(buf) - cp, - "Dev# %3d Vendor 0x%04x Product 0x%04x", - dev->devnum, dev->vendorid, dev->productid); + "Dev# %3d Vendor 0x%04x Product 0x%04x %s %s", + dev->devnum, dev->vendorid, dev->productid, vendor, product); lprintf(1, "%s\n", buf); dumpdevlist(&dev->childlist, level+1, mask); } -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html