diff options
author | Ondrej Čerman <ondrej.cerman@gmail.com> | 2019-07-26 22:17:23 +0200 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-07-29 19:44:04 -0700 |
commit | 4cfbf4907fa8221b7d8fcd7aa74ffd1d45691ef6 (patch) | |
tree | ed1b1b22c15a0f141bea7430d6664822224d323f | |
parent | e71298e11039fd1b22758097410fdca52b8610a2 (diff) |
usb: added interface label
-rw-r--r-- | hardinfo/usb_util.c | 9 | ||||
-rw-r--r-- | includes/usb_util.h | 1 | ||||
-rw-r--r-- | modules/devices/usb.c | 4 |
3 files changed, 12 insertions, 2 deletions
diff --git a/hardinfo/usb_util.c b/hardinfo/usb_util.c index 845dbd2a..cc839b9a 100644 --- a/hardinfo/usb_util.c +++ b/hardinfo/usb_util.c @@ -30,6 +30,7 @@ usbi *usbi_new() { void usbi_free(usbi *s) { if (s) { + g_free(s->if_label); g_free(s->if_class_str); g_free(s->if_subclass_str); g_free(s->if_protocol_str); @@ -234,6 +235,11 @@ static gboolean usb_get_device_lsusb(int bus, int dev, usbd *s) { if (t = strchr(l, ' ')) curr_if->if_protocol_str = g_strdup(t + 1); } + } else if (l = lsusb_line_value(p, "iInterface")) { + if (curr_if != NULL){ + if (t = strchr(l, ' ')) + curr_if->if_label = g_strdup(t + 1); + } } p = next_nl + 1; @@ -270,6 +276,9 @@ static gboolean usb_get_interface_sysfs(int conf, int number, intf->if_subclass = h_sysfs_read_hex(ifpath, "bInterfaceSubClass"); intf->if_protocol = h_sysfs_read_hex(ifpath, "bInterfaceProtocol"); + if (intf->if_label == NULL) + intf->if_label = h_sysfs_read_string(ifpath, "interface"); + g_free(ifpath); return TRUE; } diff --git a/includes/usb_util.h b/includes/usb_util.h index 2d1398ba..1b92a34c 100644 --- a/includes/usb_util.h +++ b/includes/usb_util.h @@ -52,6 +52,7 @@ typedef struct usbi { int if_class; int if_subclass; int if_protocol; + char *if_label; char *if_class_str; char *if_subclass_str; char *if_protocol_str; diff --git a/modules/devices/usb.c b/modules/devices/usb.c index 4e262fa2..f01bee5a 100644 --- a/modules/devices/usb.c +++ b/modules/devices/usb.c @@ -131,13 +131,13 @@ static void _usb_dev(const usbd *u) { if_protocol_str = UNKIFNULL_AC(i->if_protocol_str); if_driver = UNKIFNULL_AC(i->driver); - interfaces = h_strdup_cprintf("[%s %d]\n" + interfaces = h_strdup_cprintf("[%s %d %s]\n" /* Class */ "%s=[%d] %s\n" /* Sub-class */ "%s=[%d] %s\n" /* Protocol */ "%s=[%d] %s\n" /* Driver */ "%s=%s\n", interfaces, - _("Interface"), i->if_number, + _("Interface"), i->if_number, i->if_label? i->if_label: "", _("Class"), i->if_class, if_class_str, _("Sub-class"), i->if_subclass, if_subclass_str, _("Protocol"), i->if_protocol, if_protocol_str, |