mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 00:25:30 +00:00
Use ID_VENDOR_ID and ID_MODEL_ID fallbacks
Some udev subsystems run probers to populate the values, rather than just the kernel providing the sysfs files. Support reading these too.
This commit is contained in:
parent
07ab0a61a2
commit
fa2df1eed6
@ -325,6 +325,21 @@ fu_udev_device_probe_serio(FuUdevDevice *self, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static guint16
|
||||||
|
fu_udev_device_get_property_as_uint16(GUdevDevice *udev_device, const gchar *key)
|
||||||
|
{
|
||||||
|
const gchar *tmp = g_udev_device_get_property(udev_device, key);
|
||||||
|
guint64 value = 0;
|
||||||
|
g_autofree gchar *str = NULL;
|
||||||
|
|
||||||
|
if (tmp == NULL)
|
||||||
|
return 0x0;
|
||||||
|
str = g_strdup_printf("0x%s", tmp);
|
||||||
|
if (!fu_strtoull(str, &value, 0x0, G_MAXUINT16, NULL))
|
||||||
|
return 0x0;
|
||||||
|
return (guint16)value;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fu_udev_device_set_vendor_from_udev_device(FuUdevDevice *self, GUdevDevice *udev_device)
|
fu_udev_device_set_vendor_from_udev_device(FuUdevDevice *self, GUdevDevice *udev_device)
|
||||||
{
|
{
|
||||||
@ -336,6 +351,14 @@ fu_udev_device_set_vendor_from_udev_device(FuUdevDevice *self, GUdevDevice *udev
|
|||||||
fu_udev_device_get_sysfs_attr_as_uint16(udev_device, "subsystem_vendor");
|
fu_udev_device_get_sysfs_attr_as_uint16(udev_device, "subsystem_vendor");
|
||||||
priv->subsystem_model =
|
priv->subsystem_model =
|
||||||
fu_udev_device_get_sysfs_attr_as_uint16(udev_device, "subsystem_device");
|
fu_udev_device_get_sysfs_attr_as_uint16(udev_device, "subsystem_device");
|
||||||
|
|
||||||
|
/* fallback to properties as udev might be using a subsystem-specific prober */
|
||||||
|
if (priv->vendor == 0x0)
|
||||||
|
priv->vendor = fu_udev_device_get_property_as_uint16(udev_device, "ID_VENDOR_ID");
|
||||||
|
if (priv->model == 0x0)
|
||||||
|
priv->model = fu_udev_device_get_property_as_uint16(udev_device, "ID_MODEL_ID");
|
||||||
|
if (priv->revision == 0x0)
|
||||||
|
priv->revision = fu_udev_device_get_property_as_uint16(udev_device, "ID_REVISION");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user