Allow devices to build instance IDs more easily

Provide a device instance builder that allows plugins to easily
create multiple instance IDs based on parent attributes.

Also fix a lot of the instance ID orders, so that we add more generic
IDs first, and more specific IDs after.
This commit is contained in:
Richard Hughes 2022-02-17 17:42:25 +00:00
parent de14bc6f0e
commit c4ca026294
47 changed files with 752 additions and 661 deletions

View File

@ -171,24 +171,19 @@ fu_bluez_device_set_modalias(FuBluezDevice *self, const gchar *modalias)
fu_firmware_strparse_uint16_safe(modalias, modaliaslen, 21, &rev, NULL); fu_firmware_strparse_uint16_safe(modalias, modaliaslen, 21, &rev, NULL);
} }
if (vid != 0x0 && pid != 0x0 && rev != 0x0) { /* add generated IDs */
g_autofree gchar *devid = NULL; if (vid != 0x0)
devid = g_strdup_printf("BLUETOOTH\\VID_%04X&PID_%04X&REV_%04X", vid, pid, rev); fu_device_add_instance_u16(FU_DEVICE(self), "VID", vid);
fu_device_add_instance_id(FU_DEVICE(self), devid); if (pid != 0x0)
} fu_device_add_instance_u16(FU_DEVICE(self), "PID", pid);
if (vid != 0x0 && pid != 0x0) { fu_device_add_instance_u16(FU_DEVICE(self), "REV", rev);
g_autofree gchar *devid = NULL; fu_device_build_instance_id_quirk(FU_DEVICE(self), NULL, "BLUETOOTH", "VID", NULL);
devid = g_strdup_printf("BLUETOOTH\\VID_%04X&PID_%04X", vid, pid); fu_device_build_instance_id(FU_DEVICE(self), NULL, "BLUETOOTH", "VID", "PID", NULL);
fu_device_add_instance_id(FU_DEVICE(self), devid); fu_device_build_instance_id(FU_DEVICE(self), NULL, "BLUETOOTH", "VID", "PID", "REV", NULL);
}
/* set vendor ID */
if (vid != 0x0) { if (vid != 0x0) {
g_autofree gchar *devid = NULL; g_autofree gchar *vendor_id = g_strdup_printf("BLUETOOTH:%04X", vid);
g_autofree gchar *vendor_id = NULL;
devid = g_strdup_printf("BLUETOOTH\\VID_%04X", vid);
fu_device_add_instance_id_full(FU_DEVICE(self),
devid,
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
vendor_id = g_strdup_printf("BLUETOOTH:%04X", vid);
fu_device_add_vendor_id(FU_DEVICE(self), vendor_id); fu_device_add_vendor_id(FU_DEVICE(self), vendor_id);
} }
} }

View File

