From 3fe9aaa567b595b50c5090f6f67f9cd5b6163746 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 6 Apr 2023 12:33:47 -0500 Subject: [PATCH] Attempt to handle pci bridges (no DRIVER line). --- toys/other/lsusb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/toys/other/lsusb.c b/toys/other/lsusb.c index c4f64529..aa802b34 100644 --- a/toys/other/lsusb.c +++ b/toys/other/lsusb.c @@ -58,7 +58,7 @@ struct scanloop { // note that %s is omitted (because pointer is into toybuf, avoiding copy). static int scan_uevent(struct dirtree *new, int len, struct scanloop *sl) { - int ii, count = 0; + int ii, saw = 0; off_t flen = sizeof(toybuf); char *ss, *yy; @@ -75,18 +75,18 @@ static int scan_uevent(struct dirtree *new, int len, struct scanloop *sl) // Try each pattern for (ii = 0; iiparent) return DIRTREE_RECURSE; - if (3 == scan_uevent(new, 3, (struct scanloop[]){{"BUSNUM=%u", &busnum, 0}, + if (7 == scan_uevent(new, 3, (struct scanloop[]){{"BUSNUM=%u", &busnum, 0}, {"DEVNUM=%u", &devnum, 0}, {"PRODUCT=%x/%x", &pid, &vid}})) { get_names(TT.ids, pid, vid, &n1, &n2); @@ -207,7 +207,7 @@ static int list_pci(struct dirtree *new) } // Load uevent data, look up names in database - if (3 != scan_uevent(new, 3, (struct scanloop[]){{"DRIVER=", &driver, 0}, + if (6>scan_uevent(new, 3, (struct scanloop[]){{"DRIVER=", &driver, 0}, {"PCI_CLASS=%x", cvd, 0}, {"PCI_ID=%x:%x", cvd+1, cvd+2}})) return 0; get_names(TT.class, 255&(cvd[0]>>16), 255&(cvd[0]>>8), names, names); get_names(TT.ids, cvd[1], cvd[2], names+1, names+2); @@ -227,7 +227,7 @@ static int list_pci(struct dirtree *new) } else printf(" \"%s [%s]\"", names[ii], buf); } printf(FLAG(m) ? " -r%02x" : " (rev %02x)", revision); - if (FLAG(k)) printf(FLAG(m) ? " \"%s\"" : " %s", driver); + if (FLAG(k) && driver) printf(FLAG(m) ? " \"%s\"" : " %s", driver); xputc('\n'); if (TT.x) { -- 2.39.2