From 1a37237e2ffe6dfe142224a9d9e8b24135e93244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Jan 2022 10:39:53 +0100 Subject: [PATCH 1/4] hwdb: fix check for uppercasedness of match patterns The check was added in 77547d5313ea916d2fb64ca5a8812734e9b50f92, but it doesn't work as expected. Because the second part is wrapped in Optional(), it would silently "succeed" when the lowercase digits were in the second part: >>> from parse_hwdb import * >>> g = 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4)) >>> g.parseString('v04D8pE11C*') (['v', '04D8', 'p', 'E11C'], {}) >>> g.parseString('v04D8pe11c*') (['v', '04D8'], {}) The following matches are OK: usb:v0627p0001:*QEMU USB Keyboard* usb:v0627p0001:* usb:v0627p0001* usb:v0627* --- hwdb.d/parse_hwdb.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index 941adf28f7..0268bf9580 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -212,21 +212,23 @@ def check_matches(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)), + grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4) + Optional(':')) + '*', + 'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8) + Optional(':')) + '*', } for match in matches: prefix, rest = match.split(':', maxsplit=1) gr = grammars.get(prefix) if gr: + # we check this first to provide an easy error message + if rest[-1] not in '*:': + error('pattern {} does not end with "*" or ":"', match) + 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 From cc1746bbedb3c508cb39ce9c299f4f098bebb1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Jan 2022 10:47:57 +0100 Subject: [PATCH 2/4] hwdb: make usb match patterns uppercase Those patterns were always supposed to be uppercase. --- hwdb.d/70-analyzers.hwdb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwdb.d/70-analyzers.hwdb b/hwdb.d/70-analyzers.hwdb index 4865f0b669..1c56bd6e9f 100644 --- a/hwdb.d/70-analyzers.hwdb +++ b/hwdb.d/70-analyzers.hwdb @@ -12,7 +12,7 @@ # Total Phase ########################################################### # Aarvark I2C/SPI Host Adapter -usb:v0403pe0d0* +usb:v0403pE0D0* ID_SIGNAL_ANALYZER=1 # Beagle Protocol Analyzers @@ -29,5 +29,5 @@ usb:v1679p3001* # Power Delivery Analyzers usb:v1679p6003* -usb:v0483pdf11* +usb:v0483pDF11* ID_SIGNAL_ANALYZER=1 From ba5b19ef4d68e2e1cdc578b090e7450d3056b45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Jan 2022 10:48:16 +0100 Subject: [PATCH 3/4] Revert "udev: Import hwdb matches for USB devices" This reverts commit 94cb45d57f6e94dd4c93bd4706f9be70634bf03f. This rule set up a duplicate import: $ udevadm test /devices/pci0000:00/0000:00:14.0/usb2/2-4/2-4.1/2-4.1.3 ... 2-4.1.3: /usr/lib/udev/rules.d/40-libgphoto2.rules:9 Importing properties from results of builtin command 'usb_id' 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Skipping builtin 'usb_id' in IMPORT key 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:13 Importing properties from results of builtin command 'hwdb --subsystem=usb' 2-4.1.3: hwdb modalias key: "usb:v17EFp3054:OneLink+ Giga" 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Importing properties from results of builtin command 'hwdb 'usb:v17efp3054'' 2-4.1.3: No entry found from hwdb. 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:15 Failed to run builtin 'hwdb 'usb:v17efp3054'': No data available 2-4.1.3: /usr/lib/udev/rules.d/50-udev-default.rules:52 MODE 0664 except that the existing one was done with uppercase digits and the full match pattern, and the second one was done with lowercase digits. With the previous commit we only have uppercase digits in our match patterns, so we can drop the duplicate import. (Some other projects might have rules that used the lowercase match patterns, and people might have some local rules that did that too. But the second import was only added recently so I think it's better to rip off the bandaid quickly.) --- rules.d/50-udev-default.rules.in | 1 - 1 file changed, 1 deletion(-) diff --git a/rules.d/50-udev-default.rules.in b/rules.d/50-udev-default.rules.in index 8fae58f115..685b59a78a 100644 --- a/rules.d/50-udev-default.rules.in +++ b/rules.d/50-udev-default.rules.in @@ -12,7 +12,6 @@ SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb" ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}" -SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="hwdb 'usb:v$attr{idVendor}p$attr{idProduct}'" ACTION!="add", GOTO="default_end" From f097f4ab896ea81e76b5764e218d7c644bfda199 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 3 Jan 2022 10:14:39 +0100 Subject: [PATCH 4/4] hwdb: Allow end-users root-less access to TL866 EPROM readers As is currently done in the upstream minipro tool: https://gitlab.com/DavidGriffith/minipro/-/tree/master/udev --- hwdb.d/70-analyzers.hwdb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hwdb.d/70-analyzers.hwdb b/hwdb.d/70-analyzers.hwdb index 1c56bd6e9f..899ece3a01 100644 --- a/hwdb.d/70-analyzers.hwdb +++ b/hwdb.d/70-analyzers.hwdb @@ -31,3 +31,14 @@ usb:v1679p3001* usb:v1679p6003* usb:v0483pDF11* ID_SIGNAL_ANALYZER=1 + +########################################################### +# XGecu +########################################################### +# TL866A/CS +usb:v04D8pE11C* + ID_SIGNAL_ANALYZER=1 + +# TL866II+ +usb:vA466p0A53* + ID_SIGNAL_ANALYZER=1