mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-27 12:30:17 +00:00
mtd: Use the correct uSWID child for multiple coSWID children
This commit is contained in:
parent
519110b70e
commit
7ec0f11e69
@ -19,6 +19,10 @@ These devices use custom DeviceInstanceId values built from the device `NAME` an
|
||||
* `MTD\VENDOR_foo&NAME_baz`
|
||||
* `MTD\VENDOR_foo&PRODUCT_bar&NAME_baz`
|
||||
|
||||
If the `FirmwareGType` quirk is set for the device then the firmware is read back from the device at
|
||||
daemon startup and parsed for the version number.
|
||||
In the event the firmware has multiple child images then the device GUIDs are used as firmware IDs.
|
||||
|
||||
## Update Behavior
|
||||
|
||||
The MTD device is erased in chunks, written and then read back to verify.
|
||||
|
@ -30,6 +30,8 @@ fu_mtd_device_to_string(FuDevice *device, guint idt, GString *str)
|
||||
static gboolean
|
||||
fu_mtd_device_setup(FuDevice *device, GError **error)
|
||||
{
|
||||
FuFirmware *firmware_child = NULL;
|
||||
GPtrArray *instance_ids;
|
||||
GType firmware_gtype = fu_device_get_firmware_gtype(device);
|
||||
const gchar *fn;
|
||||
g_autoptr(FuFirmware) firmware = NULL;
|
||||
@ -53,11 +55,24 @@ fu_mtd_device_setup(FuDevice *device, GError **error)
|
||||
if (!fu_firmware_parse_file(firmware, file, FWUPD_INSTALL_FLAG_NONE, error))
|
||||
return FALSE;
|
||||
|
||||
/* find the firmware child that matches any of the device GUID,
|
||||
* and use the main firmware version if no match */
|
||||
instance_ids = fu_device_get_instance_ids(device);
|
||||
for (guint i = 0; i < instance_ids->len; i++) {
|
||||
const gchar *instance_id = g_ptr_array_index(instance_ids, i);
|
||||
g_autofree gchar *guid = fwupd_guid_hash_string(instance_id);
|
||||
firmware_child = fu_firmware_get_image_by_id(firmware, guid, NULL);
|
||||
if (firmware_child != NULL)
|
||||
break;
|
||||
}
|
||||
if (firmware_child == NULL)
|
||||
firmware_child = firmware;
|
||||
|
||||
/* copy over the version */
|
||||
if (fu_firmware_get_version(firmware) != NULL)
|
||||
fu_device_set_version(device, fu_firmware_get_version(firmware));
|
||||
if (fu_firmware_get_version_raw(firmware) != G_MAXUINT64)
|
||||
fu_device_set_version_raw(device, fu_firmware_get_version_raw(firmware));
|
||||
if (fu_firmware_get_version(firmware_child) != NULL)
|
||||
fu_device_set_version(device, fu_firmware_get_version(firmware_child));
|
||||
if (fu_firmware_get_version_raw(firmware_child) != G_MAXUINT64)
|
||||
fu_device_set_version_raw(device, fu_firmware_get_version_raw(firmware_child));
|
||||
|
||||
/* success */
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user