• Roman Kagan's avatar
    [PATCH] USB: scripts/mod/file2alias.c: handle numeric ranges for USB bcdDevice · b19dcd93
    Roman Kagan authored
    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: default avatarRoman Kagan <rkagan@mail.ru>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    
    b19dcd93
file2alias.c 11.6 KB