Compare commits
No commits in common. "0119ab3d6c1e17881ce9686221c7cbc650940953" and "7f16ef9fba3ba16c66452ca1d96c6c68cc8ebe3e" have entirely different histories.
0119ab3d6c
...
7f16ef9fba
|
@ -36,16 +36,6 @@
|
|||
usb:v058Fp9540*
|
||||
ID_AUTOSUSPEND=1
|
||||
|
||||
#########################################
|
||||
# QEMU
|
||||
#########################################
|
||||
|
||||
# Emulated USB HID devices
|
||||
usb:v0627p0001:*QEMU USB Keyboard*
|
||||
usb:v0627p0001:*QEMU USB Mouse*
|
||||
usb:v0627p0001:*QEMU USB Tablet*
|
||||
ID_AUTOSUSPEND=1
|
||||
|
||||
#########################################
|
||||
# Wacom
|
||||
#########################################
|
||||
|
|
|
@ -79,9 +79,6 @@ GENERAL_MATCHES = {'acpi',
|
|||
'OUI',
|
||||
}
|
||||
|
||||
def upperhex_word(length):
|
||||
return Word(nums + 'ABCDEF', exact=length)
|
||||
|
||||
@lru_cache()
|
||||
def hwdb_grammar():
|
||||
ParserElement.setDefaultWhitespaceChars('')
|
||||
|
@ -90,7 +87,7 @@ def hwdb_grammar():
|
|||
for category, conn in TYPES.items())
|
||||
|
||||
matchline_typed = Combine(prefix + Word(printables + ' ' + '®'))
|
||||
matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®'))
|
||||
matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables))
|
||||
matchline = (matchline_typed | matchline_general) + EOL
|
||||
|
||||
propertyline = (White(' ', exact=1).suppress() +
|
||||
|
@ -183,27 +180,8 @@ def parse(fname):
|
|||
return []
|
||||
return [convert_properties(g) for g in parsed.GROUPS]
|
||||
|
||||
def check_matches(groups):
|
||||
def check_match_uniqueness(groups):
|
||||
matches = sum((group[0] for group in groups), [])
|
||||
|
||||
# This is a partial check. The other cases could be also done, but those
|
||||
# two are most commonly wrong.
|
||||
grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4)),
|
||||
'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8)),
|
||||
}
|
||||
|
||||
for match in matches:
|
||||
prefix, rest = match.split(':', maxsplit=1)
|
||||
gr = grammars.get(prefix)
|
||||
if gr:
|
||||
try:
|
||||
gr.parseString(rest)
|
||||
except ParseBaseException as e:
|
||||
error('Pattern {!r} is invalid: {}', rest, e)
|
||||
continue
|
||||
if rest[-1] not in '*:':
|
||||
error('pattern {} does not end with "*" or ":"', match)
|
||||
|
||||
matches.sort()
|
||||
prev = None
|
||||
for match in matches:
|
||||
|
@ -278,7 +256,7 @@ if __name__ == '__main__':
|
|||
for fname in args:
|
||||
groups = parse(fname)
|
||||
print_summary(fname, groups)
|
||||
check_matches(groups)
|
||||
check_match_uniqueness(groups)
|
||||
check_properties(groups)
|
||||
|
||||
sys.exit(ERROR)
|
||||
|
|
|
@ -47,7 +47,7 @@ int udev_builtin_hwdb_lookup(sd_device *dev,
|
|||
}
|
||||
|
||||
static const char *modalias_usb(sd_device *dev, char *s, size_t size) {
|
||||
const char *v, *p, *n = NULL;
|
||||
const char *v, *p;
|
||||
uint16_t vn, pn;
|
||||
|
||||
if (sd_device_get_sysattr_value(dev, "idVendor", &v) < 0)
|
||||
|
@ -58,16 +58,15 @@ static const char *modalias_usb(sd_device *dev, char *s, size_t size) {
|
|||
return NULL;
|
||||
if (safe_atoux16(p, &pn) < 0)
|
||||
return NULL;
|
||||
(void) sd_device_get_sysattr_value(dev, "product", &n);
|
||||
|
||||
snprintf(s, size, "usb:v%04Xp%04X:%s", vn, pn, strempty(n));
|
||||
snprintf(s, size, "usb:v%04Xp%04X*", vn, pn);
|
||||
return s;
|
||||
}
|
||||
|
||||
static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
|
||||
const char *subsystem, const char *prefix,
|
||||
const char *filter, bool test) {
|
||||
char s[LINE_MAX];
|
||||
sd_device *d;
|
||||
char s[16];
|
||||
bool last = false;
|
||||
int r = 0;
|
||||
|
||||
|
@ -76,7 +75,7 @@ static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
|
|||
if (!srcdev)
|
||||
srcdev = dev;
|
||||
|
||||
for (sd_device *d = srcdev; d; ) {
|
||||
for (d = srcdev; d; ) {
|
||||
const char *dsubsys, *devtype, *modalias = NULL;
|
||||
|
||||
if (sd_device_get_subsystem(d, &dsubsys) < 0)
|
||||
|
@ -102,8 +101,6 @@ static int udev_builtin_hwdb_search(sd_device *dev, sd_device *srcdev,
|
|||
if (!modalias)
|
||||
goto next;
|
||||
|
||||
log_device_debug(dev, "hwdb modalias key: \"%s\"", modalias);
|
||||
|
||||
r = udev_builtin_hwdb_lookup(dev, prefix, modalias, filter, test);
|
||||
if (r > 0)
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,7 @@ for entry in chromiumos.gen_autosuspend_rules.PCI_IDS:
|
|||
device = int(device, 16)
|
||||
print('pci:v{:08X}d{:08X}*'.format(vendor, device))
|
||||
|
||||
print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice)')
|
||||
print('# usb:v<VEND>p<PROD> (4 uppercase hexadecimal digits twice')
|
||||
for entry in chromiumos.gen_autosuspend_rules.USB_IDS:
|
||||
vendor, product = entry.split(':')
|
||||
vendor = int(vendor, 16)
|
||||
|
|
Loading…
Reference in New Issue