From: Nathaniel McCallum <nathaniel@natemccallum.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Devices that ignore USB spec generate invalid modaliases
Date: Wed, 11 Nov 2009 03:20:23 -0500 [thread overview]
Message-ID: <4AFA73C7.4070002@natemccallum.com> (raw)
[-- 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);
}
}
next reply other threads:[~2009-11-11 8:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-11 8:20 Nathaniel McCallum [this message]
2009-11-11 8:39 ` [PATCH] Devices that ignore USB spec generate invalid modaliases 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AFA73C7.4070002@natemccallum.com \
--to=nathaniel@natemccallum.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox