summaryrefslogtreecommitdiffstats
path: root/usb.c
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mandriva.org>2009-04-10 14:31:19 +0000
committerPascal Terjan <pterjan@mandriva.org>2009-04-10 14:31:19 +0000
commit82624de6ba2a009c9cf168c029e19b1f8280a88f (patch)
tree72362e5e17aeedd7c2f39137c98c1777e35b8872 /usb.c
parentd1191d46824541839e76f4e1509a30e1d29c1320 (diff)
downloadldetect-82624de6ba2a009c9cf168c029e19b1f8280a88f.tar
ldetect-82624de6ba2a009c9cf168c029e19b1f8280a88f.tar.gz
ldetect-82624de6ba2a009c9cf168c029e19b1f8280a88f.tar.bz2
ldetect-82624de6ba2a009c9cf168c029e19b1f8280a88f.tar.xz
ldetect-82624de6ba2a009c9cf168c029e19b1f8280a88f.zip
fix parsing of /proc/bus/usb/device I: lines and use the class
of the first interface used by a driver instead of the first interface (or first one like before when none is used). That fixes presenting something as usb_storage even if the device is ignored by usb_storage driver and handled on another interface by option driver
Diffstat (limited to 'usb.c')
-rw-r--r--usb.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usb.c b/usb.c
index 10c512e..856fba3 100644
--- a/usb.c
+++ b/usb.c
@@ -57,13 +57,17 @@ extern struct pciusb_entries usb_probe(void) {
} else fprintf(stderr, "%s %d: unknown ``P'' line\n", proc_usb_path, line);
break;
}
- case 'I': if (e->class_id == 0) {
+ case 'I': if (e->class_id == 0 || e->module == NULL) {
char driver[50];
int class_id, sub, prot = 0;
- if (sscanf(buf, "I:%*1c If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%02x Prot=%02x Driver=%s", &class_id, &sub, &prot, driver) == 4) {
- e->class_id = (class_id * 0x100 + sub) * 0x100 + prot;
+ if (sscanf(buf, "I:%*1c If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%02x Prot=%02x Driver=%s", &class_id, &sub, &prot, driver) == 4) {
+ unsigned long cid = (class_id * 0x100 + sub) * 0x100 + prot;
+ if (e->class_id == 0)
+ e->class_id = cid;
if (strncmp(driver, "(none)", 6)) {
char *p;
+ /* Get current class if we are on the first one having used by a driver */
+ e->class_id = cid;
e->module = strdup(driver);
/* replace '-' characters with '_' to be compliant with modnames from modaliases */
p = e->module;
@@ -76,8 +80,6 @@ extern struct pciusb_entries usb_probe(void) {
if (e->class_id == (0x1*0x100+ 0x01)) /* USB_AUDIO_CLASS*0x100 + USB_SUBCLASS_AUDIO_CONTROL*/
e->module = strdup("snd_usb_audio");
- } else if (sscanf(buf, "I:%*1c If#=%*2d Alt=%*2d #EPs=%*2d Cls=%02x(%*5c) Sub=%02x Prot=%02x Driver=", &class_id, &sub, &prot) == 3) {
- /* prevent spurious warnings for strange USB interfaces */
} else fprintf(stderr, "%s %d: unknown ``I'' line\n", proc_usb_path, line);
break;
}