mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usbutils.git
synced 2024-11-30 15:23:36 +08:00
Verbose flag in tree mode shows vendor and product name.
When running `lsusb -tv`, devices should have the vendor and product name appended to the row. Signed-off-by: Dafydd Crosby <dtcrsby@gmail.com>
This commit is contained in:
parent
7170260942
commit
71413e7723
24
devtree.c
24
devtree.c
@ -294,10 +294,12 @@ void devtree_processchanges(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void dumpdevlist(struct list_head *list, unsigned int level,
|
||||
unsigned int mask)
|
||||
unsigned int mask, unsigned int verblevel)
|
||||
{
|
||||
struct usbdevnode *dev;
|
||||
struct list_head *list2;
|
||||
char vendor[128];
|
||||
char product[128];
|
||||
char buf[512];
|
||||
char *cp;
|
||||
unsigned int i;
|
||||
@ -317,15 +319,23 @@ static void dumpdevlist(struct list_head *list, unsigned int level,
|
||||
*cp++ = '`';
|
||||
}
|
||||
*cp++ = '-';
|
||||
snprintf(cp, buf + sizeof(buf) - cp,
|
||||
"Dev# %3d Vendor 0x%04x Product 0x%04x",
|
||||
dev->devnum, dev->vendorid, dev->productid);
|
||||
if (verblevel > 1) {
|
||||
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 %s %s",
|
||||
dev->devnum, dev->vendorid, dev->productid, vendor, product);
|
||||
} else {
|
||||
snprintf(cp, buf + sizeof(buf) - cp,
|
||||
"Dev# %3d Vendor 0x%04x Product 0x%04x",
|
||||
dev->devnum, dev->vendorid, dev->productid);
|
||||
}
|
||||
lprintf(1, "%s\n", buf);
|
||||
dumpdevlist(&dev->childlist, level+1, mask);
|
||||
dumpdevlist(&dev->childlist, level+1, mask, verblevel);
|
||||
}
|
||||
}
|
||||
|
||||
void devtree_dump(void)
|
||||
void devtree_dump(unsigned int verblevel)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct usbbusnode *bus;
|
||||
@ -333,6 +343,6 @@ void devtree_dump(void)
|
||||
for (list = usbbuslist.next; list != &usbbuslist; list = list->next) {
|
||||
bus = list_entry(list, struct usbbusnode, list);
|
||||
lprintf(1, "Bus# %2d\n", bus->busnum);
|
||||
dumpdevlist(&bus->childlist, 0, 0);
|
||||
dumpdevlist(&bus->childlist, 0, 0, verblevel);
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ extern void devtree_busdisconnect(struct usbbusnode *bus);
|
||||
extern void devtree_devconnect(struct usbdevnode *dev);
|
||||
extern void devtree_devdisconnect(struct usbdevnode *dev);
|
||||
extern void devtree_processchanges(void);
|
||||
extern void devtree_dump(void);
|
||||
extern void devtree_dump(unsigned int verblevel);
|
||||
|
||||
extern int lprintf(unsigned int vl, const char *format, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
|
26
lsusb.c
26
lsusb.c
@ -207,30 +207,6 @@ static int get_string(libusb_device_handle *dev, char *buf, size_t size, u_int8_
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static int get_class_string(char *buf, size_t size, u_int8_t cls)
|
||||
{
|
||||
const char *cp;
|
||||
@ -3929,7 +3905,7 @@ static int treedump(void)
|
||||
}
|
||||
devtree_parsedevfile(fd);
|
||||
close(fd);
|
||||
devtree_dump();
|
||||
devtree_dump(verblevel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
26
names.c
26
names.c
@ -270,6 +270,32 @@ const char *names_videoterminal(u_int16_t termt)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static int new_vendor(const char *name, u_int16_t vendorid)
|
||||
{
|
||||
struct vendor *v;
|
||||
|
4
names.h
4
names.h
@ -47,6 +47,10 @@ extern const char *names_langid(u_int16_t langid);
|
||||
extern const char *names_physdes(u_int8_t ph);
|
||||
extern const char *names_bias(u_int8_t b);
|
||||
extern const char *names_countrycode(unsigned int countrycode);
|
||||
|
||||
extern int get_vendor_string(char *buf, size_t size, u_int16_t vid);
|
||||
extern int get_product_string(char *buf, size_t size, u_int16_t vid, u_int16_t pid);
|
||||
|
||||
extern int names_init(char *n);
|
||||
extern void names_exit(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user