I recently opened this Debian bug, for which I attach a
patch that seems to work. Bug report quoted in full below.
I would appreciate udev maintainers' opinions on whether this is
likely to break non-USB devices, or whether there is a better way
to do it.
S
Steps to reproduce: plug in a USB device which isn't in the udev
hwdb, like this one:
Bus 003 Device 017: ID 21b4:0081
Device Descriptor:
bLength18
bDescriptorType 1
bcdUSB 1.00
bDeviceClass0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x21b4
idProduct 0x0081
bcdDevice1.20
iManufacturer 1 AudioQuest inc.
iProduct2 AudioQuest DragonFly
iSerial 3 (C) 2013 Wavelength Audio, ltd.
(Yes I know that's a weird serial number, I didn't design the device.)
Expected result:
* ID_MODEL_FROM_DATABASE and ID_VENDOR_FROM_DATABASE are missing
* Interested applications can look up those properties using
idVendor and idProduct if they want to
Actual result: those strings are taken from the parent device,
an Intel Corp. Integrated Rate Matching Hub (vendor 8087, product 0024):
P: /devices/pci:00/:00:1a.0/usb3/3-1/3-1.2/3-1.2:1.0/sound/card1
E:
DEVPATH=/devices/pci:00/:00:1a.0/usb3/3-1/3-1.2/3-1.2:1.0/sound/card1
E: ID_BUS=usb
E: ID_FOR_SEAT=sound-pci-_00_1a_0-usb-0_1_2_1_0
E: ID_ID=usb-AudioQuest_inc._AudioQuest_DragonFly-00-DragonFly
E: ID_MODEL=AudioQuest_DragonFly
E: ID_MODEL_ENC=AudioQuest\x20DragonFly
E: ID_MODEL_FROM_DATABASE=Integrated Rate Matching Hub
E: ID_MODEL_ID=0081
E: ID_PATH=pci-:00:1a.0-usb-0:1.2:1.0
E: ID_PATH_TAG=pci-_00_1a_0-usb-0_1_2_1_0
E: ID_REVISION=0120
E: ID_SERIAL=AudioQuest_inc._AudioQuest_DragonFly
E: ID_TYPE=audio
E: ID_USB_DRIVER=snd-usb-audio
E: ID_USB_INTERFACES=:010100:010200:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=AudioQuest_inc.
E: ID_VENDOR_ENC=AudioQuest\x20inc.
E: ID_VENDOR_FROM_DATABASE=Intel Corp.
E: ID_VENDOR_ID=21b4
E: SOUND_INITIALIZED=1
E: SUBSYSTEM=sound
E: SYSTEMD_WANTS=sound.target
E: TAGS=:seat:systemd:
E: USEC_INITIALIZED=6479525776
This makes PulseAudio assign a silly name to this device, which shows
up in control UIs (e.g. Integrated Rate Matching Hub Analog Stereo in
pavucontrol and Analog Stereo - Integrated Rate Matching Hub in
gnome-control-center):
index: 1
name:
alsa_output.usb-AudioQuest_inc._AudioQuest_DragonFly-00-DragonFly.analog-stereo
...
card: 1
alsa_card.usb-AudioQuest_inc._AudioQuest_DragonFly-00-DragonFly
...
properties:
...
alsa.card_name = AudioQuest DragonFly
alsa.long_card_name = AudioQuest inc. AudioQuest DragonFly at
usb-:00:1a.0-1.2, full speed
...
udev.id =
usb-AudioQuest_inc._AudioQuest_DragonFly-00-DragonFly
device.bus = usb
device.vendor.id = 21b4
device.vendor.name = Intel Corp.
device.product.id = 0081
device.product.name = Integrated Rate Matching Hub
device.serial = AudioQuest_inc._AudioQuest_DragonFly
...
device.profile.name = analog-stereo
device.profile.description = Analog Stereo
device.description = Integrated Rate Matching Hub Analog
Stereo
From e0bb1d9cf82e397b08335e5d7107a8506849e823 Mon Sep 17 00:00:00 2001
From: Simon McVittie simon.mcvit...@collabora.co.uk
Date: Thu, 14 Aug 2014 14:05:45 +0100
Subject: [PATCH] hwdb: stop looking at parent devices if the modalias changes
This avoids claiming that an unrecognised USB device is an Intel USB
hub, just because it happens to be plugged into an Intel USB hub.
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=758050
---
src/udev/udev-builtin-hwdb.c | 11 +++
1 file changed, 11 insertions(+)
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c
index cac97e7..ac8d2e3 100644
--- a/src/udev/udev-builtin-hwdb.c
+++ b/src/udev/udev-builtin-hwdb.c
@@ -89,6 +89,7 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
struct udev_device *d;
char s[16];
int n = 0;
+char found_modalias[16] = { 0 };
for (d = srcdev; d; d = udev_device_get_parent(d)) {
const char *dsubsys;
@@ -111,6 +112,16 @@ static int udev_builtin_hwdb_search(struct udev_device *dev, struct udev_device
if (!modalias)
continue;
+/* if we already found a device with a vendor:product
+ * and this device has a different vendor:product, stop -
+ * this avoids matching the hub to which a USB device is
+ * attached */
+if (found_modalias[0]