[PATCH] USB: scripts/mod/file2alias.c: handle numeric ranges for USB bcdDevice
authorRoman Kagan <rkagan@mail.ru>
Fri, 22 Apr 2005 22:07:01 +0000 (15:07 -0700)
committerGreg KH <gregkh@suse.de>
Fri, 22 Apr 2005 22:07:01 +0000 (15:07 -0700)
commitb19dcd9341a81ff6e04fcec396f77eeb91570584
treef2eebbf7142d5d36ffb44d365ad3eca539ff5127
parent2e0a6b8cd27375089f8356e7f1ce2319059696eb
[PATCH] USB: scripts/mod/file2alias.c: handle numeric ranges for USB bcdDevice

Another attempt at that...

The attached patch fixes the longstanding problem with USB bcdDevice
numeric ranges incorrectly converted into patterns for MODULE_ALIAS
generation.  Previously it put both the lower and the upper limits into
the pattern, dlXdhY, making it impossible to fnmatch against except for
a few special cases, like dl*dh* or dlXdhX.

The patch makes it generate multiple MODULE_ALIAS lines covering the
whole range with fnmatch-able patterns.  E.g. for a range between 0x0001
and 0x8345 it gives the following patterns:

000[1-9]
00[1-9]*
0[1-9]*
[1-7]*
8[0-2]*
83[0-3]*
834[0-5]

Since bcdDevice is 2 bytes wide = 4 digits in hex representation, the
max no. of patters is 2 * 4 - 1 = 7.

The values are BCD (binary-coded decimals) and not hex, so patterns
using a dash seem to be safe regardless of locale collation order.

The patch changes bcdDevice part of the alias from dlXdhY to dZ, but
this shouldn't have big compatibility issues because fnmatch()-based
modprobing hasn't yet been widely used.  Besides, the most common (and
almost the only working) case of dl*dh* becomes d* and thus continues to
work.

The patch is against 2.6.12-rc2, applies to -mm3 with an offset.  The
matching patch to fix the MODALIAS environment variable now generated by
the usb hotplug function follows.

Signed-off-by: Roman Kagan <rkagan@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
scripts/mod/file2alias.c