diff options
author | Dan Williams <dcbw@redhat.com> | 2013-05-30 23:22:06 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-05-30 23:22:06 -0500 |
commit | a17ec278a6e2eb912dc7be9b7244c477bc653430 (patch) | |
tree | 7821cfb080e8874beb9bfc84a20b75235fbc482c | |
parent | 38a2dc71e7cf2a9c3eea07002da415c2c64a86fd (diff) |
core: 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.
Backport of 2bbe2f83275e04c44f7fb46102d40871ae505603
-rw-r--r-- | src/mm-plugin-base.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c index 636acf64..53376703 100644 --- a/src/mm-plugin-base.c +++ b/src/mm-plugin-base.c @@ -1203,6 +1203,7 @@ mm_plugin_base_get_device_ids (MMPluginBase *self, GUdevDevice *device = NULL, *parent = NULL; const char *vid = NULL, *pid = NULL, *parent_subsys; gboolean success = FALSE; + char *pci_vid = NULL, *pci_pid = NULL; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (MM_IS_PLUGIN_BASE (self), FALSE); @@ -1242,6 +1243,19 @@ mm_plugin_base_get_device_ids (MMPluginBase *self, /* Platform devices don't usually have a VID/PID */ success = TRUE; goto out; + } 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); + } } } } @@ -1287,6 +1301,8 @@ out: g_object_unref (device); if (parent) g_object_unref (parent); + g_free (pci_vid); + g_free (pci_pid); return success; } |