diff options
author | Angel Pons <th3fanbus@gmail.com> | 2020-07-29 18:29:28 +0200 |
---|---|---|
committer | Angel Pons <th3fanbus@gmail.com> | 2020-07-30 22:47:17 +0000 |
commit | 9630ced250a43161256c64b6c06ed671bba5dcc4 (patch) | |
tree | 7df24f11e93f0ab043dfb3b9149616ee51710ba5 /src/arch | |
parent | 3c13da78971183e0689475b16f05919210aea073 (diff) |
arch/x86/smbios.c: Factor out switch-case block
Most of `smbios_fill_dimm_manufacturer_from_id()` is noise. Factor the
switch into its own function to improve readability.
Change-Id: Ia0757c01572709d16589a4ed622ca2d2cb69dda2
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44022
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/smbios.c | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 07ccacfa25..1b51d903d1 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -157,56 +157,52 @@ static int smbios_processor_name(u8 *start) return smbios_add_string(start, str); } -/* this function will fill the corresponding manufacturer */ -void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, struct smbios_type17 *t) +static const char *get_dimm_manufacturer_name(const uint16_t mod_id) { switch (mod_id) { case 0x9b85: - t->manufacturer = smbios_add_string(t->eos, "Crucial"); - break; + return "Crucial"; case 0x4304: - t->manufacturer = smbios_add_string(t->eos, "Ramaxel"); - break; + return "Ramaxel"; case 0x4f01: - t->manufacturer = smbios_add_string(t->eos, "Transcend"); - break; + return "Transcend"; case 0x9801: - t->manufacturer = smbios_add_string(t->eos, "Kingston"); - break; + return "Kingston"; case 0x987f: - t->manufacturer = smbios_add_string(t->eos, "Hynix"); - break; + return "Hynix"; case 0x9e02: - t->manufacturer = smbios_add_string(t->eos, "Corsair"); - break; + return "Corsair"; case 0xb004: - t->manufacturer = smbios_add_string(t->eos, "OCZ"); - break; + return "OCZ"; case 0xad80: - t->manufacturer = smbios_add_string(t->eos, "Hynix/Hyundai"); - break; + return "Hynix/Hyundai"; case 0x3486: - t->manufacturer = smbios_add_string(t->eos, "Super Talent"); - break; + return "Super Talent"; case 0xcd04: - t->manufacturer = smbios_add_string(t->eos, "GSkill"); - break; + return "GSkill"; case 0xce80: - t->manufacturer = smbios_add_string(t->eos, "Samsung"); - break; + return "Samsung"; case 0xfe02: - t->manufacturer = smbios_add_string(t->eos, "Elpida"); - break; + return "Elpida"; case 0x2c80: - t->manufacturer = smbios_add_string(t->eos, "Micron"); - break; - default: { - char string_buffer[256]; + return "Micron"; + default: + return NULL; + } +} - snprintf(string_buffer, sizeof(string_buffer), "Unknown (%x)", mod_id); - t->manufacturer = smbios_add_string(t->eos, string_buffer); - break; - } +/* this function will fill the corresponding manufacturer */ +void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, struct smbios_type17 *t) +{ + const char *const manufacturer = get_dimm_manufacturer_name(mod_id); + + if (manufacturer) { + t->manufacturer = smbios_add_string(t->eos, manufacturer); + } else { + char string_buffer[256]; + + snprintf(string_buffer, sizeof(string_buffer), "Unknown (%x)", mod_id); + t->manufacturer = smbios_add_string(t->eos, string_buffer); } } /* this function will fill the corresponding locator */ |