Re: [PATCH v2 2/7] firmware: dmi: Adjust dmi_decode() to use enums

Jean Delvare
2025-12-22T16:50:20Z

On Tue, 16 Dec 2025 06:33:49 -0600, Mario Limonciello (AMD) wrote:
> dmi_decode() has hardcoded values with comments for each DMI entry
> type. The same information is already in dmi.h though, so drop the
> comments and use the definitions instead.
>
> Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> drivers/firmware/dmi_scan.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index 70d39adf50dca..80aded4c778bc 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -484,14 +484,14 @@ static void __init dmi_memdev_walk(void)
> static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
> {
> switch (dm->type) {
> - case 0: /* BIOS Information */
> + case DMI_ENTRY_BIOS:
> dmi_save_ident(dm, DMI_BIOS_VENDOR, 4);
> dmi_save_ident(dm, DMI_BIOS_VERSION, 5);
> dmi_save_ident(dm, DMI_BIOS_DATE, 8);
> dmi_save_release(dm, DMI_BIOS_RELEASE, 21);
> dmi_save_release(dm, DMI_EC_FIRMWARE_RELEASE, 23);
> break;
> - case 1: /* System Information */
> + case DMI_ENTRY_SYSTEM:
> dmi_save_ident(dm, DMI_SYS_VENDOR, 4);
> dmi_save_ident(dm, DMI_PRODUCT_NAME, 5);
> dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6);
> @@ -500,33 +500,33 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
> dmi_save_ident(dm, DMI_PRODUCT_SKU, 25);
> dmi_save_ident(dm, DMI_PRODUCT_FAMILY, 26);
> break;
> - case 2: /* Base Board Information */
> + case DMI_ENTRY_BASEBOARD:
> dmi_save_ident(dm, DMI_BOARD_VENDOR, 4);
> dmi_save_ident(dm, DMI_BOARD_NAME, 5);
> dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
> dmi_save_ident(dm, DMI_BOARD_SERIAL, 7);
> dmi_save_ident(dm, DMI_BOARD_ASSET_TAG, 8);
> break;
> - case 3: /* Chassis Information */
> + case DMI_ENTRY_CHASSIS:
> dmi_save_ident(dm, DMI_CHASSIS_VENDOR, 4);
> dmi_save_type(dm, DMI_CHASSIS_TYPE, 5);
> dmi_save_ident(dm, DMI_CHASSIS_VERSION, 6);
> dmi_save_ident(dm, DMI_CHASSIS_SERIAL, 7);
> dmi_save_ident(dm, DMI_CHASSIS_ASSET_TAG, 8);
> break;
> - case 9: /* System Slots */
> + case DMI_ENTRY_SYSTEM_SLOT:
> dmi_save_system_slot(dm);
> break;
> - case 10: /* Onboard Devices Information */
> + case DMI_ENTRY_ONBOARD_DEVICE:
> dmi_save_devices(dm);
> break;
> - case 11: /* OEM Strings */
> + case DMI_ENTRY_OEMSTRINGS:
> dmi_save_oem_strings_devices(dm);
> break;
> - case 38: /* IPMI Device Information */
> + case DMI_ENTRY_IPMI_DEV:
> dmi_save_ipmi_device(dm);
> break;
> - case 41: /* Onboard Devices Extended Information */
> + case DMI_ENTRY_ONBOARD_DEV_EXT:
> dmi_save_extended_devices(dm);
> }
> }

I'm fine with this change.

Reviewed-by: Jean Delvare <jdelvare@suse.de>

--
Jean Delvare
SUSE L3 Support