mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 09:00:55 +00:00
Copy the instance ID strings when incorporating
Also, add a test.
This commit is contained in:
parent
599e67cd2c
commit
30aab6f564
@ -4797,6 +4797,13 @@ fu_device_unbind_driver(FuDevice *self, GError **error)
|
||||
return klass->unbind_driver(self, error);
|
||||
}
|
||||
|
||||
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_incorporate:
|
||||
* @self: a #FuDevice
|
||||
@ -4860,6 +4867,13 @@ fu_device_incorporate(FuDevice *self, FuDevice *donor)
|
||||
}
|
||||
g_rw_lock_reader_unlock(&priv_donor->metadata_mutex);
|
||||
|
||||
/* copy all instance ID keys if not already set */
|
||||
g_hash_table_iter_init(&iter, priv_donor->instance_hash);
|
||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||
if (fu_device_instance_lookup(self, key) == NULL)
|
||||
fu_device_add_instance_str(self, key, value);
|
||||
}
|
||||
|
||||
/* now the base class, where all the interesting bits are */
|
||||
fwupd_device_incorporate(FWUPD_DEVICE(self), FWUPD_DEVICE(donor));
|
||||
|
||||
@ -5169,13 +5183,6 @@ fu_device_add_instance_u32(FuDevice *self, const gchar *key, guint32 value)
|
||||
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
|
||||
|
@ -1382,14 +1382,18 @@ fu_device_parent_func(void)
|
||||
static void
|
||||
fu_device_incorporate_func(void)
|
||||
{
|
||||
g_autoptr(FuDevice) device = fu_device_new(NULL);
|
||||
g_autoptr(FuDevice) donor = fu_device_new(NULL);
|
||||
gboolean ret;
|
||||
g_autoptr(FuContext) ctx = fu_context_new();
|
||||
g_autoptr(FuDevice) device = fu_device_new(ctx);
|
||||
g_autoptr(FuDevice) donor = fu_device_new(ctx);
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* set up donor device */
|
||||
fu_device_set_alternate_id(donor, "alt-id");
|
||||
fu_device_set_equivalent_id(donor, "equiv-id");
|
||||
fu_device_set_metadata(donor, "test", "me");
|
||||
fu_device_set_metadata(donor, "test2", "me");
|
||||
fu_device_add_instance_str(donor, "VID", "1234");
|
||||
|
||||
/* base properties */
|
||||
fu_device_add_flag(donor, FWUPD_DEVICE_FLAG_REQUIRE_AC);
|
||||
@ -1412,6 +1416,10 @@ fu_device_incorporate_func(void)
|
||||
g_assert_cmpint(fu_device_get_created(device), ==, 123);
|
||||
g_assert_cmpint(fu_device_get_modified(device), ==, 789);
|
||||
g_assert_cmpint(fu_device_get_icons(device)->len, ==, 1);
|
||||
ret = fu_device_build_instance_id(device, &error, "SUBSYS", "VID", NULL);
|
||||
g_assert_no_error(error);
|
||||
g_assert_true(ret);
|
||||
g_assert_true(fu_device_has_instance_id(device, "SUBSYS\\VID_1234"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user