Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174931
b: refs/heads/master
c: afe2dab
h: refs/heads/master
i:
  174929: 9f1dff4
  174927: 74b96e0
v: v3
  • Loading branch information
Nathaniel McCallum authored and Greg Kroah-Hartman committed Dec 11, 2009
1 parent 9c02db8 commit 39de071
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c1479a92cf0a7792298d364e44a781550621cb58
refs/heads/master: afe2dab4f6d32d5650aaba42f2c7ec9c0622f4dd
48 changes: 36 additions & 12 deletions trunk/scripts/mod/file2alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void device_id_check(const char *modname, const char *device_id,
static void do_usb_entry(struct usb_device_id *id,
unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
unsigned char range_lo, unsigned char range_hi,
struct module *mod)
unsigned char max, struct module *mod)
{
char alias[500];
strcpy(alias, "usb:");
Expand All @@ -118,9 +118,22 @@ static void do_usb_entry(struct usb_device_id *id,
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 > 0 || range_hi < max) {
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_lo);
}
}
if (bcdDevice_initial_digits < (sizeof(id->bcdDevice_lo) * 2 - 1))
strcat(alias, "*");

Expand Down Expand Up @@ -150,7 +163,7 @@ static void do_usb_entry(struct usb_device_id *id,
static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
{
unsigned int devlo, devhi;
unsigned char chi, clo;
unsigned char chi, clo, max;
int ndigits;

id->match_flags = TO_NATIVE(id->match_flags);
Expand All @@ -162,6 +175,17 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
devhi = id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI ?
TO_NATIVE(id->bcdDevice_hi) : ~0x0U;

/* Figure out if this entry is in bcd or hex format */
max = 0x9; /* Default to decimal format */
for (ndigits = 0 ; ndigits < sizeof(id->bcdDevice_lo) * 2 ; ndigits++) {
clo = (devlo >> (ndigits << 2)) & 0xf;
chi = ((devhi > 0x9999 ? 0x9999 : devhi) >> (ndigits << 2)) & 0xf;
if (clo > max || chi > max) {
max = 0xf;
break;
}
}

/*
* Some modules (visor) have empty slots as placeholder for
* run-time specification that results in catch-all alias
Expand All @@ -173,21 +197,21 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
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;
if (chi > max) /* If we are in bcd mode, truncate if necessary */
chi = max;
devlo >>= 4;
devhi >>= 4;

if (devlo == devhi || !ndigits) {
do_usb_entry(id, devlo, ndigits, clo, chi, mod);
do_usb_entry(id, devlo, ndigits, clo, chi, max, mod);
break;
}

if (clo > 0)
do_usb_entry(id, devlo++, ndigits, clo, 9, mod);
if (clo > 0x0)
do_usb_entry(id, devlo++, ndigits, clo, max, max, mod);

if (chi < 9)
do_usb_entry(id, devhi--, ndigits, 0, chi, mod);
if (chi < max)
do_usb_entry(id, devhi--, ndigits, 0x0, chi, max, mod);
}
}

Expand Down

0 comments on commit 39de071

Please sign in to comment.