public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Devices that ignore USB spec generate invalid modaliases
@ 2009-11-11  8:20 Nathaniel McCallum
  2009-11-11  8:39 ` Nathaniel McCallum
  2009-11-12 23:42 ` [PATCH] " Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Nathaniel McCallum @ 2009-11-11  8:20 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 949 bytes --]

Please CC me as I'm not subscribed to LKML.

The current code to generate usb modaliases from usb_device_id assumes 
that the device's bcdDevice descriptor will actually be in BCD format. 
While this should be a sane assumption, some devices don't follow spec 
and just use plain old hex.  This causes drivers for these devices to 
generate invalid modalias lines which will never actually match for the 
hardware.

The following patch adds hex support for bcdDevice in file2alias.c. 
Drivers for devices which have bcdDevice conforming to BCD will have no 
change in modalias output.  Drivers for devices which don't conform 
(primarily usb-storage and ibmcam in my initial survey) should now 
generate valid modaliases.

EXAMPLE OUTPUT (ibmcam; space added to highlight change)
Old: usb:v0545p800D d030[10-9] dc*dsc*dp*ic*isc*ip*
New: usb:v0545p800D d030a      dc*dsc*dp*ic*isc*ip*

Patch attached. Questions/comments welcome.

Nathaniel McCallum

[-- Attachment #2: file2alias_usb_bcd2hex.patch --]
[-- Type: text/plain, Size: 1502 bytes --]

--- linux-2.6.31.orig/scripts/mod/file2alias.c	2009-09-09 18:13:59.000000000 -0400
+++ linux-2.6.31/scripts/mod/file2alias.c	2009-11-11 02:51:02.446894908 -0500
@@ -118,9 +118,20 @@
 		sprintf(alias + strlen(alias), "%0*X",
 			bcdDevice_initial_digits, bcdDevice_initial);
 	if (range_lo == range_hi)
-		sprintf(alias + strlen(alias), "%u", range_lo);
-	else if (range_lo > 0 || range_hi < 9)
-		sprintf(alias + strlen(alias), "[%u-%u]", range_lo, range_hi);
+		sprintf(alias + strlen(alias), "%x", range_lo);
+	else if (range_lo > 0x0 || range_hi < 0xf) {
+		if (range_lo > 0x9 || range_hi < 0xa)
+			sprintf(alias + strlen(alias),
+				"[%x-%x]", range_lo, range_hi);
+		else {
+			sprintf(alias + strlen(alias), 
+				range_lo < 0x9 ? "[%x-9" : "[%x",
+				range_lo);
+			sprintf(alias + strlen(alias), 
+				range_hi > 0xa ? "a-%x]" : "%x]",
+				range_hi);
+		}
+	}
 	if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
 		strcat(alias, "*");
 
@@ -173,8 +184,6 @@
 	for (ndigits = sizeof(id->bcdDevice_lo) * 2 - 1; devlo <= devhi; ndigits--) {
 		clo = devlo & 0xf;
 		chi = devhi & 0xf;
-		if (chi > 9)	/* it's bcd not hex */
-			chi = 9;
 		devlo >>= 4;
 		devhi >>= 4;
 
@@ -184,10 +193,10 @@
 		}
 
 		if (clo > 0)
-			do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
+			do_usb_entry(id, devlo++, ndigits, clo, 0xf, mod);
 
-		if (chi < 9)
-			do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
+		if (chi < 0xf)
+			do_usb_entry(id, devhi--, ndigits, 0x0, chi, mod);
 	}
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-13 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11  8:20 [PATCH] Devices that ignore USB spec generate invalid modaliases Nathaniel McCallum
2009-11-11  8:39 ` Nathaniel McCallum
2009-11-11 18:54   ` [PATCH][RFC] " Nathaniel McCallum
2009-11-12 23:42 ` [PATCH] " Greg KH
2009-11-13  1:09   ` Nathaniel McCallum
2009-11-13 14:51     ` Nathaniel McCallum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox