Parse the DT chassis-type when parsing the FDT

This commit is contained in:
Richard Hughes 2023-01-18 15:10:22 +00:00
parent 5688191a7b
commit c647d0d0f6

View File

@ -15,6 +15,7 @@
gboolean
fu_hwids_fdt_setup(FuContext *ctx, FuHwids *self, GError **error)
{
g_autofree gchar *chassis_type = NULL;
g_auto(GStrv) compatible = NULL;
g_autoptr(FuFirmware) fdt_img = NULL;
g_autoptr(FuFdtImage) fdt_img_fwver = NULL;
@ -49,6 +50,26 @@ fu_hwids_fdt_setup(FuContext *ctx, FuHwids *self, GError **error)
fu_hwids_add_value(self, map[i].hwid, tmp);
}
/* chassis kind */
fu_fdt_image_get_attr_str(FU_FDT_IMAGE(fdt_img), "chassis-type", &chassis_type, NULL);
if (chassis_type != NULL) {
struct {
FuSmbiosChassisKind chassis_kind;
const gchar *dt;
} chassis_map[] = {{FU_SMBIOS_CHASSIS_KIND_CONVERTIBLE, "convertible"},
{FU_SMBIOS_CHASSIS_KIND_EMBEDDED_PC, "embedded"},
{FU_SMBIOS_CHASSIS_KIND_HAND_HELD, "handset"},
{FU_SMBIOS_CHASSIS_KIND_LAPTOP, "laptop"},
{FU_SMBIOS_CHASSIS_KIND_TABLET, "tablet"},
{FU_SMBIOS_CHASSIS_KIND_UNKNOWN, NULL}};
for (guint i = 0; chassis_map[i].dt != NULL; i++) {
if (g_strcmp0(chassis_type, chassis_map[i].dt) == 0) {
fu_context_set_chassis_kind(ctx, chassis_map[i].chassis_kind);
break;
}
}
}
/* fallback */
if (g_strv_length(compatible) > 0)
fu_hwids_add_value(self, FU_HWIDS_KEY_MANUFACTURER, compatible[0]);