device: read PCI VID/PID
Nozomi devices are old Option NV CardBus devices with the ttys (nozX) hanging directly off the PCI device. We need to read the vendor and product IDs off them too. It appears that udev screws up the ID_MODEL_ID field (at least on F17, its set to the device path and not the PCI ID) so just skip looking at the TTY itself and read the PCI parent, where we're 100% sure to find the PCI IDs we want.
This commit is contained in:

committed by
Aleksander Morgado

parent
e33fc37ec2
commit
2bbe2f8327
@@ -119,6 +119,7 @@ get_device_ids (GUdevDevice *device,
|
||||
GUdevDevice *parent = NULL;
|
||||
const gchar *vid = NULL, *pid = NULL, *parent_subsys;
|
||||
gboolean success = FALSE;
|
||||
char *pci_vid = NULL, *pci_pid = NULL;
|
||||
|
||||
parent = g_udev_device_get_parent (device);
|
||||
if (parent) {
|
||||
@@ -154,6 +155,19 @@ get_device_ids (GUdevDevice *device,
|
||||
pid = g_udev_device_get_property (qmi_parent, "ID_MODEL_ID");
|
||||
g_object_unref (qmi_parent);
|
||||
}
|
||||
} else if (g_str_equal (parent_subsys, "pci")) {
|
||||
const char *pci_id;
|
||||
|
||||
/* We can't always rely on the model + vendor showing up on
|
||||
* the PCI device's child, so look at the PCI parent. PCI_ID
|
||||
* has the format "1931:000C".
|
||||
*/
|
||||
pci_id = g_udev_device_get_property (parent, "PCI_ID");
|
||||
if (pci_id && strlen (pci_id) == 9 && pci_id[4] == ':') {
|
||||
vid = pci_vid = g_strdup (pci_id);
|
||||
pci_vid[4] = '\0';
|
||||
pid = pci_pid = g_strdup (pci_id + 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,6 +211,8 @@ get_device_ids (GUdevDevice *device,
|
||||
out:
|
||||
if (parent)
|
||||
g_object_unref (parent);
|
||||
g_free (pci_vid);
|
||||
g_free (pci_pid);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user