From 0586405abbeb51b5e427e766e8e599e3045f102b Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 27 Mar 2009 18:11:40 +0000 Subject: use /sys/bus/usb/devices instead of /sys/class/usb_device (disabled in kernel) to find modalias (this breaks ABI because we now need to keep port number) --- libldetect.h | 2 ++ pciusb.c | 5 +++-- usb.c | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libldetect.h b/libldetect.h index 4e9b2d1..6ad02e7 100644 --- a/libldetect.h +++ b/libldetect.h @@ -18,6 +18,8 @@ struct pciusb_entry { unsigned short pci_device; /* pci device id 5 bits wide */ unsigned short pci_function; /* pci function id 3 bits wide */ + unsigned short usb_port; /* pci function id 3 bits wide */ + char *module; char *text; char* class; diff --git a/pciusb.c b/pciusb.c index ecbe74a..ef9af7a 100644 --- a/pciusb.c +++ b/pciusb.c @@ -114,8 +114,8 @@ static void find_usb_modules_through_aliases(struct pciusb_entry *e) { struct dirent *dent; asprintf(&usb_prefix, "%d-", e->pci_bus); - /* usbdev. */ - asprintf(&sysfs_path, "/sys/class/usb_device/usbdev%d.%d/device", e->pci_bus, e->pci_device); + /* USB port is indexed from 0 in procfs, from 1 in sysfs */ + asprintf(&sysfs_path, "/sys/bus/usb/devices/%d-%d", e->pci_bus, e->usb_port + 1); dir = opendir(sysfs_path); if (!dir) @@ -233,6 +233,7 @@ extern void pciusb_initialize(struct pciusb_entry *e) { e->pci_bus = 0xffff; e->pci_device = 0xffff; e->pci_function = 0xffff; + e->usb_port = 0xffff; e->module = NULL; e->text = NULL; e->class = NULL; diff --git a/usb.c b/usb.c index fe65611..10c512e 100644 --- a/usb.c +++ b/usb.c @@ -38,13 +38,14 @@ extern struct pciusb_entries usb_probe(void) { switch (buf[0]) { case 'T': { - unsigned short pci_bus, pci_device; + unsigned short pci_bus, pci_device, usb_port; e = &r.entries[r.nb++]; pciusb_initialize(e); - if (sscanf(buf, "T: Bus=%02hd Lev=%*02d Prnt=%*04d Port=%*02d Cnt=%*02d Dev#=%3hd Spd=%*3s MxCh=%*2d", &pci_bus, &pci_device) == 2) { + if (sscanf(buf, "T: Bus=%02hd Lev=%*02d Prnt=%*04d Port=%02hd Cnt=%*02d Dev#=%3hd Spd=%*3s MxCh=%*2d", &pci_bus, &usb_port, &pci_device) == 3) { e->pci_bus = pci_bus; e->pci_device = pci_device; + e->usb_port = usb_port; } else fprintf(stderr, "%s %d: unknown ``T'' line\n", proc_usb_path, line); break; } -- cgit v1.2.1