aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-03-27 16:05:31 -0500
committerAleksander Morgado <aleksander@lanedo.com>2013-03-28 20:06:53 +0100
commit2bbe2f83275e04c44f7fb46102d40871ae505603 (patch)
treedaa9ba1b46054123e4126d7839b44f9026e55535
parente33fc37ec2e7574bf74ae60496fe3c1ed2ff0e3a (diff)
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.
-rw-r--r--src/mm-device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mm-device.c b/src/mm-device.c
index a37b26d5..78004395 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -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;
}