@ -184,31 +184,19 @@ fu_cfi_device_probe(FuDevice *device, GError **error)
{ {
FuCfiDevice *self = FU_CFI_DEVICE(device); FuCfiDevice *self = FU_CFI_DEVICE(device);
FuCfiDevicePrivate *priv = GET_PRIVATE(self); FuCfiDevicePrivate *priv = GET_PRIVATE(self);
/* load the parameters from quirks */
if (priv->flash_id != NULL) {
g_autofree gchar *flash_id_jedec = NULL; g_autofree gchar *flash_id_jedec = NULL;
g_autofree gchar *instance_id0 = NULL;
g_autofree gchar *instance_id1 = NULL;
/* least specific so adding first */ /* least specific so adding first */
flash_id_jedec = fu_cfi_device_get_flash_id_jedec(self); flash_id_jedec = fu_cfi_device_get_flash_id_jedec(self);
if (flash_id_jedec != NULL) { if (flash_id_jedec != NULL) {
instance_id1 = g_strdup_printf("CFI\\FLASHID_%s", flash_id_jedec); fu_device_add_instance_str(device, "FLASHID", flash_id_jedec);
fu_device_add_instance_id_full(FU_DEVICE(self), if (!fu_device_build_instance_id_quirk(device, error, "CFI", "FLASHID", NULL))
instance_id1, return FALSE;
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
} }
/* this is most specific and can override keys of instance_id1 */ /* this is most specific and can override */
instance_id0 = g_strdup_printf("CFI\\FLASHID_%s", priv->flash_id); fu_device_add_instance_str(device, "FLASHID", priv->flash_id);
fu_device_add_instance_id_full(FU_DEVICE(self), return fu_device_build_instance_id_quirk(device, error, "CFI", "FLASHID", NULL);
instance_id0,
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
}
/* success */
return TRUE;
} }
/** /**

View File

@ -76,6 +76,7 @@ typedef struct {
GPtrArray *private_flag_items; /* (nullable) */ GPtrArray *private_flag_items; /* (nullable) */
gchar *custom_flags; gchar *custom_flags;
gulong notify_flags_handler_id; gulong notify_flags_handler_id;
GHashTable *instance_hash;
} FuDevicePrivate; } FuDevicePrivate;
typedef struct { typedef struct {
@ -4355,6 +4356,9 @@ fu_device_setup(FuDevice *self, GError **error)
return FALSE; return FALSE;
} }
/* no longer needed */
g_hash_table_remove_all(priv->instance_hash);
priv->done_setup = TRUE; priv->done_setup = TRUE;
return TRUE; return TRUE;
} }
@ -4735,6 +4739,269 @@ fu_device_flags_notify_cb(FuDevice *self, GParamSpec *pspec, gpointer user_data)
fu_device_ensure_inhibits(self); fu_device_ensure_inhibits(self);
} }
/**
* fu_device_add_instance_str:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: (nullable): value
*
* Assign a value for the @key.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_str(FuDevice *self, const gchar *key, const gchar *value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash, g_strdup(key), g_strdup(value));
}
/**
* fu_device_add_instance_strsafe:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: (nullable): value
*
* Assign a sanitized value for the @key.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_strsafe(FuDevice *self, const gchar *key, const gchar *value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash,
g_strdup(key),
fu_common_instance_id_strsafe(value));
}
/**
* fu_device_add_instance_strup:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: (nullable): value
*
* Assign a uppercase value for the @key.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_strup(FuDevice *self, const gchar *key, const gchar *value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash,
g_strdup(key),
value != NULL ? g_utf8_strup(value, -1) : NULL);
}
/**
* fu_device_add_instance_u4:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: value
*
* Assign a value to the @key, which is padded as %1X.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_u4(FuDevice *self, const gchar *key, guint8 value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash, g_strdup(key), g_strdup_printf("%01X", value));
}
/**
* fu_device_add_instance_u8:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: value
*
* Assign a value to the @key, which is padded as %2X.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_u8(FuDevice *self, const gchar *key, guint8 value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash, g_strdup(key), g_strdup_printf("%02X", value));
}
/**
* fu_device_add_instance_u16:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: value
*
* Assign a value to the @key, which is padded as %4X.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_u16(FuDevice *self, const gchar *key, guint16 value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash, g_strdup(key), g_strdup_printf("%04X", value));
}
/**
* fu_device_add_instance_u32:
* @self: a #FuDevice
* @key: (not nullable): string
* @value: value
*
* Assign a value to the @key, which is padded as %8X.
*
* Since: 1.7.7
**/
void
fu_device_add_instance_u32(FuDevice *self, const gchar *key, guint32 value)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
g_return_if_fail(FU_IS_DEVICE(self));
g_return_if_fail(key != NULL);
g_return_if_fail(!priv->done_setup);
g_hash_table_insert(priv->instance_hash, g_strdup(key), g_strdup_printf("%08X", value));
}
static const gchar *
fu_device_instance_lookup(FuDevice *self, const gchar *key)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
return g_hash_table_lookup(priv->instance_hash, key);
}
/**
* fu_device_build_instance_id:
* @self: a #FuDevice
* @error: (nullable): optional return location for an error
* @subsystem: (not nullable): subsystem, e.g. `NVME`
* @...: pairs of string key values, ending with %NULL
*
* Creates an instance ID from a prefix and some key values.
* If the key value cannot be found, the parent and then proxy is also queried.
*
* If any of the key values remain unset then no instance ID is added.
*
* fu_device_add_instance_str(dev, "VID", "1234");
* fu_device_add_instance_u16(dev, "PID", 5678);
* if (!fu_device_build_instance_id(dev, &error, "NVME", "VID", "PID", NULL))
* g_warning("failed to add ID: %s", error->message);
*
* Returns: %TRUE if the instance ID was added.
*
* Since: 1.7.7
**/
gboolean
fu_device_build_instance_id(FuDevice *self, GError **error, const gchar *subsystem, ...)
{
FuDevice *parent = fu_device_get_parent(self);
FuDevicePrivate *priv = GET_PRIVATE(self);
va_list args;
g_autoptr(GString) str = g_string_new(subsystem);
g_return_val_if_fail(FU_IS_DEVICE(self), FALSE);
g_return_val_if_fail(subsystem != NULL, FALSE);
g_return_val_if_fail(!priv->done_setup, FALSE);
va_start(args, subsystem);
for (guint i = 0;; i++) {
const gchar *key = va_arg(args, const gchar *);
const gchar *value;
if (key == NULL)
break;
value = fu_device_instance_lookup(self, key);
if (value == NULL && parent != NULL)
value = fu_device_instance_lookup(parent, key);
if (value == NULL && priv->proxy != NULL)
value = fu_device_instance_lookup(priv->proxy, key);
if (value == NULL) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no value for %s",
key);
return FALSE;
}
g_string_append(str, i == 0 ? "\\" : "&");
g_string_append_printf(str, "%s_%s", key, value);
}
va_end(args);
/* success */
fu_device_add_instance_id(self, str->str);
return TRUE;
}
/**
* fu_device_build_instance_id_quirk:
* @self: a #FuDevice
* @error: (nullable): optional return location for an error
* @subsystem: (not nullable): subsystem, e.g. `NVME`
* @...: pairs of string key values, ending with %NULL
*
* Creates an quirk-only instance ID from a prefix and some key values. If any of the key values
* are unset then no instance ID is added.
*
* Returns: %TRUE if the instance ID was added.
*
* Since: 1.7.7
**/
gboolean
fu_device_build_instance_id_quirk(FuDevice *self, GError **error, const gchar *subsystem, ...)
{
FuDevicePrivate *priv = GET_PRIVATE(self);
va_list args;
g_autoptr(GString) str = g_string_new(subsystem);
g_return_val_if_fail(FU_IS_DEVICE(self), FALSE);
g_return_val_if_fail(subsystem != NULL, FALSE);
g_return_val_if_fail(!priv->done_setup, FALSE);
va_start(args, subsystem);
for (guint i = 0;; i++) {
const gchar *key = va_arg(args, const gchar *);
const gchar *value;
if (key == NULL)
break;
value = g_hash_table_lookup(priv->instance_hash, key);
if (value == NULL) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"no value for %s",
key);
return FALSE;
}
g_string_append(str, i == 0 ? "\\" : "&");
g_string_append_printf(str, "%s_%s", key, value);
}
va_end(args);
/* success */
fu_device_add_instance_id_full(self, str->str, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
return TRUE;
}
static void static void
fu_device_class_init(FuDeviceClass *klass) fu_device_class_init(FuDeviceClass *klass)
{ {
@ -4929,6 +5196,7 @@ fu_device_init(FuDevice *self)
priv->parent_guids = g_ptr_array_new_with_free_func(g_free); priv->parent_guids = g_ptr_array_new_with_free_func(g_free);
priv->possible_plugins = g_ptr_array_new_with_free_func(g_free); priv->possible_plugins = g_ptr_array_new_with_free_func(g_free);
priv->retry_recs = g_ptr_array_new_with_free_func(g_free); priv->retry_recs = g_ptr_array_new_with_free_func(g_free);
priv->instance_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
g_rw_lock_init(&priv->parent_guids_mutex); g_rw_lock_init(&priv->parent_guids_mutex);
g_rw_lock_init(&priv->metadata_mutex); g_rw_lock_init(&priv->metadata_mutex);
priv->notify_flags_handler_id = g_signal_connect(FWUPD_DEVICE(self), priv->notify_flags_handler_id = g_signal_connect(FWUPD_DEVICE(self),
@ -4972,6 +5240,7 @@ fu_device_finalize(GObject *object)
g_free(priv->backend_id); g_free(priv->backend_id);
g_free(priv->proxy_guid); g_free(priv->proxy_guid);
g_free(priv->custom_flags); g_free(priv->custom_flags);
g_hash_table_unref(priv->instance_hash);
G_OBJECT_CLASS(fu_device_parent_class)->finalize(object); G_OBJECT_CLASS(fu_device_parent_class)->finalize(object);
} }

View File

@ -699,3 +699,22 @@ gboolean
fu_device_has_private_flag(FuDevice *self, guint64 flag); fu_device_has_private_flag(FuDevice *self, guint64 flag);
void void
fu_device_emit_request(FuDevice *self, FwupdRequest *request); fu_device_emit_request(FuDevice *self, FwupdRequest *request);
void
fu_device_add_instance_str(FuDevice *self, const gchar *key, const gchar *value);
void
fu_device_add_instance_strsafe(FuDevice *self, const gchar *key, const gchar *value);
void
fu_device_add_instance_strup(FuDevice *self, const gchar *key, const gchar *value);
void
fu_device_add_instance_u4(FuDevice *self, const gchar *key, guint8 value);
void
fu_device_add_instance_u8(FuDevice *self, const gchar *key, guint8 value);
void
fu_device_add_instance_u16(FuDevice *self, const gchar *key, guint16 value);
void
fu_device_add_instance_u32(FuDevice *self, const gchar *key, guint32 value);
gboolean
fu_device_build_instance_id(FuDevice *self, GError **error, const gchar *subsystem, ...);
gboolean
fu_device_build_instance_id_quirk(FuDevice *self, GError **error, const gchar *subsystem, ...);

View File

@ -128,13 +128,9 @@ fu_i2c_device_probe(FuDevice *device, GError **error)
#ifdef HAVE_GUDEV #ifdef HAVE_GUDEV
/* i2c devices all expose a name */ /* i2c devices all expose a name */
tmp = g_udev_device_get_sysfs_attr(udev_device, "name"); tmp = g_udev_device_get_sysfs_attr(udev_device, "name");
if (tmp != NULL) { fu_device_add_instance_strsafe(device, "NAME", tmp);
g_autofree gchar *name_safe = fu_common_instance_id_strsafe(tmp); if (!fu_device_build_instance_id(device, error, "I2C", "NAME", NULL))
if (name_safe != NULL) { return FALSE;
g_autofree gchar *devid = g_strdup_printf("I2C\\NAME_%s", name_safe);
fu_device_add_instance_id(FU_DEVICE(self), devid);
}
}
/* get bus number out of sysfs path */ /* get bus number out of sysfs path */
regex = g_regex_new("/i2c-([0-9]+)/", 0, 0, error); regex = g_regex_new("/i2c-([0-9]+)/", 0, 0, error);

View File

@ -300,15 +300,12 @@ fu_udev_device_probe_serio(FuUdevDevice *self, GError **error)
/* firmware ID */ /* firmware ID */
tmp = g_udev_device_get_property(priv->udev_device, "SERIO_FIRMWARE_ID"); tmp = g_udev_device_get_property(priv->udev_device, "SERIO_FIRMWARE_ID");
if (tmp != NULL) { if (tmp != NULL) {
g_autofree gchar *id_safe = NULL;
/* this prefix is not useful */ /* this prefix is not useful */
if (g_str_has_prefix(tmp, "PNP: ")) if (g_str_has_prefix(tmp, "PNP: "))
tmp += 5; tmp += 5;
id_safe = fu_common_instance_id_strsafe(tmp); fu_device_add_instance_strsafe(FU_DEVICE(self), "FWID", tmp);
if (id_safe != NULL) { if (!fu_device_build_instance_id(FU_DEVICE(self), error, "SERIO", "FWID", NULL))
g_autofree gchar *devid = g_strdup_printf("SERIO\\FWID_%s", id_safe); return FALSE;
fu_device_add_instance_id(FU_DEVICE(self), devid);
}
} }
return TRUE; return TRUE;
} }
@ -459,71 +456,37 @@ fu_udev_device_probe(FuDevice *device, GError **error)
} }
/* add GUIDs in order of priority */ /* add GUIDs in order of priority */
if (priv->vendor != 0x0000 && priv->model != 0x0000 && priv->subsystem_vendor != 0x0000 && if (priv->vendor != 0x0000)
priv->subsystem_model != 0x0000) { fu_device_add_instance_u16(device, "VEN", priv->vendor);
g_autofree gchar *devid1 = NULL; if (priv->model != 0x0000)
g_autofree gchar *devid2 = NULL; fu_device_add_instance_u16(device, "DEV", priv->model);
devid1 = g_strdup_printf("%s\\VEN_%04X&DEV_%04X&SUBSYS_%04X%04X&REV_%02X", if (priv->subsystem_vendor != 0x0000 && priv->subsystem_model != 0x0000) {
subsystem, g_autofree gchar *subsys =
priv->vendor, g_strdup_printf("%04X%04X", priv->subsystem_vendor, priv->subsystem_model);
priv->model, fu_device_add_instance_str(device, "SUBSYS", subsys);
priv->subsystem_vendor,
priv->subsystem_model,
priv->revision);
fu_device_add_instance_id(device, devid1);
devid2 = g_strdup_printf("%s\\VEN_%04X&DEV_%04X&SUBSYS_%04X%04X",
subsystem,
priv->vendor,
priv->model,
priv->subsystem_vendor,
priv->subsystem_model);
fu_device_add_instance_id(device, devid2);
}
if (priv->vendor != 0x0000 && priv->model != 0x0000) {
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("%s\\VEN_%04X&DEV_%04X&REV_%02X",
subsystem,
priv->vendor,
priv->model,
priv->revision);
fu_device_add_instance_id(device, devid);
}
if (priv->vendor != 0x0000 && priv->model != 0x0000) {
g_autofree gchar *devid = NULL;
devid =
g_strdup_printf("%s\\VEN_%04X&DEV_%04X", subsystem, priv->vendor, priv->model);
fu_device_add_instance_id(device, devid);
}
if (priv->vendor != 0x0000) {
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("%s\\VEN_%04X", subsystem, priv->vendor);
fu_device_add_instance_id_full(device, devid, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
} }
fu_device_add_instance_u8(device, "REV", priv->revision);
fu_device_build_instance_id_quirk(device, NULL, subsystem, "VEN", NULL);
fu_device_build_instance_id(device, NULL, subsystem, "VEN", "DEV", NULL);
fu_device_build_instance_id(device, NULL, subsystem, "VEN", "DEV", "REV", NULL);
fu_device_build_instance_id(device, NULL, subsystem, "VEN", "DEV", "SUBSYS", NULL);
fu_device_build_instance_id(device, NULL, subsystem, "VEN", "DEV", "SUBSYS", "REV", NULL);
/* add device class */ /* add device class */
tmp = g_udev_device_get_sysfs_attr(priv->udev_device, "class"); tmp = g_udev_device_get_sysfs_attr(priv->udev_device, "class");
if (tmp != NULL && g_str_has_prefix(tmp, "0x")) { if (tmp != NULL && g_str_has_prefix(tmp, "0x"))
g_autofree gchar *class_id = g_utf8_strup(tmp + 2, -1); tmp += 2;
g_autofree gchar *devid = NULL; fu_device_add_instance_strup(device, "CLASS", tmp);
devid = g_strdup_printf("%s\\VEN_%04X&CLASS_%s", subsystem, priv->vendor, class_id); fu_device_build_instance_id_quirk(device, NULL, subsystem, "VEN", "CLASS", NULL);
fu_device_add_instance_id_full(device, devid, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
}
/* add devtype */ /* add devtype */
tmp = g_udev_device_get_devtype(priv->udev_device); fu_device_add_instance_strup(device, "TYPE", g_udev_device_get_devtype(priv->udev_device));
if (tmp != NULL) { fu_device_build_instance_id_quirk(device, NULL, subsystem, "TYPE", NULL);
g_autofree gchar *devtype = g_utf8_strup(tmp, -1);
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("%s\\TYPE_%s", subsystem, devtype);
fu_device_add_instance_id_full(device, devid, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
}
/* add the driver */ /* add the driver */
if (priv->driver != NULL) { fu_device_add_instance_str(device, "DRIVER", priv->driver);
g_autofree gchar *devid = NULL; fu_device_build_instance_id_quirk(device, NULL, subsystem, "DRIVER", NULL);
devid = g_strdup_printf("%s\\DRIVER_%s", subsystem, priv->driver);
fu_device_add_instance_id_full(device, devid, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
}
/* add subsystem to match in plugins */ /* add subsystem to match in plugins */
if (subsystem != NULL) { if (subsystem != NULL) {

View File

@ -174,7 +174,6 @@ fu_usb_device_query_hub(FuUsbDevice *self, GError **error)
gsize sz = 0; gsize sz = 0;
guint16 value = 0x29; guint16 value = 0x29;
guint8 data[0x0c] = {0x0}; guint8 data[0x0c] = {0x0};
g_autofree gchar *devid = NULL;
/* longer descriptor for SuperSpeed */ /* longer descriptor for SuperSpeed */
if (fu_usb_device_get_spec(self) >= 0x0300) if (fu_usb_device_get_spec(self) >= 0x0300)
@ -200,20 +199,12 @@ fu_usb_device_query_hub(FuUsbDevice *self, GError **error)
/* see http://www.usblyzer.com/usb-hub-class-decoder.htm */ /* see http://www.usblyzer.com/usb-hub-class-decoder.htm */
if (sz == 0x09) { if (sz == 0x09) {
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&HUB_%02X", fu_device_add_instance_u8(FU_DEVICE(self), "HUB", data[7]);
g_usb_device_get_vid(priv->usb_device),
g_usb_device_get_pid(priv->usb_device),
data[7]);
fu_device_add_instance_id(FU_DEVICE(self), devid);
} else if (sz == 0x0c) { } else if (sz == 0x0c) {
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&HUB_%02X%02X", g_autofree gchar *hub = g_strdup_printf("%02X%02X", data[11], data[10]);
g_usb_device_get_vid(priv->usb_device), fu_device_add_instance_str(FU_DEVICE(self), "HUB", hub);
g_usb_device_get_pid(priv->usb_device),
data[11],
data[10]);
fu_device_add_instance_id(FU_DEVICE(self), devid);
} }
return TRUE; return fu_device_build_instance_id(FU_DEVICE(self), error, "VID", "PID", "HUB", NULL);
} }
#endif #endif
@ -395,9 +386,6 @@ fu_usb_device_probe(FuDevice *device, GError **error)
FuUsbDevice *self = FU_USB_DEVICE(device); FuUsbDevice *self = FU_USB_DEVICE(device);
FuUsbDevicePrivate *priv = GET_PRIVATE(self); FuUsbDevicePrivate *priv = GET_PRIVATE(self);
guint16 release; guint16 release;
g_autofree gchar *devid0 = NULL;
g_autofree gchar *devid1 = NULL;
g_autofree gchar *devid2 = NULL;
g_autofree gchar *platform_id = NULL; g_autofree gchar *platform_id = NULL;
g_autofree gchar *vendor_id = NULL; g_autofree gchar *vendor_id = NULL;
g_autoptr(GPtrArray) intfs = NULL; g_autoptr(GPtrArray) intfs = NULL;
@ -417,17 +405,12 @@ fu_usb_device_probe(FuDevice *device, GError **error)
} }
/* add GUIDs in order of priority */ /* add GUIDs in order of priority */
devid2 = g_strdup_printf("USB\\VID_%04X&PID_%04X&REV_%04X", fu_device_add_instance_u16(device, "VID", g_usb_device_get_vid(priv->usb_device));
g_usb_device_get_vid(priv->usb_device), fu_device_add_instance_u16(device, "PID", g_usb_device_get_pid(priv->usb_device));
g_usb_device_get_pid(priv->usb_device), fu_device_add_instance_u16(device, "REV", release);
release); fu_device_build_instance_id_quirk(device, NULL, "USB", "VID", NULL);
fu_device_add_instance_id(device, devid2); fu_device_build_instance_id(device, NULL, "USB", "VID", "PID", NULL);
devid1 = g_strdup_printf("USB\\VID_%04X&PID_%04X", fu_device_build_instance_id(device, NULL, "USB", "VID", "PID", "REV", NULL);
g_usb_device_get_vid(priv->usb_device),
g_usb_device_get_pid(priv->usb_device));
fu_device_add_instance_id(device, devid1);
devid0 = g_strdup_printf("USB\\VID_%04X", g_usb_device_get_vid(priv->usb_device));
fu_device_add_instance_id_full(device, devid0, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
/* add the interface GUIDs */ /* add the interface GUIDs */
intfs = g_usb_device_get_interfaces(priv->usb_device, error); intfs = g_usb_device_get_interfaces(priv->usb_device, error);
@ -435,20 +418,18 @@ fu_usb_device_probe(FuDevice *device, GError **error)
return FALSE; return FALSE;
for (guint i = 0; i < intfs->len; i++) { for (guint i = 0; i < intfs->len; i++) {
GUsbInterface *intf = g_ptr_array_index(intfs, i); GUsbInterface *intf = g_ptr_array_index(intfs, i);
g_autofree gchar *intid1 = NULL; fu_device_add_instance_u8(device, "CLASS", g_usb_interface_get_class(intf));
g_autofree gchar *intid2 = NULL; fu_device_add_instance_u8(device, "SUBCLASS", g_usb_interface_get_subclass(intf));
g_autofree gchar *intid3 = NULL; fu_device_add_instance_u8(device, "PROT", g_usb_interface_get_protocol(intf));
intid1 = g_strdup_printf("USB\\CLASS_%02X&SUBCLASS_%02X&PROT_%02X", fu_device_build_instance_id_quirk(device, NULL, "USB", "CLASS", NULL);
g_usb_interface_get_class(intf), fu_device_build_instance_id_quirk(device, NULL, "USB", "CLASS", "SUBCLASS", NULL);
g_usb_interface_get_subclass(intf), fu_device_build_instance_id_quirk(device,
g_usb_interface_get_protocol(intf)); NULL,
fu_device_add_instance_id_full(device, intid1, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS); "USB",
intid2 = g_strdup_printf("USB\\CLASS_%02X&SUBCLASS_%02X", "CLASS",
g_usb_interface_get_class(intf), "SUBCLASS",
g_usb_interface_get_subclass(intf)); "PROT",
fu_device_add_instance_id_full(device, intid2, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS); NULL);
intid3 = g_strdup_printf("USB\\CLASS_%02X", g_usb_interface_get_class(intf));
fu_device_add_instance_id_full(device, intid3, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
} }
/* add 2 levels of parent IDs */ /* add 2 levels of parent IDs */

View File

@ -1003,3 +1003,17 @@ LIBFWUPDPLUGIN_1.7.6 {
fu_udev_device_get_parent_with_subsystem; fu_udev_device_get_parent_with_subsystem;
local: *; local: *;
} LIBFWUPDPLUGIN_1.7.4; } LIBFWUPDPLUGIN_1.7.4;
LIBFWUPDPLUGIN_1.7.7 {
global:
fu_device_add_instance_str;
fu_device_add_instance_strsafe;
fu_device_add_instance_strup;
fu_device_add_instance_u16;
fu_device_add_instance_u32;
fu_device_add_instance_u4;
fu_device_add_instance_u8;
fu_device_build_instance_id;
fu_device_build_instance_id_quirk;
local: *;
} LIBFWUPDPLUGIN_1.7.6;

View File

@ -1335,7 +1335,6 @@ static gboolean
fu_ccgx_hpi_device_ensure_silicon_id(FuCcgxHpiDevice *self, GError **error) fu_ccgx_hpi_device_ensure_silicon_id(FuCcgxHpiDevice *self, GError **error)
{ {
guint8 buf[2] = {0x0}; guint8 buf[2] = {0x0};
g_autofree gchar *instance_id = NULL;
if (!fu_ccgx_hpi_device_reg_read(self, CY_PD_SILICON_ID, buf, sizeof(buf), error)) { if (!fu_ccgx_hpi_device_reg_read(self, CY_PD_SILICON_ID, buf, sizeof(buf), error)) {
g_prefix_error(error, "get silicon id error: "); g_prefix_error(error, "get silicon id error: ");
@ -1350,10 +1349,9 @@ fu_ccgx_hpi_device_ensure_silicon_id(FuCcgxHpiDevice *self, GError **error)
return FALSE; return FALSE;
/* add quirks */ /* add quirks */
instance_id = g_strdup_printf("CCGX\\SID_%04X", self->silicon_id); if (self->silicon_id != 0x0)
fu_device_add_instance_id_full(FU_DEVICE(self), fu_device_add_instance_u16(FU_DEVICE(self), "SID", self->silicon_id);
instance_id, fu_device_build_instance_id_quirk(FU_DEVICE(self), NULL, "CCGX", "SID", NULL);
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
/* sanity check */ /* sanity check */
if (self->flash_row_size == 0x0 || self->flash_size == 0x0 || if (self->flash_row_size == 0x0 || self->flash_size == 0x0 ||
@ -1361,8 +1359,7 @@ fu_ccgx_hpi_device_ensure_silicon_id(FuCcgxHpiDevice *self, GError **error)
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"invalid row size for Instance ID %s: 0x%x/0x%x", "invalid row size for: 0x%x/0x%x",
instance_id,
self->flash_row_size, self->flash_row_size,
self->flash_size); self->flash_size);
return FALSE; return FALSE;
@ -1380,36 +1377,6 @@ fu_ccgx_hpi_device_set_version_raw(FuCcgxHpiDevice *self, guint32 version_raw)
fu_device_set_version_raw(FU_DEVICE(self), version_raw); fu_device_set_version_raw(FU_DEVICE(self), version_raw);
} }
static void
fu_ccgx_hpi_device_setup_with_fw_mode(FuCcgxHpiDevice *self)
{
fu_device_set_logical_id(FU_DEVICE(self), fu_ccgx_fw_mode_to_string(self->fw_mode));
}
static void
fu_ccgx_hpi_device_setup_with_app_type(FuCcgxHpiDevice *self)
{
if (self->silicon_id != 0x0 && self->fw_app_type != 0x0) {
g_autofree gchar *instance_id1 = NULL;
g_autofree gchar *instance_id2 = NULL;
/* we get fw_image_type from the quirk */
instance_id1 = g_strdup_printf("USB\\VID_%04X&PID_%04X&SID_%04X&APP_%04X",
fu_usb_device_get_vid(FU_USB_DEVICE(self)),
fu_usb_device_get_pid(FU_USB_DEVICE(self)),
self->silicon_id,
self->fw_app_type);
fu_device_add_instance_id(FU_DEVICE(self), instance_id1);
instance_id2 = g_strdup_printf("USB\\VID_%04X&PID_%04X&SID_%04X&APP_%04X&MODE_%s",
fu_usb_device_get_vid(FU_USB_DEVICE(self)),
fu_usb_device_get_pid(FU_USB_DEVICE(self)),
self->silicon_id,
self->fw_app_type,
fu_ccgx_fw_mode_to_string(self->fw_mode));
fu_device_add_instance_id(FU_DEVICE(self), instance_id2);
}
}
static gboolean static gboolean
fu_ccgx_hpi_device_setup(FuDevice *device, GError **error) fu_ccgx_hpi_device_setup(FuDevice *device, GError **error)
{ {
@ -1442,7 +1409,8 @@ fu_ccgx_hpi_device_setup(FuDevice *device, GError **error)
self->hpi_addrsz = mode & 0x80 ? 2 : 1; self->hpi_addrsz = mode & 0x80 ? 2 : 1;
self->num_ports = (mode >> 2) & 0x03 ? 2 : 1; self->num_ports = (mode >> 2) & 0x03 ? 2 : 1;
self->fw_mode = (FWMode)(mode & 0x03); self->fw_mode = (FWMode)(mode & 0x03);
fu_ccgx_hpi_device_setup_with_fw_mode(self); fu_device_set_logical_id(device, fu_ccgx_fw_mode_to_string(self->fw_mode));
fu_device_add_instance_str(device, "MODE", fu_device_get_logical_id(device));
/* get silicon ID */ /* get silicon ID */
if (!fu_ccgx_hpi_device_ensure_silicon_id(self, error)) if (!fu_ccgx_hpi_device_ensure_silicon_id(self, error))
@ -1481,7 +1449,8 @@ fu_ccgx_hpi_device_setup(FuDevice *device, GError **error)
/* add GUIDs that are specific to the firmware app type */ /* add GUIDs that are specific to the firmware app type */
self->fw_app_type = versions[self->fw_mode] & 0xffff; self->fw_app_type = versions[self->fw_mode] & 0xffff;
fu_ccgx_hpi_device_setup_with_app_type(self); if (self->fw_app_type != 0x0)
fu_device_add_instance_u16(device, "APP", self->fw_app_type);
/* if running in bootloader force an upgrade to any version */ /* if running in bootloader force an upgrade to any version */
if (fu_device_has_flag(device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) { if (fu_device_has_flag(device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) {
@ -1498,6 +1467,18 @@ fu_ccgx_hpi_device_setup(FuDevice *device, GError **error)
fu_device_uninhibit(device, "device-in-boot-mode"); fu_device_uninhibit(device, "device-in-boot-mode");
} }
/* add extra instance IDs */
fu_device_build_instance_id_quirk(device, NULL, "USB", "VID", "PID", "SID", "APP", NULL);
fu_device_build_instance_id_quirk(device,
NULL,
"USB",
"VID",
"PID",
"SID",
"APP",
"MODE",
NULL);
/* if we are coming back from reset, wait for hardware to settle */ /* if we are coming back from reset, wait for hardware to settle */
if (!fu_ccgx_hpi_device_get_event(self, if (!fu_ccgx_hpi_device_get_event(self,
HPI_REG_SECTION_DEV, HPI_REG_SECTION_DEV,

View File

@ -41,12 +41,10 @@ fu_cfu_module_get_bank(FuCfuModule *self)
gboolean gboolean
fu_cfu_module_setup(FuCfuModule *self, const guint8 *buf, gsize bufsz, gsize offset, GError **error) fu_cfu_module_setup(FuCfuModule *self, const guint8 *buf, gsize bufsz, gsize offset, GError **error)
{ {
FuDevice *parent = fu_device_get_proxy(FU_DEVICE(self)); FuDevice *device = FU_DEVICE(self);
FuDevice *parent = fu_device_get_proxy(device);
guint32 version_raw = 0; guint32 version_raw = 0;
guint8 tmp = 0; guint8 tmp = 0;
g_autofree gchar *instance_id0 = NULL;
g_autofree gchar *instance_id1 = NULL;
g_autofree gchar *instance_id2 = NULL;
g_autofree gchar *logical_id = NULL; g_autofree gchar *logical_id = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
@ -55,48 +53,47 @@ fu_cfu_module_setup(FuCfuModule *self, const guint8 *buf, gsize bufsz, gsize off
return FALSE; return FALSE;
/* these GUIDs may cause the name or version-format to be overwritten */ /* these GUIDs may cause the name or version-format to be overwritten */
instance_id0 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X", fu_device_add_instance_u8(device, "CID", self->component_id);
fu_udev_device_get_vendor(FU_UDEV_DEVICE(parent)), if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", NULL))
fu_udev_device_get_model(FU_UDEV_DEVICE(parent))); return FALSE;
fu_device_add_instance_id(FU_DEVICE(self), instance_id0); if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", "CID", NULL))
instance_id1 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&CID_%02X", return FALSE;
fu_udev_device_get_vendor(FU_UDEV_DEVICE(parent)),
fu_udev_device_get_model(FU_UDEV_DEVICE(parent)),
self->component_id);
fu_device_add_instance_id(FU_DEVICE(self), instance_id1);
/* bank */ /* bank */
if (!fu_common_read_uint8_safe(buf, bufsz, offset + 0x4, &tmp, error)) if (!fu_common_read_uint8_safe(buf, bufsz, offset + 0x4, &tmp, error))
return FALSE; return FALSE;
self->bank = tmp & 0b11; self->bank = tmp & 0b11;
instance_id2 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&CID_%02X&BANK_%01X", fu_device_add_instance_u4(device, "BANK", self->bank);
fu_udev_device_get_vendor(FU_UDEV_DEVICE(parent)), if (!fu_device_build_instance_id(device,
fu_udev_device_get_model(FU_UDEV_DEVICE(parent)), error,
self->component_id, "HIDRAW",
self->bank); "VEN",
fu_device_add_instance_id(FU_DEVICE(self), instance_id2); "DEV",
"CID",
"BANK",
NULL))
return FALSE;
/* set name, if not already set using a quirk */ /* set name, if not already set using a quirk */
if (fu_device_get_name(FU_DEVICE(self)) == NULL) { if (fu_device_get_name(device) == NULL) {
g_autofree gchar *name = NULL; g_autofree gchar *name = NULL;
name = g_strdup_printf("%s (0x%02X:0x%02x)", name = g_strdup_printf("%s (0x%02X:0x%02x)",
fu_device_get_name(parent), fu_device_get_name(parent),
self->component_id, self->component_id,
self->bank); self->bank);
fu_device_set_name(FU_DEVICE(self), name); fu_device_set_name(device, name);
} }
/* version */ /* version */
if (!fu_common_read_uint32_safe(buf, bufsz, offset, &version_raw, G_LITTLE_ENDIAN, error)) if (!fu_common_read_uint32_safe(buf, bufsz, offset, &version_raw, G_LITTLE_ENDIAN, error))
return FALSE; return FALSE;
fu_device_set_version_raw(FU_DEVICE(self), version_raw); fu_device_set_version_raw(device, version_raw);
version = fu_common_version_from_uint32(version_raw, version = fu_common_version_from_uint32(version_raw, fu_device_get_version_format(device));
fu_device_get_version_format(FU_DEVICE(self))); fu_device_set_version(device, version);
fu_device_set_version(FU_DEVICE(self), version);
/* logical ID */ /* logical ID */
logical_id = g_strdup_printf("CID:0x%02x,BANK:0x%02x", self->component_id, self->bank); logical_id = g_strdup_printf("CID:0x%02x,BANK:0x%02x", self->component_id, self->bank);
fu_device_set_logical_id(FU_DEVICE(self), logical_id); fu_device_set_logical_id(device, logical_id);
/* success */ /* success */
return TRUE; return TRUE;

View File

@ -121,9 +121,6 @@ fu_cpu_device_add_instance_ids(FuDevice *device, GError **error)
guint32 model_id_ext; guint32 model_id_ext;
guint32 processor_id; guint32 processor_id;
guint32 stepping_id; guint32 stepping_id;
g_autofree gchar *devid1 = NULL;
g_autofree gchar *devid2 = NULL;
g_autofree gchar *devid3 = NULL;
/* decode according to https://en.wikipedia.org/wiki/CPUID */ /* decode according to https://en.wikipedia.org/wiki/CPUID */
if (!fu_common_cpuid(0x1, &eax, NULL, NULL, NULL, error)) if (!fu_common_cpuid(0x1, &eax, NULL, NULL, NULL, error))
@ -141,17 +138,16 @@ fu_cpu_device_add_instance_ids(FuDevice *device, GError **error)
if (family_id == 15) if (family_id == 15)
family_id += family_id_ext; family_id += family_id_ext;
devid1 = g_strdup_printf("CPUID\\PRO_%01X&FAM_%02X", processor_id, family_id); /* add GUIDs */
fu_device_add_instance_id(device, devid1); fu_device_add_instance_u4(device, "PRO", processor_id);
devid2 = fu_device_add_instance_u8(device, "FAM", family_id);
g_strdup_printf("CPUID\\PRO_%01X&FAM_%02X&MOD_%02X", processor_id, family_id, model_id); fu_device_add_instance_u8(device, "MOD", model_id);
fu_device_add_instance_id(device, devid2); fu_device_add_instance_u4(device, "STP", stepping_id);
devid3 = g_strdup_printf("CPUID\\PRO_%01X&FAM_%02X&MOD_%02X&STP_%01X", fu_device_build_instance_id(device, NULL, "CPUID", "PRO", "FAM", NULL);
processor_id, fu_device_build_instance_id(device, NULL, "CPUID", "PRO", "FAM", "MOD", NULL);
family_id, fu_device_build_instance_id(device, NULL, "CPUID", "PRO", "FAM", "MOD", "STP", NULL);
model_id,
stepping_id); /* success */
fu_device_add_instance_id(device, devid3);
return TRUE; return TRUE;
} }

View File

@ -531,10 +531,11 @@ fu_dfu_target_avr_setup(FuDfuTarget *target, GError **error)
} }
memcpy(&device_id_be, buf, 4); memcpy(&device_id_be, buf, 4);
priv->device_id = GINT32_FROM_BE(device_id_be); priv->device_id = GINT32_FROM_BE(device_id_be);
if (buf[0] == ATMEL_MANUFACTURER_CODE1) { if (buf[0] == ATMEL_MANUFACTURER_CODE1) {
chip_id_guid = g_strdup_printf("DFU_AVR\\CID_0x%08x", (guint)priv->device_id); chip_id_guid = g_strdup_printf("0x%08x", (guint)priv->device_id);
} else if (buf[0] == ATMEL_MANUFACTURER_CODE2) { } else if (buf[0] == ATMEL_MANUFACTURER_CODE2) {
chip_id_guid = g_strdup_printf("DFU_AVR\\CID_0x%06x", (guint)priv->device_id >> 8); chip_id_guid = g_strdup_printf("0x%06x", (guint)priv->device_id >> 8);
} else { } else {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
@ -549,7 +550,9 @@ fu_dfu_target_avr_setup(FuDfuTarget *target, GError **error)
/* set the alt-name using the chip ID via a quirk */ /* set the alt-name using the chip ID via a quirk */
device = fu_dfu_target_get_device(target); device = fu_dfu_target_get_device(target);
fu_device_add_instance_id(FU_DEVICE(device), chip_id_guid); fu_device_add_instance_str(FU_DEVICE(device), "CID", chip_id_guid);
if (!fu_device_build_instance_id(FU_DEVICE(device), error, "DFU_AVR", "CID", NULL))
return FALSE;
chip_id = fu_dfu_device_get_chip_id(device); chip_id = fu_dfu_device_get_chip_id(device);
if (chip_id == NULL) { if (chip_id == NULL) {
fu_dfu_device_remove_attribute(fu_dfu_target_get_device(target), fu_dfu_device_remove_attribute(fu_dfu_target_get_device(target),

View File

@ -161,9 +161,6 @@ fu_elantp_hid_device_setup(FuDevice *device, GError **error)
guint16 tmp; guint16 tmp;
guint8 buf[2] = {0x0}; guint8 buf[2] = {0x0};
guint8 ic_type; guint8 ic_type;
g_autofree gchar *instance_id1 = NULL;
g_autofree gchar *instance_id2 = NULL;
g_autofree gchar *instance_id_ic_type = NULL;
g_autofree gchar *version_bl = NULL; g_autofree gchar *version_bl = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
@ -212,11 +209,11 @@ fu_elantp_hid_device_setup(FuDevice *device, GError **error)
self->module_id = fu_common_read_uint16(buf, G_LITTLE_ENDIAN); self->module_id = fu_common_read_uint16(buf, G_LITTLE_ENDIAN);
/* define the extra instance IDs */ /* define the extra instance IDs */
instance_id1 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&MOD_%04X", fu_device_add_instance_u16(device, "VEN", fu_udev_device_get_vendor(udev_device));
fu_udev_device_get_vendor(udev_device), fu_device_add_instance_u16(device, "DEV", fu_udev_device_get_model(udev_device));
fu_udev_device_get_model(udev_device), fu_device_add_instance_u16(device, "MOD", self->module_id);
self->module_id); if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", "MOD", NULL))
fu_device_add_instance_id(device, instance_id1); return FALSE;
/* get OSM version */ /* get OSM version */
if (!fu_elantp_hid_device_read_cmd(self, if (!fu_elantp_hid_device_read_cmd(self,
@ -241,12 +238,11 @@ fu_elantp_hid_device_setup(FuDevice *device, GError **error)
} else { } else {
ic_type = (tmp >> 8) & 0xFF; ic_type = (tmp >> 8) & 0xFF;
} }
instance_id_ic_type = g_strdup_printf("ELANTP\\ICTYPE_%02X", ic_type);
fu_device_add_instance_id(device, instance_id_ic_type);
/* define the extra instance IDs (ic_type + module_id) */ /* define the extra instance IDs (ic_type + module_id) */
instance_id2 = g_strdup_printf("ELANTP\\ICTYPE_%02X&MOD_%04X", ic_type, self->module_id); fu_device_add_instance_u8(device, "ICTYPE", ic_type);
fu_device_add_instance_id(device, instance_id2); fu_device_build_instance_id(device, NULL, "ELANTP", "ICTYPE", NULL);
fu_device_build_instance_id(device, NULL, "ELANTP", "ICTYPE", "MOD", NULL);
/* no quirk entry */ /* no quirk entry */
if (self->ic_page_count == 0x0) { if (self->ic_page_count == 0x0) {

View File

@ -150,9 +150,6 @@ fu_elantp_i2c_device_setup(FuDevice *device, GError **error)
guint16 vid; guint16 vid;
guint8 buf[30] = {0x0}; guint8 buf[30] = {0x0};
guint8 ic_type; guint8 ic_type;
g_autofree gchar *instance_id1 = NULL;
g_autofree gchar *instance_id2 = NULL;
g_autofree gchar *instance_id_ic_type = NULL;
g_autofree gchar *version_bl = NULL; g_autofree gchar *version_bl = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
@ -178,11 +175,10 @@ fu_elantp_i2c_device_setup(FuDevice *device, GError **error)
} }
/* add GUIDs in order of priority */ /* add GUIDs in order of priority */
if (vid != 0x0 && pid != 0x0) { fu_device_add_instance_u16(device, "VID", vid);
g_autofree gchar *devid = NULL; fu_device_add_instance_u16(device, "PID", pid);
devid = g_strdup_printf("HIDRAW\\VID_%04X&PID_%04X", vid, pid); if (!fu_device_build_instance_id(device, error, "HIDRAW", "VID", "PID", NULL))
fu_device_add_instance_id(device, devid); return FALSE;
}
/* get pattern */ /* get pattern */
if (!fu_elantp_i2c_device_read_cmd(self, ETP_CMD_I2C_GET_HID_ID, buf, sizeof(buf), error)) { if (!fu_elantp_i2c_device_read_cmd(self, ETP_CMD_I2C_GET_HID_ID, buf, sizeof(buf), error)) {
@ -241,11 +237,14 @@ fu_elantp_i2c_device_setup(FuDevice *device, GError **error)
G_LITTLE_ENDIAN, G_LITTLE_ENDIAN,
error)) error))
return FALSE; return FALSE;
fu_device_add_instance_u16(device, "MOD", self->module_id);
/* define the extra instance IDs */ /* define the extra instance IDs */
instance_id1 = fu_device_add_instance_u16(device, "VEN", vid);
g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&MOD_%04X", vid, pid, self->module_id); fu_device_add_instance_u16(device, "DEV", pid);
fu_device_add_instance_id(device, instance_id1); fu_device_add_instance_u16(device, "MOD", self->module_id);
if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", "MOD", NULL))
return FALSE;
/* get OSM version */ /* get OSM version */
if (!fu_elantp_i2c_device_read_cmd(self, if (!fu_elantp_i2c_device_read_cmd(self,
@ -278,12 +277,11 @@ fu_elantp_i2c_device_setup(FuDevice *device, GError **error)
} else { } else {
ic_type = (tmp >> 8) & 0xFF; ic_type = (tmp >> 8) & 0xFF;
} }
instance_id_ic_type = g_strdup_printf("ELANTP\\ICTYPE_%02X", ic_type);
fu_device_add_instance_id(device, instance_id_ic_type);
/* define the extra instance IDs (ic_type + module_id) */ /* define the extra instance IDs (ic_type + module_id) */
instance_id2 = g_strdup_printf("ELANTP\\ICTYPE_%02X&MOD_%04X", ic_type, self->module_id); fu_device_add_instance_u8(device, "ICTYPE", ic_type);
fu_device_add_instance_id(device, instance_id2); fu_device_build_instance_id(device, NULL, "ELANTP", "ICTYPE", NULL);
fu_device_build_instance_id(device, NULL, "ELANTP", "ICTYPE", "MOD", NULL);
/* no quirk entry */ /* no quirk entry */
if (self->ic_page_count == 0x0) { if (self->ic_page_count == 0x0) {

View File

@ -139,9 +139,6 @@ fu_emmc_device_probe(FuDevice *device, GError **error)
guint64 manfid = 0; guint64 manfid = 0;
const gchar *tmp; const gchar *tmp;
g_autoptr(GUdevDevice) udev_parent = NULL; g_autoptr(GUdevDevice) udev_parent = NULL;
g_autofree gchar *name_only = NULL;
g_autofree gchar *man_oem = NULL;
g_autofree gchar *man_oem_name = NULL;
g_autofree gchar *vendor_id = NULL; g_autofree gchar *vendor_id = NULL;
g_autoptr(GRegex) dev_regex = NULL; g_autoptr(GRegex) dev_regex = NULL;
@ -206,23 +203,19 @@ fu_emmc_device_probe(FuDevice *device, GError **error)
fu_device_get_name(device)); fu_device_get_name(device));
return FALSE; return FALSE;
} }
fu_device_add_instance_strsafe(device, "NAME", tmp);
fu_device_build_instance_id(device, NULL, "EMMC", "NAME", NULL);
fu_device_set_name(device, tmp); fu_device_set_name(device, tmp);
name_only = g_strdup_printf("EMMC\\NAME_%s", fu_device_get_name(device));
fu_device_add_instance_id(device, name_only);
/* manfid + oemid, manfid + oemid + name */ /* manfid + oemid, manfid + oemid + name */
if (!fu_emmc_device_get_sysattr_guint64(udev_parent, "manfid", &manfid, error)) if (!fu_emmc_device_get_sysattr_guint64(udev_parent, "manfid", &manfid, error))
return FALSE; return FALSE;
if (!fu_emmc_device_get_sysattr_guint64(udev_parent, "oemid", &oemid, error)) if (!fu_emmc_device_get_sysattr_guint64(udev_parent, "oemid", &oemid, error))
return FALSE; return FALSE;
man_oem = fu_device_add_instance_u16(device, "MAN", manfid);
g_strdup_printf("EMMC\\%04" G_GUINT64_FORMAT "&%04" G_GUINT64_FORMAT, manfid, oemid); fu_device_add_instance_u16(device, "OEM", oemid);
fu_device_add_instance_id(device, man_oem); fu_device_build_instance_id(device, NULL, "EMMC", "MAN", "OEM", NULL);
man_oem_name = g_strdup_printf("EMMC\\MAN_%04X&OEM_%04X&NAME_%s", fu_device_build_instance_id(device, NULL, "EMMC", "MAN", "OEM", "NAME", NULL);
(guint)manfid,
(guint)oemid,
fu_device_get_name(device));
fu_device_add_instance_id(device, man_oem_name);
/* set the vendor */ /* set the vendor */
tmp = g_udev_device_get_sysfs_attr(udev_parent, "manfid"); tmp = g_udev_device_get_sysfs_attr(udev_parent, "manfid");

View File

@ -164,9 +164,7 @@ static gboolean
fu_fresco_pd_device_setup(FuDevice *device, GError **error) fu_fresco_pd_device_setup(FuDevice *device, GError **error)
{ {
FuFrescoPdDevice *self = FU_FRESCO_PD_DEVICE(device); FuFrescoPdDevice *self = FU_FRESCO_PD_DEVICE(device);
FuUsbDevice *usb_device = FU_USB_DEVICE(device);
guint8 ver[4] = {0x0}; guint8 ver[4] = {0x0};
g_autofree gchar *instance_id = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
/* FuUsbDevice->setup */ /* FuUsbDevice->setup */
@ -185,14 +183,10 @@ fu_fresco_pd_device_setup(FuDevice *device, GError **error)
/* get customer ID */ /* get customer ID */
self->customer_id = ver[1]; self->customer_id = ver[1];
instance_id = g_strdup_printf("USB\\VID_%04X&PID_%04X&CID_%02X",
fu_usb_device_get_vid(usb_device),
fu_usb_device_get_pid(usb_device),
self->customer_id);
fu_device_add_instance_id(device, instance_id);
/* success */ /* add extra instance ID */
return TRUE; fu_device_add_instance_u8(device, "CID", self->customer_id);
return fu_device_build_instance_id(device, error, "USB", "VID", "PID", "CID", NULL);
} }
static FuFirmware * static FuFirmware *

View File

@ -1402,8 +1402,6 @@ fu_genesys_scaler_device_probe(FuDevice *device, GError **error)
FuGenesysScalerDevice *self = FU_GENESYS_SCALER_DEVICE(device); FuGenesysScalerDevice *self = FU_GENESYS_SCALER_DEVICE(device);
guint8 buf[7 + 1] = {0}; guint8 buf[7 + 1] = {0};
g_autofree gchar *guid = NULL; g_autofree gchar *guid = NULL;
g_autofree gchar *guid_upper = NULL;
g_autofree gchar *instance_id = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
if (!fu_genesys_scaler_device_get_level(self, &self->level, error)) if (!fu_genesys_scaler_device_get_level(self, &self->level, error))
@ -1425,9 +1423,12 @@ fu_genesys_scaler_device_probe(FuDevice *device, GError **error)
fu_device_set_version(device, version); fu_device_set_version(device, version);
fu_device_set_version_format(device, FWUPD_VERSION_FORMAT_PLAIN); fu_device_set_version_format(device, FWUPD_VERSION_FORMAT_PLAIN);
fu_device_set_logical_id(device, "scaler"); fu_device_set_logical_id(device, "scaler");
guid_upper = g_ascii_strup(guid, -1);
instance_id = g_strdup_printf("GENESYS_SCALER\\MSTAR_TSUM_G&PUBKEY_%s", guid_upper); /* add instance ID */
fu_device_add_instance_id(device, instance_id); fu_device_add_instance_str(device, "MSTAR", "TSUM_G");
fu_device_add_instance_strup(device, "PUBKEY", guid);
fu_device_build_instance_id(device, NULL, "GENESYS_SCALER", "MSTAR", "PUBKEY", NULL);
fu_device_add_flag(device, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag(device, FWUPD_DEVICE_FLAG_UPDATABLE);
self->vc.req_read = GENESYS_SCALER_MSTAR_READ; self->vc.req_read = GENESYS_SCALER_MSTAR_READ;

View File

@ -68,10 +68,12 @@ fu_gpio_device_setup(FuDevice *device, GError **error)
/* label is optional, but name is always set */ /* label is optional, but name is always set */
if (info.label[0] != '\0') { if (info.label[0] != '\0') {
g_autofree gchar *logical_id = fu_common_strsafe(info.label, sizeof(info.label)); g_autofree gchar *logical_id = fu_common_strsafe(info.label, sizeof(info.label));
g_autofree gchar *instance_id = NULL;
fu_device_set_logical_id(device, logical_id); fu_device_set_logical_id(device, logical_id);
instance_id = g_strdup_printf("GPIO\\ID_%s", logical_id);
fu_device_add_instance_id(device, instance_id); /* add instance ID */
fu_device_add_instance_strsafe(device, "ID", logical_id);
if (!fu_device_build_instance_id(device, error, "GPIO", "ID", NULL))
return FALSE;
} }
/* success */ /* success */

View File

@ -42,20 +42,13 @@ fu_hailuck_bl_device_attach(FuDevice *device, FuProgress *progress, GError **err
static gboolean static gboolean
fu_hailuck_bl_device_probe(FuDevice *device, GError **error) fu_hailuck_bl_device_probe(FuDevice *device, GError **error)
{ {
g_autofree gchar *devid = NULL;
/* FuUsbDevice->probe */ /* FuUsbDevice->probe */
if (!FU_DEVICE_CLASS(fu_hailuck_bl_device_parent_class)->probe(device, error)) if (!FU_DEVICE_CLASS(fu_hailuck_bl_device_parent_class)->probe(device, error))
return FALSE; return FALSE;
/* add extra keyboard-specific GUID */ /* add instance ID */
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&MODE_KBD", fu_device_add_instance_str(device, "MODE", "KBD");
fu_usb_device_get_vid(FU_USB_DEVICE(device)), return fu_device_build_instance_id(device, error, "USB", "VID", "PID", "MODE", NULL);
fu_usb_device_get_pid(FU_USB_DEVICE(device)));
fu_device_add_instance_id(device, devid);
/* success */
return TRUE;
} }
static gboolean static gboolean

View File

@ -35,7 +35,6 @@ fu_hailuck_kbd_device_detach(FuDevice *device, FuProgress *progress, GError **er
static gboolean static gboolean
fu_hailuck_kbd_device_probe(FuDevice *device, GError **error) fu_hailuck_kbd_device_probe(FuDevice *device, GError **error)
{ {
g_autofree gchar *devid = NULL;
g_autoptr(FuHailuckTpDevice) tp_device = fu_hailuck_tp_device_new(FU_DEVICE(device)); g_autoptr(FuHailuckTpDevice) tp_device = fu_hailuck_tp_device_new(FU_DEVICE(device));
/* FuUsbDevice->probe */ /* FuUsbDevice->probe */
@ -43,10 +42,9 @@ fu_hailuck_kbd_device_probe(FuDevice *device, GError **error)
return FALSE; return FALSE;
/* add extra keyboard-specific GUID */ /* add extra keyboard-specific GUID */
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&MODE_KBD", fu_device_add_instance_str(device, "MODE", "KBD");
fu_usb_device_get_vid(FU_USB_DEVICE(device)), if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", "MODE", NULL))
fu_usb_device_get_pid(FU_USB_DEVICE(device))); return FALSE;
fu_device_add_instance_id(device, devid);
/* add touchpad */ /* add touchpad */
if (!fu_device_probe(FU_DEVICE(tp_device), error)) if (!fu_device_probe(FU_DEVICE(tp_device), error))

View File

@ -20,20 +20,9 @@ G_DEFINE_TYPE(FuHailuckTpDevice, fu_hailuck_tp_device, FU_TYPE_DEVICE)
static gboolean static gboolean
fu_hailuck_tp_device_probe(FuDevice *device, GError **error) fu_hailuck_tp_device_probe(FuDevice *device, GError **error)
{ {
FuDevice *parent = fu_device_get_parent(device); /* add extra touchpad-specific GUID */
g_autofree gchar *devid1 = NULL; fu_device_add_instance_str(device, "MODE", "TP");
g_autofree gchar *devid2 = NULL; return fu_device_build_instance_id(device, error, "USB", "VID", "PID", "MODE", NULL);
devid1 = g_strdup_printf("USB\\VID_%04X&PID_%04X",
fu_usb_device_get_vid(FU_USB_DEVICE(parent)),
fu_usb_device_get_pid(FU_USB_DEVICE(parent)));
fu_device_add_instance_id(device, devid1);
devid2 = g_strdup_printf("USB\\VID_%04X&PID_%04X&MODE_TP",
fu_usb_device_get_vid(FU_USB_DEVICE(parent)),
fu_usb_device_get_pid(FU_USB_DEVICE(parent)));
fu_device_add_instance_id(device, devid2);
return TRUE;
} }
typedef struct { typedef struct {

View File

@ -27,14 +27,14 @@ fu_ifd_device_set_region(FuIfdDevice *self, FuIfdRegion region)
FuIfdDevicePrivate *priv = GET_PRIVATE(self); FuIfdDevicePrivate *priv = GET_PRIVATE(self);
const gchar *region_str = fu_ifd_region_to_string(region); const gchar *region_str = fu_ifd_region_to_string(region);
g_autofree gchar *instance_id = NULL; g_autofree gchar *instance_id = NULL;
g_autofree gchar *region_str_up = NULL;
priv->region = region; priv->region = region;
fu_device_set_name(FU_DEVICE(self), fu_ifd_region_to_name(region)); fu_device_set_name(FU_DEVICE(self), fu_ifd_region_to_name(region));
fu_device_set_logical_id(FU_DEVICE(self), region_str); fu_device_set_logical_id(FU_DEVICE(self), region_str);
region_str_up = g_ascii_strup(region_str, -1);
instance_id = g_strdup_printf("IFD\\NAME_%s", region_str_up); /* add instance ID */
fu_device_add_instance_id(FU_DEVICE(self), instance_id); fu_device_add_instance_strup(FU_DEVICE(self), "NAME", region_str);
fu_device_build_instance_id(FU_DEVICE(self), NULL, "IFD", "NAME", NULL);
} }
static void static void

View File

@ -477,8 +477,6 @@ fu_intel_spi_device_set_quirk_kv(FuDevice *device,
return TRUE; return TRUE;
} }
if (g_strcmp0(key, "IntelSpiKind") == 0) { if (g_strcmp0(key, "IntelSpiKind") == 0) {
g_autofree gchar *instance_id = NULL;
g_autofree gchar *kind_up = NULL;
/* validate */ /* validate */
self->kind = fu_intel_spi_kind_from_string(value); self->kind = fu_intel_spi_kind_from_string(value);
@ -492,10 +490,8 @@ fu_intel_spi_device_set_quirk_kv(FuDevice *device,
} }
/* get things like SPIBAR */ /* get things like SPIBAR */
kind_up = g_ascii_strup(value, -1); fu_device_add_instance_strup(device, "ID", value);
instance_id = g_strdup_printf("INTEL_SPI_CHIPSET\\ID_%s", kind_up); return fu_device_build_instance_id(device, error, "INTEL_SPI_CHIPSET", "ID", NULL);
fu_device_add_instance_id(device, instance_id);
return TRUE;
} }
if (g_strcmp0(key, "IntelSpiBarProxy") == 0) { if (g_strcmp0(key, "IntelSpiBarProxy") == 0) {
self->spibar_proxy = g_strdup(value); self->spibar_proxy = g_strdup(value);

View File

@ -487,7 +487,6 @@ fu_logitech_hidpp_device_fetch_model_id(FuLogitechHidPpDevice *self, GError **er
{ {
FuLogitechHidPpDevicePrivate *priv = GET_PRIVATE(self); FuLogitechHidPpDevicePrivate *priv = GET_PRIVATE(self);
guint8 idx; guint8 idx;
g_autofree gchar *devid = NULL;
g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new(); g_autoptr(FuLogitechHidPpHidppMsg) msg = fu_logitech_hidpp_msg_new();
g_autoptr(GString) str = g_string_new(NULL); g_autoptr(GString) str = g_string_new(NULL);
@ -512,11 +511,9 @@ fu_logitech_hidpp_device_fetch_model_id(FuLogitechHidPpDevice *self, GError **er
fu_logitech_hidpp_device_set_model_id(self, str->str); fu_logitech_hidpp_device_set_model_id(self, str->str);
/* add one more instance ID */ /* add one more instance ID */
devid = g_strdup_printf("HIDRAW\\VEN_%04X&MOD_%s", fu_device_add_instance_u16(FU_DEVICE(self), "VEN", FU_UNIFYING_DEVICE_VID);
(guint)FU_UNIFYING_DEVICE_VID, fu_device_add_instance_str(FU_DEVICE(self), "MOD", priv->model_id);
priv->model_id); return fu_device_build_instance_id(FU_DEVICE(self), error, "HIDRAW", "VEN", "MOD", NULL);
fu_device_add_instance_id(FU_DEVICE(self), devid);
return TRUE;
} }
static gboolean static gboolean

View File

@ -359,7 +359,6 @@ fu_logitech_hidpp_runtime_bolt_setup_internal(FuDevice *device, GError **error)
guint16 version_raw = 0; guint16 version_raw = 0;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
g_autoptr(FuLogitechHidPpRadio) radio = NULL; g_autoptr(FuLogitechHidPpRadio) radio = NULL;
g_autofree gchar *instance_id = NULL;
g_autoptr(GString) radio_version = NULL; g_autoptr(GString) radio_version = NULL;
msg->report_id = HIDPP_REPORT_ID_SHORT; msg->report_id = HIDPP_REPORT_ID_SHORT;
@ -374,6 +373,7 @@ fu_logitech_hidpp_runtime_bolt_setup_internal(FuDevice *device, GError **error)
g_prefix_error(error, "failed to read device config: "); g_prefix_error(error, "failed to read device config: ");
return FALSE; return FALSE;
} }
switch (msg->data[0]) { switch (msg->data[0]) {
case 0: case 0:
/* main application */ /* main application */
@ -409,15 +409,26 @@ fu_logitech_hidpp_runtime_bolt_setup_internal(FuDevice *device, GError **error)
/* SoftDevice */ /* SoftDevice */
radio_version = g_string_new(NULL); radio_version = g_string_new(NULL);
radio = fu_logitech_hidpp_radio_new(ctx, i); radio = fu_logitech_hidpp_radio_new(ctx, i);
fu_device_add_instance_u16(
FU_DEVICE(radio),
"VEN",
fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)));
fu_device_add_instance_u16(
FU_DEVICE(radio),
"DEV",
fu_udev_device_get_model(FU_UDEV_DEVICE(device)));
fu_device_add_instance_u8(FU_DEVICE(radio), "ENT", msg->data[0]);
fu_device_set_physical_id(FU_DEVICE(radio), fu_device_set_physical_id(FU_DEVICE(radio),
fu_device_get_physical_id(device)); fu_device_get_physical_id(device));
fu_device_set_logical_id(FU_DEVICE(radio), "Receiver_SoftDevice"); fu_device_set_logical_id(FU_DEVICE(radio), "Receiver_SoftDevice");
if (!fu_device_build_instance_id(FU_DEVICE(radio),
instance_id = error,
g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&ENT_05", "HIDRAW",
fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)), "VEN",
fu_udev_device_get_model(FU_UDEV_DEVICE(device))); "DEV",
fu_device_add_guid(FU_DEVICE(radio), instance_id); "ENT",
NULL))
return FALSE;
if (!fu_common_read_uint16_safe(msg->data, if (!fu_common_read_uint16_safe(msg->data,
sizeof(msg->data), sizeof(msg->data),
0x03, 0x03,

View File

@ -69,13 +69,9 @@ fu_mtd_device_probe(FuDevice *device, GError **error)
FuContext *ctx = fu_device_get_context(device); FuContext *ctx = fu_device_get_context(device);
FuMtdDevice *self = FU_MTD_DEVICE(device); FuMtdDevice *self = FU_MTD_DEVICE(device);
const gchar *name; const gchar *name;
const gchar *product;
const gchar *vendor; const gchar *vendor;
guint64 flags = 0; guint64 flags = 0;
guint64 size = 0; guint64 size = 0;
g_autofree gchar *name_safe = NULL;
g_autofree gchar *product_safe = NULL;
g_autofree gchar *vendor_safe = NULL;
/* FuUdevDevice->probe */ /* FuUdevDevice->probe */
if (!FU_DEVICE_CLASS(fu_mtd_device_parent_class)->probe(device, error)) if (!FU_DEVICE_CLASS(fu_mtd_device_parent_class)->probe(device, error))
@ -87,44 +83,25 @@ fu_mtd_device_probe(FuDevice *device, GError **error)
/* get name */ /* get name */
name = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "name", NULL); name = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "name", NULL);
if (name != NULL) { if (name != NULL)
name_safe = fu_common_instance_id_strsafe(name);
if (name_safe != NULL) {
g_autofree gchar *devid = g_strdup_printf("MTD\\NAME_%s", name_safe);
fu_device_add_instance_id(FU_DEVICE(self), devid);
}
fu_device_set_name(FU_DEVICE(self), name); fu_device_set_name(FU_DEVICE(self), name);
}
/* set vendor ID as the BIOS vendor */ /* set vendor ID as the BIOS vendor */
vendor = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER); vendor = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER);
if (vendor != NULL) { if (vendor != NULL) {
g_autofree gchar *vendor_id = g_strdup_printf("DMI:%s", vendor); g_autofree gchar *vendor_id = g_strdup_printf("DMI:%s", vendor);
fu_device_add_vendor_id(device, vendor_id); fu_device_add_vendor_id(device, vendor_id);
vendor_safe = fu_common_instance_id_strsafe(vendor);
} }
/* use vendor and product as an optional instance ID prefix */ /* use vendor and product as an optional instance ID prefix */
product = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME); fu_device_add_instance_strsafe(device, "NAME", name);
if (product != NULL) fu_device_add_instance_strsafe(device, "VENDOR", vendor);
product_safe = fu_common_instance_id_strsafe(product); fu_device_add_instance_strsafe(device,
if (vendor_safe != NULL && product_safe != NULL && name_safe != NULL) { "PRODUCT",
g_autofree gchar *devid = NULL; fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME));
devid = g_strdup_printf("MTD\\VENDOR_%s&PRODUCT_%s&NAME_%s", fu_device_build_instance_id(device, NULL, "MTD", "NAME", NULL);
vendor_safe, fu_device_build_instance_id(device, NULL, "MTD", "VENDOR", "NAME", NULL);
product_safe, fu_device_build_instance_id(device, NULL, "MTD", "VENDOR", "PRODUCT", "NAME", NULL);
name_safe);
fu_device_add_instance_id(device, devid);
}
if (vendor_safe != NULL && name_safe != NULL) {
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("MTD\\VENDOR_%s&NAME_%s", vendor_safe, name_safe);
fu_device_add_instance_id(device, devid);
}
if (name_safe != NULL) {
g_autofree gchar *devid = g_strdup_printf("MTD\\NAME_%s", name_safe);
fu_device_add_instance_id(FU_DEVICE(self), devid);
}
/* get properties about the device */ /* get properties about the device */
if (!fu_udev_device_get_sysfs_attr_uint64(FU_UDEV_DEVICE(device), "size", &size, error)) if (!fu_udev_device_get_sysfs_attr_uint64(FU_UDEV_DEVICE(device), "size", &size, error))

View File

@ -936,7 +936,6 @@ static gboolean
fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error) fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error)
{ {
FuNordicHidCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device); FuNordicHidCfgChannel *self = FU_NORDIC_HID_CFG_CHANNEL(device);
g_autofree gchar *target_id = NULL;
/* get the board name */ /* get the board name */
if (!fu_nordic_hid_cfg_channel_get_board_name(self, error)) if (!fu_nordic_hid_cfg_channel_get_board_name(self, error))
@ -965,15 +964,17 @@ fu_nordic_hid_cfg_channel_setup(FuDevice *device, GError **error)
fu_device_set_name(device, physical_id); fu_device_set_name(device, physical_id);
} }
/* additional GUID based on VID/PID and target area to flash /* generate IDs */
* needed to distinguish images aimed to different bootloaders */ fu_device_add_instance_strsafe(device, "BOARD", self->board_name);
target_id = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&BOARD_%s&BL_%s", fu_device_add_instance_strsafe(device, "BL", self->bl_name);
fu_udev_device_get_vendor(FU_UDEV_DEVICE(device)), return fu_device_build_instance_id(device,
fu_udev_device_get_model(FU_UDEV_DEVICE(device)), error,
self->board_name, "HIDRAW",
self->bl_name); "VEN",
fu_device_add_guid(device, target_id); "DEV",
return TRUE; "BOARD",
"BL",
NULL);
} }
static void static void

View File

@ -121,19 +121,6 @@ fu_parade_lspcon_device_probe(FuDevice *device, GError **error)
FuContext *context = fu_device_get_context(device); FuContext *context = fu_device_get_context(device);
FuUdevDevice *udev_device = FU_UDEV_DEVICE(device); FuUdevDevice *udev_device = FU_UDEV_DEVICE(device);
const gchar *device_name; const gchar *device_name;
g_autofree gchar *instance_id_hwid = NULL;
g_autofree gchar *instance_id = NULL;
/* custom instance IDs to get device quirks */
instance_id = g_strdup_printf("PARADE-LSPCON\\NAME_%s",
fu_udev_device_get_sysfs_attr(udev_device, "name", NULL));
fu_device_add_instance_id(device, instance_id);
instance_id_hwid = g_strdup_printf("%s&FAMILY_%s",
instance_id,
fu_context_get_hwid_value(context, FU_HWIDS_KEY_FAMILY));
fu_device_add_instance_id_full(device,
instance_id_hwid,
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
device_name = fu_device_get_name(device); device_name = fu_device_get_name(device);
if (g_strcmp0(device_name, "PS175") != 0) { if (g_strcmp0(device_name, "PS175") != 0) {
@ -145,6 +132,17 @@ fu_parade_lspcon_device_probe(FuDevice *device, GError **error)
return FALSE; return FALSE;
} }
/* custom instance IDs to get device quirks */
fu_device_add_instance_str(device,
"NAME",
fu_udev_device_get_sysfs_attr(udev_device, "name", NULL));
fu_device_add_instance_str(device,
"FAMILY",
fu_context_get_hwid_value(context, FU_HWIDS_KEY_FAMILY));
if (!fu_device_build_instance_id(device, error, "PARADE-LSPCON", "NAME", NULL))
return FALSE;
fu_device_build_instance_id_quirk(device, NULL, "PARADE-LSPCON", "NAME", "FAMILY", NULL);
/* should know which aux device over which we read DPCD version */ /* should know which aux device over which we read DPCD version */
if (self->aux_device_name == NULL) { if (self->aux_device_name == NULL) {
g_set_error_literal(error, g_set_error_literal(error,

View File

@ -812,35 +812,32 @@ static gboolean
fu_pxi_ble_device_setup_guid(FuPxiBleDevice *self, GError **error) fu_pxi_ble_device_setup_guid(FuPxiBleDevice *self, GError **error)
{ {
#ifdef HAVE_HIDRAW_H #ifdef HAVE_HIDRAW_H
FuDevice *device = FU_DEVICE(self);
struct hidraw_devinfo hid_raw_info = {0x0}; struct hidraw_devinfo hid_raw_info = {0x0};
g_autofree gchar *devid = NULL;
g_autoptr(GString) dev_name = NULL; g_autoptr(GString) dev_name = NULL;
g_autoptr(GString) model_name = NULL;
/* extra GUID with device name */ /* extra GUID with device name */
if (!fu_pxi_ble_device_get_raw_info(self, &hid_raw_info, error)) if (!fu_pxi_ble_device_get_raw_info(self, &hid_raw_info, error))
return FALSE; return FALSE;
dev_name = g_string_new(fu_device_get_name(FU_DEVICE(self))); dev_name = g_string_new(fu_device_get_name(device));
g_string_ascii_up(dev_name); g_string_ascii_up(dev_name);
fu_common_string_replace(dev_name, " ", "_"); fu_common_string_replace(dev_name, " ", "_");
devid = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&NAME_%s",
(guint)hid_raw_info.vendor,
(guint)hid_raw_info.product,
dev_name->str);
fu_device_add_instance_id(FU_DEVICE(self), devid);
/* extra GUID with model name*/ /* extra GUID with model name*/
if (self->model_name != NULL) {
g_autofree gchar *devid2 = NULL;
g_autoptr(GString) model_name = NULL;
model_name = g_string_new(self->model_name); model_name = g_string_new(self->model_name);
g_string_ascii_up(model_name); g_string_ascii_up(model_name);
fu_common_string_replace(model_name, " ", "_"); fu_common_string_replace(model_name, " ", "_");
devid2 = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&MODEL_%s",
(guint)hid_raw_info.vendor, /* generate IDs */
(guint)hid_raw_info.product, fu_device_add_instance_u16(device, "VEN", hid_raw_info.vendor);
model_name->str); fu_device_add_instance_u16(device, "DEV", hid_raw_info.product);
fu_device_add_instance_id(FU_DEVICE(self), devid2); fu_device_add_instance_str(device, "NAME", dev_name->str);
} fu_device_add_instance_str(device, "MODEL", model_name->str);
if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", "NAME", NULL))
return FALSE;
if (!fu_device_build_instance_id(device, error, "HIDRAW", "VEN", "DEV", "MODEL", NULL))
return FALSE;
#endif #endif
return TRUE; return TRUE;
} }

View File

@ -725,7 +725,6 @@ fu_pxi_receiver_device_add_peripherals(FuPxiReceiverDevice *device, guint idx, G
{ {
#ifdef HAVE_HIDRAW_H #ifdef HAVE_HIDRAW_H
struct ota_fw_dev_model model = {0x0}; struct ota_fw_dev_model model = {0x0};
g_autofree gchar *instance_id = NULL;
g_autofree gchar *model_name = NULL; g_autofree gchar *model_name = NULL;
g_autofree gchar *model_version = NULL; g_autofree gchar *model_version = NULL;
@ -734,21 +733,38 @@ fu_pxi_receiver_device_add_peripherals(FuPxiReceiverDevice *device, guint idx, G
return FALSE; return FALSE;
model_version = g_strndup((gchar *)model.version, 5); model_version = g_strndup((gchar *)model.version, 5);
model_name = g_strndup((gchar *)model.name, FU_PXI_DEVICE_MODEL_NAME_LEN); model_name = g_strndup((gchar *)model.name, FU_PXI_DEVICE_MODEL_NAME_LEN);
instance_id = g_strdup_printf("HIDRAW\\VEN_%04X&DEV_%04X&MODEL_%s",
device->vendor,
device->product,
model_name);
if (model.type == OTA_WIRELESS_MODULE_TYPE_RECEIVER) { if (model.type == OTA_WIRELESS_MODULE_TYPE_RECEIVER) {
fu_device_set_version(FU_DEVICE(device), model_version); fu_device_set_version(FU_DEVICE(device), model_version);
fu_device_add_instance_id(FU_DEVICE(device), instance_id); fu_device_add_instance_u16(FU_DEVICE(device), "VEN", device->vendor);
fu_device_add_instance_u16(FU_DEVICE(device), "DEV", device->product);
fu_device_add_instance_str(FU_DEVICE(device), "MODEL", model_name);
if (!fu_device_build_instance_id(FU_DEVICE(device),
error,
"HIDRAW",
"VEN",
"DEV",
"MODEL",
NULL))
return FALSE;
} else { } else {
g_autoptr(FuPxiWirelessDevice) wireless_device = fu_pxi_wireless_device_new(&model); g_autoptr(FuPxiWirelessDevice) child = fu_pxi_wireless_device_new(&model);
g_autofree gchar *logical_id = g_strdup_printf("IDX:0x%02x", idx); g_autofree gchar *logical_id = g_strdup_printf("IDX:0x%02x", idx);
fu_device_add_instance_id(FU_DEVICE(wireless_device), instance_id); fu_device_add_instance_u16(FU_DEVICE(child), "VEN", device->vendor);
fu_device_set_name(FU_DEVICE(wireless_device), model_name); fu_device_add_instance_u16(FU_DEVICE(child), "DEV", device->product);
fu_device_set_version(FU_DEVICE(wireless_device), model_version); fu_device_add_instance_str(FU_DEVICE(child), "MODEL", model_name);
fu_device_set_logical_id(FU_DEVICE(wireless_device), logical_id); if (!fu_device_build_instance_id(FU_DEVICE(child),
fu_device_add_child(FU_DEVICE(device), FU_DEVICE(wireless_device)); error,
"HIDRAW",
"VEN",
"DEV",
"MODEL",
NULL))
return FALSE;
fu_device_set_name(FU_DEVICE(child), model_name);
fu_device_set_version(FU_DEVICE(child), model_version);
fu_device_set_logical_id(FU_DEVICE(child), logical_id);
fu_device_add_child(FU_DEVICE(device), FU_DEVICE(child));
} }
return TRUE; return TRUE;
#else #else

View File

@ -383,22 +383,20 @@ fu_realtek_mst_device_probe(FuDevice *device, GError **error)
{ {
FuRealtekMstDevice *self = FU_REALTEK_MST_DEVICE(device); FuRealtekMstDevice *self = FU_REALTEK_MST_DEVICE(device);
FuContext *context = fu_device_get_context(device); FuContext *context = fu_device_get_context(device);
const gchar *hardware_family = NULL;
const gchar *quirk_name = NULL; const gchar *quirk_name = NULL;
g_autofree gchar *family_instance_id = NULL;
g_autofree gchar *instance_id = NULL;
/* set custom instance ID and load matching quirks */ /* set custom instance ID and load matching quirks */
instance_id = fu_device_add_instance_str(
g_strdup_printf("REALTEK-MST\\NAME_%s", device,
"NAME",
fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "name", NULL)); fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "name", NULL));
fu_device_add_instance_id(device, instance_id); if (!fu_device_build_instance_id(device, error, "REALTEK-MST", "NAME", NULL))
return FALSE;
hardware_family = fu_context_get_hwid_value(context, FU_HWIDS_KEY_FAMILY); fu_device_add_instance_str(device,
family_instance_id = g_strdup_printf("%s&FAMILY_%s", instance_id, hardware_family); "FAMILY",
fu_device_add_instance_id_full(device, fu_context_get_hwid_value(context, FU_HWIDS_KEY_FAMILY));
family_instance_id, fu_device_build_instance_id_quirk(device, NULL, "REALTEK-MST", "NAME", "FAMILY", NULL);
FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
/* having loaded quirks, check this device is supported */ /* having loaded quirks, check this device is supported */
quirk_name = fu_device_get_name(device); quirk_name = fu_device_get_name(device);

View File

@ -66,7 +66,6 @@ fu_redfish_device_probe_related_pcie_item(FuRedfishDevice *self, const gchar *ur
{ {
FuRedfishDevicePrivate *priv = GET_PRIVATE(self); FuRedfishDevicePrivate *priv = GET_PRIVATE(self);
JsonObject *json_obj; JsonObject *json_obj;
const gchar *subsystem = "PCI";
guint64 vendor_id = 0x0; guint64 vendor_id = 0x0;
guint64 model_id = 0x0; guint64 model_id = 0x0;
guint64 subsystem_vendor_id = 0x0; guint64 subsystem_vendor_id = 0x0;
@ -133,25 +132,19 @@ fu_redfish_device_probe_related_pcie_item(FuRedfishDevice *self, const gchar *ur
} }
/* add more instance IDs if possible */ /* add more instance IDs if possible */
if (vendor_id != 0x0 && model_id != 0x0) { if (vendor_id != 0x0)
g_autofree gchar *devid1 = NULL; fu_device_add_instance_u16(FU_DEVICE(self), "VEN", vendor_id);
devid1 = g_strdup_printf("%s\\VEN_%04X&DEV_%04X", if (model_id != 0x0)
subsystem, fu_device_add_instance_u16(FU_DEVICE(self), "DEV", model_id);
(guint)vendor_id, if (subsystem_vendor_id != 0x0 && subsystem_model_id != 0x0) {
(guint)model_id); g_autofree gchar *subsys = NULL;
fu_device_add_instance_id(FU_DEVICE(self), devid1); subsys = g_strdup_printf("%04X%04X",
}
if (vendor_id != 0x0 && model_id != 0x0 && subsystem_vendor_id != 0x0 &&
subsystem_model_id != 0x0) {
g_autofree gchar *devid2 = NULL;
devid2 = g_strdup_printf("%s\\VEN_%04X&DEV_%04X&SUBSYS_%04X%04X",
subsystem,
(guint)vendor_id,
(guint)model_id,
(guint)subsystem_vendor_id, (guint)subsystem_vendor_id,
(guint)subsystem_model_id); (guint)subsystem_model_id);
fu_device_add_instance_id(FU_DEVICE(self), devid2); fu_device_add_instance_str(FU_DEVICE(self), "SUBSYS", subsys);
} }
fu_device_build_instance_id(FU_DEVICE(self), NULL, "PCI", "VEN", "DEV", NULL);
fu_device_build_instance_id(FU_DEVICE(self), NULL, "PCI", "VEN", "DEV", "SUBSYS", NULL);
/* success */ /* success */
return TRUE; return TRUE;
@ -449,31 +442,31 @@ fu_redfish_device_probe(FuDevice *dev, GError **error)
} }
} }
/* add IDs */
fu_device_add_instance_strsafe(dev, "VENDOR", fu_device_get_vendor(dev));
fu_device_add_instance_str(dev, "SOFTWAREID", guid);
fu_device_add_instance_str(dev, "ID", fu_device_get_backend_id(dev));
/* some vendors use a GUID, others use an ID like BMC-AFBT-10 */ /* some vendors use a GUID, others use an ID like BMC-AFBT-10 */
guid_lower = g_ascii_strdown(guid, -1); guid_lower = g_ascii_strdown(guid, -1);
if (fwupd_guid_is_valid(guid_lower)) { if (fwupd_guid_is_valid(guid_lower)) {
fu_device_add_guid(dev, guid_lower); fu_device_add_guid(dev, guid_lower);
} else if (fu_device_get_vendor(dev) != NULL) { } else {
const gchar *instance_id_suffix = "";
g_autofree gchar *instance_id = NULL;
if (fu_device_has_private_flag(dev, FU_REDFISH_DEVICE_FLAG_UNSIGNED_BUILD)) if (fu_device_has_private_flag(dev, FU_REDFISH_DEVICE_FLAG_UNSIGNED_BUILD))
instance_id_suffix = "&TYPE_UNSIGNED"; fu_device_add_instance_str(dev, "TYPE", "UNSIGNED");
instance_id = g_strdup_printf("REDFISH\\VENDOR_%s&SOFTWAREID_%s%s",
fu_device_get_vendor(dev), fu_device_build_instance_id(dev,
guid, NULL,
instance_id_suffix); "REDFISH",
g_strdelimit(instance_id, " ", '_'); "VENDOR",
fu_device_add_instance_id(dev, instance_id); "SOFTWAREID",
"TYPE",
NULL);
fu_device_build_instance_id(dev, NULL, "REDFISH", "VENDOR", "SOFTWAREID", NULL);
} }
/* used for quirking and parenting */ /* used for quirking and parenting */
if (fu_device_get_vendor(dev) != NULL && fu_device_get_backend_id(dev) != NULL) { fu_device_build_instance_id(dev, NULL, "REDFISH", "VENDOR", "ID", NULL);
g_autofree gchar *instance_id = NULL;
instance_id = g_strdup_printf("REDFISH\\VENDOR_%s&ID_%s",
fu_device_get_vendor(dev),
fu_device_get_backend_id(dev));
fu_device_add_instance_id(dev, instance_id);
}
if (json_object_has_member(member, "Name")) { if (json_object_has_member(member, "Name")) {
const gchar *tmp = json_object_get_string_member(member, "Name"); const gchar *tmp = json_object_get_string_member(member, "Name");

View File

@ -20,10 +20,7 @@ fu_scsi_device_probe(FuDevice *device, GError **error)
const gchar *name; const gchar *name;
const gchar *vendor; const gchar *vendor;
const gchar *version; const gchar *version;
g_autofree gchar *name_safe = NULL; g_autofree gchar *vendor_id = NULL;
g_autofree gchar *subsystem = NULL;
g_autofree gchar *vendor_safe = NULL;
g_autofree gchar *version_safe = NULL;
g_autoptr(GPtrArray) block_devs = NULL; g_autoptr(GPtrArray) block_devs = NULL;
/* ignore */ /* ignore */
@ -37,8 +34,7 @@ fu_scsi_device_probe(FuDevice *device, GError **error)
/* vendor */ /* vendor */
vendor = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "vendor", NULL); vendor = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "vendor", NULL);
vendor_safe = fu_common_instance_id_strsafe(vendor); if (vendor == NULL || g_strcmp0(vendor, "ATA") == 0) {
if (vendor_safe == NULL || g_strcmp0(vendor_safe, "ATA") == 0) {
g_set_error_literal(error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -46,57 +42,27 @@ fu_scsi_device_probe(FuDevice *device, GError **error)
return FALSE; return FALSE;
} }
fu_device_set_vendor(device, vendor); fu_device_set_vendor(device, vendor);
vendor_id = g_strdup_printf("SCSI:%s", vendor);
fu_device_add_vendor_id(device, vendor_id);
/* name */ /* name */
name = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "model", NULL); name = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "model", NULL);
name_safe = fu_common_instance_id_strsafe(name);
if (name_safe == NULL) {
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"no assigned name");
return FALSE;
}
fu_device_set_name(device, name); fu_device_set_name(device, name);
/* version */ /* version */
version = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "rev", NULL); version = fu_udev_device_get_sysfs_attr(FU_UDEV_DEVICE(device), "rev", NULL);
version_safe = fu_common_instance_id_strsafe(version);
if (version_safe == NULL) {
g_set_error_literal(error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"no assigned version");
return FALSE;
}
fu_device_set_version(device, version); fu_device_set_version(device, version);
/* add GUIDs */ /* add GUIDs */
subsystem = g_utf8_strup(fu_udev_device_get_subsystem(FU_UDEV_DEVICE(device)), -1); fu_device_add_instance_strsafe(device, "VEN", vendor);
if (subsystem != NULL && vendor_safe != NULL && name_safe != NULL && version_safe != NULL) { fu_device_add_instance_strsafe(device, "DEV", name);
g_autofree gchar *devid = NULL; fu_device_add_instance_strsafe(device, "REV", version);
devid = g_strdup_printf("%s\\VEN_%s&DEV_%s&REV_%s", if (!fu_device_build_instance_id_quirk(device, NULL, "SCSI", "VEN", NULL))
subsystem, return FALSE;
vendor_safe, if (!fu_device_build_instance_id(device, NULL, "SCSI", "VEN", "DEV", NULL))
name_safe, return FALSE;
version_safe); if (!fu_device_build_instance_id(device, NULL, "SCSI", "VEN", "DEV", "REV", NULL))
fu_device_add_instance_id(device, devid); return FALSE;
}
if (subsystem != NULL && vendor_safe != NULL && name_safe != NULL) {
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("%s\\VEN_%s&DEV_%s", subsystem, vendor_safe, name_safe);
fu_device_add_instance_id(device, devid);
}
if (subsystem != NULL && vendor_safe != NULL) {
g_autofree gchar *devid = NULL;
devid = g_strdup_printf("%s\\VEN_%s", subsystem, vendor_safe);
fu_device_add_instance_id_full(device, devid, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS);
}
if (vendor_safe != NULL) {
g_autofree gchar *vendor_id = NULL;
vendor_id = g_strdup_printf("SCSI:%s", vendor_safe);
fu_device_add_vendor_id(device, vendor_id);
}
/* check all block devices, although there should only be one */ /* check all block devices, although there should only be one */
block_devs = fu_udev_device_get_children_with_subsystem(FU_UDEV_DEVICE(device), "block"); block_devs = fu_udev_device_get_children_with_subsystem(FU_UDEV_DEVICE(device), "block");

View File

@ -22,7 +22,6 @@ fu_plugin_superio_coldplug_chipset(FuPlugin *plugin, const gchar *guid, GError *
const gchar *dmi_vendor; const gchar *dmi_vendor;
const gchar *chipset; const gchar *chipset;
GType custom_gtype; GType custom_gtype;
g_autofree gchar *devid = NULL;
g_autoptr(FuSuperioDevice) dev = NULL; g_autoptr(FuSuperioDevice) dev = NULL;
g_autoptr(FuDeviceLocker) locker = NULL; g_autoptr(FuDeviceLocker) locker = NULL;
@ -51,8 +50,9 @@ fu_plugin_superio_coldplug_chipset(FuPlugin *plugin, const gchar *guid, GError *
NULL); NULL);
/* add this so we can attach all the other quirks */ /* add this so we can attach all the other quirks */
devid = g_strdup_printf("SUPERIO\\GUID_%s", guid); fu_device_add_instance_str(FU_DEVICE(dev), "GUID", guid);
fu_device_add_instance_id(FU_DEVICE(dev), devid); if (!fu_device_build_instance_id(FU_DEVICE(dev), error, "SUPERIO", "GUID", NULL))
return FALSE;
/* set ID and ports via quirks */ /* set ID and ports via quirks */
if (!fu_device_probe(FU_DEVICE(dev), error)) if (!fu_device_probe(FU_DEVICE(dev), error))

View File

@ -412,8 +412,12 @@ fu_synaptics_cxaudio_device_setup(FuDevice *device, GError **error)
return FALSE; return FALSE;
} }
self->chip_id = self->chip_id_base + chip_id_offset; self->chip_id = self->chip_id_base + chip_id_offset;
chip_id = g_strdup_printf("SYNAPTICS_CXAUDIO\\ID_CX%u", self->chip_id);
fu_device_add_instance_id_full(device, chip_id, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS); /* add instance ID */
chip_id = g_strdup_printf("CX%u", self->chip_id);
fu_device_add_instance_str(device, "ID", chip_id);
if (!fu_device_build_instance_id_quirk(device, error, "SYNAPTICS_CXAUDIO", "ID", NULL))
return FALSE;
/* set summary */ /* set summary */
summary = g_strdup_printf("CX%u USB audio device", self->chip_id); summary = g_strdup_printf("CX%u USB audio device", self->chip_id);

View File

@ -73,11 +73,12 @@ fu_synaprom_config_setup(FuDevice *device, GError **error)
FuSynapromCmdIotaFind cmd = {0x0}; FuSynapromCmdIotaFind cmd = {0x0};
FuSynapromIotaConfigVersion cfg; FuSynapromIotaConfigVersion cfg;
FuSynapromReplyIotaFindHdr hdr; FuSynapromReplyIotaFindHdr hdr;
g_autofree gchar *configid1_str = NULL;
g_autofree gchar *configid2_str = NULL;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
g_autoptr(GByteArray) reply = NULL; g_autoptr(GByteArray) reply = NULL;
g_autoptr(GByteArray) request = NULL; g_autoptr(GByteArray) request = NULL;
g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC); g_autoptr(FuProgress) progress = fu_progress_new(G_STRLOC);
g_autofree gchar *devid = NULL;
/* get IOTA */ /* get IOTA */
cmd.itype = GUINT16_TO_LE((guint16)FU_SYNAPROM_IOTA_ITYPE_CONFIG_VERSION); cmd.itype = GUINT16_TO_LE((guint16)FU_SYNAPROM_IOTA_ITYPE_CONFIG_VERSION);
@ -125,13 +126,15 @@ fu_synaprom_config_setup(FuDevice *device, GError **error)
self->configid2, self->configid2,
GUINT16_FROM_LE(cfg.version)); GUINT16_FROM_LE(cfg.version));
/* we should have made these a %08% uint32_t... */
configid1_str = g_strdup_printf("%u", self->configid1);
configid2_str = g_strdup_printf("%u", self->configid2);
/* append the configid to the generated GUID */ /* append the configid to the generated GUID */
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&CFG1_%u&CFG2_%u", fu_device_add_instance_str(device, "CFG1", configid1_str);
fu_usb_device_get_vid(FU_USB_DEVICE(parent)), fu_device_add_instance_str(device, "CFG2", configid2_str);
fu_usb_device_get_pid(FU_USB_DEVICE(parent)), if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", "CFG1", "CFG2", NULL))
self->configid1, return FALSE;
self->configid2);
fu_device_add_instance_id(FU_DEVICE(self), devid);
/* no downgrades are allowed */ /* no downgrades are allowed */
version = g_strdup_printf("%04u", GUINT16_FROM_LE(cfg.version)); version = g_strdup_printf("%04u", GUINT16_FROM_LE(cfg.version));

View File

@ -236,10 +236,6 @@ fu_tpm_v2_device_setup(FuDevice *device, GError **error)
guint32 version1 = 0; guint32 version1 = 0;
guint32 version2 = 0; guint32 version2 = 0;
guint64 version_raw; guint64 version_raw;
g_autofree gchar *id1 = NULL;
g_autofree gchar *id2 = NULL;
g_autofree gchar *id3 = NULL;
g_autofree gchar *id4 = NULL;
g_autofree gchar *manufacturer = NULL; g_autofree gchar *manufacturer = NULL;
g_autofree gchar *model1 = NULL; g_autofree gchar *model1 = NULL;
g_autofree gchar *model2 = NULL; g_autofree gchar *model2 = NULL;
@ -302,14 +298,14 @@ fu_tpm_v2_device_setup(FuDevice *device, GError **error)
model = g_strjoin("", model1, model2, model3, model4, NULL); model = g_strjoin("", model1, model2, model3, model4, NULL);
/* add GUIDs to daemon */ /* add GUIDs to daemon */
id1 = g_strdup_printf("TPM\\VEN_%s&DEV_%04X", manufacturer, tpm_type); fu_device_add_instance_str(device, "VEN", manufacturer);
fu_device_add_instance_id(device, id1); fu_device_add_instance_u16(device, "DEV", tpm_type);
id2 = g_strdup_printf("TPM\\VEN_%s&MOD_%s", manufacturer, model); fu_device_add_instance_str(device, "MOD", model);
fu_device_add_instance_id(device, id2); fu_device_add_instance_str(device, "VER", family);
id3 = g_strdup_printf("TPM\\VEN_%s&DEV_%04X&VER_%s", manufacturer, tpm_type, family); fu_device_build_instance_id(device, NULL, "TPM", "VEN", "DEV", NULL);
fu_device_add_instance_id(device, id3); fu_device_build_instance_id(device, NULL, "TPM", "VEN", "MOD", NULL);
id4 = g_strdup_printf("TPM\\VEN_%s&MOD_%s&VER_%s", manufacturer, model, family); fu_device_build_instance_id(device, NULL, "TPM", "VEN", "DEV", "VER", NULL);
fu_device_add_instance_id(device, id4); fu_device_build_instance_id(device, NULL, "TPM", "VEN", "MOD", "VER", NULL);
/* enforce vendors can only ship updates for their own hardware */ /* enforce vendors can only ship updates for their own hardware */
vendor_id = g_strdup_printf("TPM:%s", manufacturer); vendor_id = g_strdup_printf("TPM:%s", manufacturer);

View File

@ -97,7 +97,6 @@ fu_uefi_dbx_prepare_firmware(FuDevice *device, GBytes *fw, FwupdInstallFlags fla
static gboolean static gboolean
fu_uefi_dbx_device_probe(FuDevice *device, GError **error) fu_uefi_dbx_device_probe(FuDevice *device, GError **error)
{ {
g_autofree gchar *arch_up = NULL;
g_autoptr(FuFirmware) kek = fu_efi_signature_list_new(); g_autoptr(FuFirmware) kek = fu_efi_signature_list_new();
g_autoptr(GBytes) kek_blob = NULL; g_autoptr(GBytes) kek_blob = NULL;
g_autoptr(GPtrArray) sigs = NULL; g_autoptr(GPtrArray) sigs = NULL;
@ -108,23 +107,19 @@ fu_uefi_dbx_device_probe(FuDevice *device, GError **error)
return FALSE; return FALSE;
if (!fu_firmware_parse(kek, kek_blob, FWUPD_INSTALL_FLAG_NO_SEARCH, error)) if (!fu_firmware_parse(kek, kek_blob, FWUPD_INSTALL_FLAG_NO_SEARCH, error))
return FALSE; return FALSE;
arch_up = g_utf8_strup(EFI_MACHINE_TYPE_NAME, -1); fu_device_add_instance_strup(device, "ARCH", EFI_MACHINE_TYPE_NAME);
sigs = fu_firmware_get_images(kek); sigs = fu_firmware_get_images(kek);
for (guint j = 0; j < sigs->len; j++) { for (guint j = 0; j < sigs->len; j++) {
FuEfiSignature *sig = g_ptr_array_index(sigs, j); FuEfiSignature *sig = g_ptr_array_index(sigs, j);
g_autofree gchar *checksum = NULL; g_autofree gchar *checksum = NULL;
g_autofree gchar *checksum_up = NULL;
g_autofree gchar *devid1 = NULL;
g_autofree gchar *devid2 = NULL;
checksum = fu_firmware_get_checksum(FU_FIRMWARE(sig), G_CHECKSUM_SHA256, error); checksum = fu_firmware_get_checksum(FU_FIRMWARE(sig), G_CHECKSUM_SHA256, error);
if (checksum == NULL) if (checksum == NULL)
return FALSE; return FALSE;
checksum_up = g_utf8_strup(checksum, -1); fu_device_add_instance_strup(device, "CRT", checksum);
devid1 = g_strdup_printf("UEFI\\CRT_%s", checksum_up); fu_device_build_instance_id(device, NULL, "UEFI", "CRT", NULL);
fu_device_add_instance_id(device, devid1); fu_device_build_instance_id(device, NULL, "UEFI", "CRT", "ARCH", NULL);
devid2 = g_strdup_printf("UEFI\\CRT_%s&ARCH_%s", checksum_up, arch_up);
fu_device_add_instance_id(device, devid2);
} }
return fu_uefi_dbx_device_set_version_number(device, error); return fu_uefi_dbx_device_set_version_number(device, error);
} }

View File

@ -62,10 +62,11 @@ fu_uf2_device_probe_current_fw(FuDevice *device, GBytes *fw, GError **error)
/* add instance ID for quirks */ /* add instance ID for quirks */
if (fu_firmware_get_idx(firmware) != 0x0) { if (fu_firmware_get_idx(firmware) != 0x0) {
g_autofree gchar *id0 = NULL; fu_device_add_instance_u32(device,
id0 = g_strdup_printf("UF2\\FAMILY_%08X", (guint32)fu_firmware_get_idx(firmware)); "FAMILY",
fu_device_add_instance_id_full(device, id0, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS); (guint32)fu_firmware_get_idx(firmware));
} }
fu_device_build_instance_id_quirk(device, NULL, "UF2", "FAMILY", NULL);
/* add device checksum */ /* add device checksum */
fw_raw = fu_firmware_get_bytes(firmware, error); fw_raw = fu_firmware_get_bytes(firmware, error);
@ -289,11 +290,10 @@ fu_uf2_device_setup(FuDevice *device, GError **error)
if (g_str_has_prefix(lines[i], "Model: ")) { if (g_str_has_prefix(lines[i], "Model: ")) {
fu_device_set_name(device, lines[i] + 7); fu_device_set_name(device, lines[i] + 7);
} else if (g_str_has_prefix(lines[i], "Board-ID: ")) { } else if (g_str_has_prefix(lines[i], "Board-ID: ")) {
g_autofree gchar *devid = NULL; fu_device_add_instance_strsafe(device, "BOARD", lines[i] + 10);
devid = g_strdup_printf("UF2\\BOARD_%s", lines[i] + 10);
fu_device_add_instance_id(device, devid);
} }
} }
fu_device_build_instance_id(device, NULL, "UF2", "BOARD", NULL);
/* this might exist */ /* this might exist */
fn2 = fu_block_device_get_full_path(self, "CURRENT.UF2", error); fn2 = fu_block_device_get_full_path(self, "CURRENT.UF2", error);
@ -314,7 +314,6 @@ fu_uf2_device_probe(FuDevice *device, GError **error)
{ {
GUdevDevice *udev_device = fu_udev_device_get_dev(FU_UDEV_DEVICE(device)); GUdevDevice *udev_device = fu_udev_device_get_dev(FU_UDEV_DEVICE(device));
const gchar *tmp; const gchar *tmp;
const gchar *uuid;
guint64 vid = 0; guint64 vid = 0;
guint64 pid = 0; guint64 pid = 0;
@ -350,20 +349,23 @@ fu_uf2_device_probe(FuDevice *device, GError **error)
tmp = g_udev_device_get_property(udev_device, "ID_VENDOR_ID"); tmp = g_udev_device_get_property(udev_device, "ID_VENDOR_ID");
if (tmp != NULL) if (tmp != NULL)
vid = g_ascii_strtoull(tmp, NULL, 16); vid = g_ascii_strtoull(tmp, NULL, 16);
if (vid != 0x0)
fu_device_add_instance_u16(device, "VID", vid);
tmp = g_udev_device_get_property(udev_device, "ID_MODEL_ID"); tmp = g_udev_device_get_property(udev_device, "ID_MODEL_ID");
if (tmp != NULL) if (tmp != NULL)
pid = g_ascii_strtoull(tmp, NULL, 16); pid = g_ascii_strtoull(tmp, NULL, 16);
uuid = g_udev_device_get_property(udev_device, "ID_FS_UUID"); if (pid != 0x0)
if (uuid != NULL && vid != 0x0 && pid != 0x0) { fu_device_add_instance_u16(device, "PID", pid);
g_autofree gchar *devid = tmp = g_udev_device_get_property(udev_device, "ID_FS_UUID");
g_strdup_printf("USB\\VID_%04X&PID_%04X&UUID_%s", (guint)vid, (guint)pid, uuid); fu_device_add_instance_str(device, "UUID", tmp);
fu_device_add_instance_id(device, devid); if (!fu_device_build_instance_id_quirk(device, error, "USB", "VID", NULL))
} return FALSE;
if (vid != 0x0 && pid != 0x0) { if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", NULL))
g_autofree gchar *devid = return FALSE;
g_strdup_printf("USB\\VID_%04X&PID_%04X", (guint)vid, (guint)pid); if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", "UUID", NULL))
fu_device_add_instance_id(device, devid); return FALSE;
}
/* vendor-id */
if (vid != 0x0) { if (vid != 0x0) {
g_autofree gchar *vendor_id = g_strdup_printf("USB:0x%04X", (guint)vid); g_autofree gchar *vendor_id = g_strdup_printf("USB:0x%04X", (guint)vid);
fu_device_add_vendor_id(device, vendor_id); fu_device_add_vendor_id(device, vendor_id);

View File

@ -19,7 +19,7 @@ fu_usi_dock_dmc_device_parent_notify_cb(FuDevice *device, GParamSpec *pspec, gpo
{ {
FuDevice *parent = fu_device_get_parent(device); FuDevice *parent = fu_device_get_parent(device);
if (parent != NULL) { if (parent != NULL) {
g_autofree gchar *instance_id = NULL; g_autoptr(GError) error = NULL;
/* slightly odd: the MCU device uses the DMC version number */ /* slightly odd: the MCU device uses the DMC version number */
g_debug("absorbing DMC version into MCU"); g_debug("absorbing DMC version into MCU");
@ -28,11 +28,9 @@ fu_usi_dock_dmc_device_parent_notify_cb(FuDevice *device, GParamSpec *pspec, gpo
fu_device_set_serial(parent, fu_device_get_serial(device)); fu_device_set_serial(parent, fu_device_get_serial(device));
/* allow matching firmware */ /* allow matching firmware */
instance_id = g_strdup_printf("USB\\VID_%04X&PID_%04X&CID_%s", fu_device_add_instance_str(parent, "CID", fu_device_get_name(device));
fu_usb_device_get_vid(FU_USB_DEVICE(parent)), if (!fu_device_build_instance_id(parent, &error, "USB", "VID", "PID", "CID", NULL))
fu_usb_device_get_pid(FU_USB_DEVICE(parent)), g_warning("failed to build ID: %s", error->message);
fu_device_get_name(device));
fu_device_add_instance_id(parent, instance_id);
/* don't allow firmware updates on this */ /* don't allow firmware updates on this */
fu_device_set_name(device, "Dock Management Controller Information"); fu_device_set_name(device, "Dock Management Controller Information");

View File

@ -194,7 +194,6 @@ fu_usi_dock_mcu_device_enumerate_children(FuUsiDockMcuDevice *self, GError **err
for (guint i = 0; components[i].name != NULL; i++) { for (guint i = 0; components[i].name != NULL; i++) {
const guint8 *val = outbuf + components[i].offset; const guint8 *val = outbuf + components[i].offset;
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
g_autofree gchar *instance_id = NULL;
g_autoptr(FuDevice) child = NULL; g_autoptr(FuDevice) child = NULL;
child = fu_usi_dock_child_new(fu_device_get_context(FU_DEVICE(self))); child = fu_usi_dock_child_new(fu_device_get_context(FU_DEVICE(self)));
@ -361,11 +360,15 @@ fu_usi_dock_mcu_device_enumerate_children(FuUsiDockMcuDevice *self, GError **err
} }
/* add virtual device */ /* add virtual device */
instance_id = g_strdup_printf("USB\\VID_%04X&PID_%04X&CID_%s", fu_device_add_instance_u16(child,
fu_usb_device_get_vid(FU_USB_DEVICE(self)), "VID",
fu_usb_device_get_pid(FU_USB_DEVICE(self)), fu_usb_device_get_vid(FU_USB_DEVICE(self)));
components[i].name); fu_device_add_instance_u16(child,
fu_device_add_instance_id(child, instance_id); "PID",
fu_usb_device_get_pid(FU_USB_DEVICE(self)));
fu_device_add_instance_str(child, "CID", components[i].name);
if (!fu_device_build_instance_id(child, error, "USB", "VID", "PID", "CID", NULL))
return FALSE;
if (fu_device_get_name(child) == NULL) if (fu_device_get_name(child) == NULL)
fu_device_set_name(child, components[i].name); fu_device_set_name(child, components[i].name);
fu_device_set_logical_id(child, components[i].name); fu_device_set_logical_id(child, components[i].name);

View File

@ -480,15 +480,10 @@ fu_vli_device_set_kind(FuVliDevice *self, FuVliDeviceKind device_kind)
fu_device_set_firmware_size_max(FU_DEVICE(self), sz); fu_device_set_firmware_size_max(FU_DEVICE(self), sz);
/* add extra DEV GUID too */ /* add extra DEV GUID too */
if (priv->kind != FU_VLI_DEVICE_KIND_UNKNOWN) { fu_device_add_instance_str(FU_DEVICE(self),
GUsbDevice *usb_device = fu_usb_device_get_dev(FU_USB_DEVICE(self)); "DEV",
g_autofree gchar *devid1 = NULL;
devid1 = g_strdup_printf("USB\\VID_%04X&PID_%04X&DEV_%s",
g_usb_device_get_vid(usb_device),
g_usb_device_get_pid(usb_device),
fu_vli_common_device_kind_to_string(priv->kind)); fu_vli_common_device_kind_to_string(priv->kind));
fu_device_add_instance_id(FU_DEVICE(self), devid1); fu_device_build_instance_id(FU_DEVICE(self), NULL, "USB", "VID", "PID", "DEV", NULL);
}
} }
void void
@ -597,14 +592,11 @@ fu_vli_device_setup(FuDevice *device, GError **error)
/* get the flash chip attached */ /* get the flash chip attached */
if (priv->spi_auto_detect) { if (priv->spi_auto_detect) {
GUsbDevice *usb_device = fu_usb_device_get_dev(FU_USB_DEVICE(self));
if (!fu_vli_device_spi_read_flash_id(self, error)) { if (!fu_vli_device_spi_read_flash_id(self, error)) {
g_prefix_error(error, "failed to read SPI chip ID: "); g_prefix_error(error, "failed to read SPI chip ID: ");
return FALSE; return FALSE;
} }
if (priv->flash_id != 0x0) { if (priv->flash_id != 0x0) {
g_autofree gchar *devid1 = NULL;
g_autofree gchar *devid2 = NULL;
g_autofree gchar *flash_id = fu_vli_device_get_flash_id_str(self); g_autofree gchar *flash_id = fu_vli_device_get_flash_id_str(self);
/* use the correct flash device */ /* use the correct flash device */
@ -613,17 +605,23 @@ fu_vli_device_setup(FuDevice *device, GError **error)
return FALSE; return FALSE;
/* add extra instance IDs to include the SPI variant */ /* add extra instance IDs to include the SPI variant */
devid2 = g_strdup_printf("USB\\VID_%04X&PID_%04X&SPI_%s&REV_%04X", fu_device_add_instance_str(device, "SPI", flash_id);
g_usb_device_get_vid(usb_device), if (!fu_device_build_instance_id(device,
g_usb_device_get_pid(usb_device), error,
flash_id, "USB",
g_usb_device_get_release(usb_device)); "VID",
fu_device_add_instance_id(device, devid2); "PID",
devid1 = g_strdup_printf("USB\\VID_%04X&PID_%04X&SPI_%s", "SPI",
g_usb_device_get_vid(usb_device), NULL))
g_usb_device_get_pid(usb_device), return FALSE;
flash_id); fu_device_build_instance_id(device,
fu_device_add_instance_id(device, devid1); NULL,
"USB",
"VID",
"PID",
"SPI",
"REV",
NULL);
} }
} }

View File

@ -665,23 +665,17 @@ fu_vli_pd_parade_device_dump_firmware(FuDevice *device, FuProgress *progress, GE
static gboolean static gboolean
fu_vli_pd_parade_device_probe(FuDevice *device, GError **error) fu_vli_pd_parade_device_probe(FuDevice *device, GError **error)
{ {
FuVliPdDevice *parent = FU_VLI_PD_DEVICE(fu_device_get_parent(device));
FuVliPdParadeDevice *self = FU_VLI_PD_PARADE_DEVICE(device); FuVliPdParadeDevice *self = FU_VLI_PD_PARADE_DEVICE(device);
g_autofree gchar *instance_id1 = NULL;
/* get version */ /* get version */
if (!fu_vli_pd_parade_device_read_fw_ver(self, error)) if (!fu_vli_pd_parade_device_read_fw_ver(self, error))
return FALSE; return FALSE;
/* use header to populate device info */ /* use header to populate device info */
instance_id1 = g_strdup_printf("USB\\VID_%04X&PID_%04X&I2C_%s", fu_device_add_instance_str(device,
fu_usb_device_get_vid(FU_USB_DEVICE(parent)), "I2C",
fu_usb_device_get_pid(FU_USB_DEVICE(parent)),
fu_vli_common_device_kind_to_string(self->device_kind)); fu_vli_common_device_kind_to_string(self->device_kind));
fu_device_add_instance_id(device, instance_id1); return fu_device_build_instance_id(device, error, "USB", "VID", "PID", "I2C", NULL);
/* success */
return TRUE;
} }
static void static void

View File

@ -292,19 +292,13 @@ fu_vli_usbhub_msp430_device_probe(FuDevice *device, GError **error)
{ {
FuVliDeviceKind device_kind = FU_VLI_DEVICE_KIND_MSP430; FuVliDeviceKind device_kind = FU_VLI_DEVICE_KIND_MSP430;
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device)); FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device));
g_autofree gchar *instance_id = NULL;
fu_device_set_name(device, fu_vli_common_device_kind_to_string(device_kind)); fu_device_set_name(device, fu_vli_common_device_kind_to_string(device_kind));
fu_device_set_physical_id(device, fu_device_get_physical_id(FU_DEVICE(parent))); fu_device_set_physical_id(device, fu_device_get_physical_id(FU_DEVICE(parent)));
/* add instance ID */ /* add instance ID */
instance_id = g_strdup_printf("USB\\VID_%04X&PID_%04X&I2C_%s", fu_device_add_instance_str(device, "I2C", fu_vli_common_device_kind_to_string(device_kind));
fu_usb_device_get_vid(FU_USB_DEVICE(parent)), return fu_device_build_instance_id(device, error, "USB", "VID", "PID", NULL);
fu_usb_device_get_pid(FU_USB_DEVICE(parent)),
fu_vli_common_device_kind_to_string(device_kind));
fu_device_add_instance_id(device, instance_id);
return TRUE;
} }
static void static void

View File

@ -46,12 +46,9 @@ fu_vli_usbhub_pd_device_setup(FuDevice *device, GError **error)
FuVliPdHdr hdr = {0x0}; FuVliPdHdr hdr = {0x0};
FuVliUsbhubPdDevice *self = FU_VLI_USBHUB_PD_DEVICE(device); FuVliUsbhubPdDevice *self = FU_VLI_USBHUB_PD_DEVICE(device);
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device)); FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device));
const gchar *name;
guint32 fwver; guint32 fwver;
g_autofree gchar *fwver_str = NULL; g_autofree gchar *fwver_str = NULL;
g_autofree gchar *instance_id0 = NULL;
g_autofree gchar *instance_id1 = NULL;
g_autofree gchar *instance_id2 = NULL;
g_autofree gchar *instance_id3 = NULL;
/* legacy location */ /* legacy location */
if (!fu_vli_device_spi_read_block(FU_VLI_DEVICE(parent), if (!fu_vli_device_spi_read_block(FU_VLI_DEVICE(parent),
@ -95,30 +92,27 @@ fu_vli_usbhub_pd_device_setup(FuDevice *device, GError **error)
fwver); fwver);
return FALSE; return FALSE;
} }
fu_device_set_name(device, fu_vli_common_device_kind_to_string(self->device_kind)); name = fu_vli_common_device_kind_to_string(self->device_kind);
fu_device_set_name(device, name);
/* use header to populate device info */ /* use header to populate device info */
fu_device_set_version_raw(device, fwver); fu_device_set_version_raw(device, fwver);
fwver_str = fu_common_version_from_uint32(fwver, FWUPD_VERSION_FORMAT_QUAD); fwver_str = fu_common_version_from_uint32(fwver, FWUPD_VERSION_FORMAT_QUAD);
fu_device_set_version(device, fwver_str); fu_device_set_version(device, fwver_str);
instance_id0 = g_strdup_printf("USB\\VID_%04X&PID_%04X&APP_%02X",
GUINT16_FROM_LE(hdr.vid),
GUINT16_FROM_LE(hdr.pid),
fwver & 0xff);
fu_device_add_instance_id(device, instance_id0);
instance_id1 = g_strdup_printf("USB\\VID_%04X&PID_%04X&DEV_%s",
GUINT16_FROM_LE(hdr.vid),
GUINT16_FROM_LE(hdr.pid),
fu_vli_common_device_kind_to_string(self->device_kind));
fu_device_add_instance_id(device, instance_id1);
/* add standard GUIDs in order of priority */ /* add standard GUIDs in order of priority */
instance_id2 = g_strdup_printf("USB\\VID_%04X&PID_%04X", fu_device_add_instance_u16(device, "VID", GUINT16_FROM_LE(hdr.vid));
GUINT16_FROM_LE(hdr.vid), fu_device_add_instance_u16(device, "PID", GUINT16_FROM_LE(hdr.pid));
GUINT16_FROM_LE(hdr.pid)); fu_device_add_instance_u8(device, "APP", fwver & 0xff);
fu_device_add_instance_id(device, instance_id2); fu_device_add_instance_str(device, "DEV", name);
instance_id3 = g_strdup_printf("USB\\VID_%04X", GUINT16_FROM_LE(hdr.vid)); if (!fu_device_build_instance_id_quirk(device, error, "USB", "VID", NULL))
fu_device_add_instance_id_full(device, instance_id3, FU_DEVICE_INSTANCE_FLAG_ONLY_QUIRKS); return FALSE;
if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", NULL))
return FALSE;
if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", "DEV", NULL))
return FALSE;
if (!fu_device_build_instance_id(device, error, "USB", "VID", "PID", "APP", NULL))
return FALSE;
/* these have a backup section */ /* these have a backup section */
if (fu_vli_common_device_kind_get_offset(self->device_kind) == VLI_USBHUB_FLASHMAP_ADDR_PD) if (fu_vli_common_device_kind_get_offset(self->device_kind) == VLI_USBHUB_FLASHMAP_ADDR_PD)

View File

@ -511,18 +511,13 @@ fu_vli_usbhub_rtd21xx_device_probe(FuDevice *device, GError **error)
{ {
FuVliDeviceKind device_kind = FU_VLI_DEVICE_KIND_RTD21XX; FuVliDeviceKind device_kind = FU_VLI_DEVICE_KIND_RTD21XX;
FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device)); FuVliUsbhubDevice *parent = FU_VLI_USBHUB_DEVICE(fu_device_get_parent(device));
g_autofree gchar *instance_id = NULL;
fu_device_set_name(device, fu_vli_common_device_kind_to_string(device_kind)); fu_device_set_name(device, fu_vli_common_device_kind_to_string(device_kind));
fu_device_set_physical_id(device, fu_device_get_physical_id(FU_DEVICE(parent))); fu_device_set_physical_id(device, fu_device_get_physical_id(FU_DEVICE(parent)));
/* add instance ID */ /* add instance ID */
instance_id = g_strdup_printf("USB\\VID_%04X&PID_%04X&I2C_%s", fu_device_add_instance_str(device, "I2C", fu_vli_common_device_kind_to_string(device_kind));
fu_usb_device_get_vid(FU_USB_DEVICE(parent)), return fu_device_build_instance_id(device, error, "USB", "VID", "PID", "I2C", NULL);
fu_usb_device_get_pid(FU_USB_DEVICE(parent)),
fu_vli_common_device_kind_to_string(device_kind));
fu_device_add_instance_id(device, instance_id);
return TRUE;
} }
static void static void

View File

@ -41,8 +41,6 @@ fu_wacom_aes_add_recovery_hwid(FuDevice *device, GError **error)
FuWacomRawVerifyResponse rsp = {.report_id = FU_WACOM_RAW_BL_REPORT_ID_GET, FuWacomRawVerifyResponse rsp = {.report_id = FU_WACOM_RAW_BL_REPORT_ID_GET,
.size8 = 0x00, .size8 = 0x00,
.data = {0x00}}; .data = {0x00}};
g_autofree gchar *devid1 = NULL;
g_autofree gchar *devid2 = NULL;
guint16 pid; guint16 pid;
if (!fu_wacom_device_set_feature(FU_WACOM_DEVICE(device), if (!fu_wacom_device_set_feature(FU_WACOM_DEVICE(device),
@ -77,12 +75,13 @@ fu_wacom_aes_add_recovery_hwid(FuDevice *device, GError **error)
return FALSE; return FALSE;
} }
devid1 = g_strdup_printf("HIDRAW\\VEN_2D1F&DEV_%04X", pid); /* add recovery IDs */
devid2 = g_strdup_printf("HIDRAW\\VEN_056A&DEV_%04X", pid); fu_device_add_instance_u16(device, "VEN", 0x2D1F);
fu_device_add_instance_id(device, devid1); fu_device_add_instance_u16(device, "DEV", pid);
fu_device_add_instance_id(device, devid2); if (!fu_device_build_instance_id(device, error, "HIDRAW", "VID", "PID", NULL))
return FALSE;
return TRUE; fu_device_add_instance_u16(device, "VEN", 0x056A);
return fu_device_build_instance_id(device, error, "HIDRAW", "VID", "PID", NULL);
} }
static gboolean static gboolean