Fall back to the udev parent if the vendor is unknown

This lets us get the correct vendor for NVMe devices.
This commit is contained in:
Richard Hughes 2018-09-04 15:09:38 +01:00
parent 2c0635ae55
commit e1c519299b

View File

@ -69,10 +69,9 @@ fu_udev_device_emit_changed (FuUdevDevice *self)
} }
static guint64 static guint64
fu_udev_device_get_sysfs_attr_as_uint64 (FuUdevDevice *self, const gchar *name) fu_udev_device_get_sysfs_attr_as_uint64 (GUdevDevice *udev_device, const gchar *name)
{ {
FuUdevDevicePrivate *priv = GET_PRIVATE (self); return fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name));
return fu_common_strtoull (g_udev_device_get_sysfs_attr (priv->udev_device, name));
} }
static guint16 static guint16
@ -93,9 +92,17 @@ fu_udev_device_probe (FuDevice *device, GError **error)
g_autofree gchar *subsystem = NULL; g_autofree gchar *subsystem = NULL;
/* set ven:dev:rev */ /* set ven:dev:rev */
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (self, "vendor"); priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "vendor");
priv->model = fu_udev_device_get_sysfs_attr_as_uint64 (self, "device"); priv->model = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "device");
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (self, "revision"); priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (priv->udev_device, "revision");
/* fallback to the parent */
if (priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0) {
g_autoptr(GUdevDevice) parent = g_udev_device_get_parent (priv->udev_device);
priv->vendor = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "vendor");
priv->model = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "device");
priv->revision = fu_udev_device_get_sysfs_attr_as_uint64 (parent, "revision");
}
/* hidraw helpfully encodes the information in a different place */ /* hidraw helpfully encodes the information in a different place */
if (priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0 && if (priv->vendor == 0x0 && priv->model == 0x0 && priv->revision == 0x0 &&