Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44020 )
Change subject: arch/x86/smbios.c: Clean up cosmetics ......................................................................
arch/x86/smbios.c: Clean up cosmetics
Put `__weak` at the beginning of functions and reflow lines to leverage the increased line width of 96 characters.
Tested with BUILD_TIMELESS=1, Asrock B85M Pro4 does not change.
Change-Id: I3a5fd2d4344b83e09f89053c083ec80aa297061e Signed-off-by: Angel Pons th3fanbus@gmail.com --- M src/arch/x86/smbios.c 1 file changed, 73 insertions(+), 111 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/20/44020/1
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 47b54aa..739bb5f 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -73,7 +73,6 @@ } }
- int smbios_add_string(u8 *start, const char *str) { int i = 1; @@ -159,75 +158,59 @@ }
/* this function will fill the corresponding manufacturer */ -void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, - struct smbios_type17 *t) +void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, struct smbios_type17 *t) { switch (mod_id) { case 0x9b85: - t->manufacturer = smbios_add_string(t->eos, - "Crucial"); + t->manufacturer = smbios_add_string(t->eos, "Crucial"); break; case 0x4304: - t->manufacturer = smbios_add_string(t->eos, - "Ramaxel"); + t->manufacturer = smbios_add_string(t->eos, "Ramaxel"); break; case 0x4f01: - t->manufacturer = smbios_add_string(t->eos, - "Transcend"); + t->manufacturer = smbios_add_string(t->eos, "Transcend"); break; case 0x9801: - t->manufacturer = smbios_add_string(t->eos, - "Kingston"); + t->manufacturer = smbios_add_string(t->eos, "Kingston"); break; case 0x987f: - t->manufacturer = smbios_add_string(t->eos, - "Hynix"); + t->manufacturer = smbios_add_string(t->eos, "Hynix"); break; case 0x9e02: - t->manufacturer = smbios_add_string(t->eos, - "Corsair"); + t->manufacturer = smbios_add_string(t->eos, "Corsair"); break; case 0xb004: - t->manufacturer = smbios_add_string(t->eos, - "OCZ"); + t->manufacturer = smbios_add_string(t->eos, "OCZ"); break; case 0xad80: - t->manufacturer = smbios_add_string(t->eos, - "Hynix/Hyundai"); + t->manufacturer = smbios_add_string(t->eos, "Hynix/Hyundai"); break; case 0x3486: - t->manufacturer = smbios_add_string(t->eos, - "Super Talent"); + t->manufacturer = smbios_add_string(t->eos, "Super Talent"); break; case 0xcd04: - t->manufacturer = smbios_add_string(t->eos, - "GSkill"); + t->manufacturer = smbios_add_string(t->eos, "GSkill"); break; case 0xce80: - t->manufacturer = smbios_add_string(t->eos, - "Samsung"); + t->manufacturer = smbios_add_string(t->eos, "Samsung"); break; case 0xfe02: - t->manufacturer = smbios_add_string(t->eos, - "Elpida"); + t->manufacturer = smbios_add_string(t->eos, "Elpida"); break; case 0x2c80: - t->manufacturer = smbios_add_string(t->eos, - "Micron"); + t->manufacturer = smbios_add_string(t->eos, "Micron"); break; default: { char string_buffer[256];
- snprintf(string_buffer, sizeof(string_buffer), - "Unknown (%x)", mod_id); - t->manufacturer = smbios_add_string(t->eos, - string_buffer); + 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 locator */ -void __weak smbios_fill_dimm_locator(const struct dimm_info *dimm, +__weak void smbios_fill_dimm_locator(const struct dimm_info *dimm, struct smbios_type17 *t) { char locator[40]; @@ -428,7 +411,7 @@ return coreboot_version; }
-const char *__weak smbios_mainboard_bios_version(void) +__weak const char *smbios_mainboard_bios_version(void) { return NULL; } @@ -483,42 +466,42 @@ return len; }
-const char *__weak smbios_mainboard_serial_number(void) +__weak const char *smbios_mainboard_serial_number(void) { return CONFIG_MAINBOARD_SERIAL_NUMBER; }
-const char *__weak smbios_mainboard_version(void) +__weak const char *smbios_mainboard_version(void) { return CONFIG_MAINBOARD_VERSION; }
-const char *__weak smbios_mainboard_manufacturer(void) +__weak const char *smbios_mainboard_manufacturer(void) { return CONFIG_MAINBOARD_SMBIOS_MANUFACTURER; }
-const char *__weak smbios_mainboard_product_name(void) +__weak const char *smbios_mainboard_product_name(void) { return CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME; }
-const char *__weak smbios_mainboard_asset_tag(void) +__weak const char *smbios_mainboard_asset_tag(void) { return ""; }
-u8 __weak smbios_mainboard_feature_flags(void) +__weak u8 smbios_mainboard_feature_flags(void) { return 0; }
-const char *__weak smbios_mainboard_location_in_chassis(void) +__weak const char *smbios_mainboard_location_in_chassis(void) { return ""; }
-smbios_board_type __weak smbios_mainboard_board_type(void) +__weak smbios_board_type smbios_mainboard_board_type(void) { return SMBIOS_BOARD_TYPE_UNKNOWN; } @@ -529,7 +512,7 @@ * convertible, or tablet enclosure will be used if the appropriate * system type is selected. */ -smbios_enclosure_type __weak smbios_mainboard_enclosure_type(void) +__weak smbios_enclosure_type smbios_mainboard_enclosure_type(void) { if (CONFIG(SYSTEM_TYPE_LAPTOP)) return SMBIOS_ENCLOSURE_LAPTOP; @@ -543,57 +526,57 @@ return SMBIOS_ENCLOSURE_DESKTOP; }
-const char *__weak smbios_system_serial_number(void) +__weak const char *smbios_system_serial_number(void) { return smbios_mainboard_serial_number(); }
-const char *__weak smbios_system_version(void) +__weak const char *smbios_system_version(void) { return smbios_mainboard_version(); }
-const char *__weak smbios_system_manufacturer(void) +__weak const char *smbios_system_manufacturer(void) { return smbios_mainboard_manufacturer(); }
-const char *__weak smbios_system_product_name(void) +__weak const char *smbios_system_product_name(void) { return smbios_mainboard_product_name(); }
-void __weak smbios_system_set_uuid(u8 *uuid) +__weak void smbios_system_set_uuid(u8 *uuid) { /* leave all zero */ }
-unsigned int __weak smbios_cpu_get_max_speed_mhz(void) +__weak unsigned int smbios_cpu_get_max_speed_mhz(void) { return 0; /* Unknown */ }
-unsigned int __weak smbios_cpu_get_current_speed_mhz(void) +__weak unsigned int smbios_cpu_get_current_speed_mhz(void) { return 0; /* Unknown */ }
-const char *__weak smbios_system_sku(void) +__weak const char *smbios_system_sku(void) { return ""; }
-const char * __weak smbios_chassis_version(void) +__weak const char *smbios_chassis_version(void) { return ""; }
-const char * __weak smbios_chassis_serial_number(void) +__weak const char *smbios_chassis_serial_number(void) { return ""; }
-const char * __weak smbios_processor_serial_number(void) +__weak const char *smbios_processor_serial_number(void) { return ""; } @@ -636,8 +619,7 @@ return len; }
-static int smbios_write_type2(unsigned long *current, int handle, - const int chassis_handle) +static int smbios_write_type2(unsigned long *current, int handle, const int chassis_handle) { struct smbios_type2 *t = (struct smbios_type2 *)*current; int len = sizeof(struct smbios_type2); @@ -646,12 +628,9 @@ t->type = SMBIOS_BOARD_INFORMATION; t->handle = handle; t->length = len - 2; - t->manufacturer = smbios_add_string(t->eos, - smbios_mainboard_manufacturer()); - t->product_name = smbios_add_string(t->eos, - smbios_mainboard_product_name()); - t->serial_number = smbios_add_string(t->eos, - smbios_mainboard_serial_number()); + t->manufacturer = smbios_add_string(t->eos, smbios_mainboard_manufacturer()); + t->product_name = smbios_add_string(t->eos, smbios_mainboard_product_name()); + t->serial_number = smbios_add_string(t->eos, smbios_mainboard_serial_number()); t->version = smbios_add_string(t->eos, smbios_mainboard_version()); t->asset_tag = smbios_add_string(t->eos, smbios_mainboard_asset_tag()); t->feature_flags = smbios_mainboard_feature_flags(); @@ -673,8 +652,7 @@ t->type = SMBIOS_SYSTEM_ENCLOSURE; t->handle = handle; t->length = len - 2; - t->manufacturer = smbios_add_string(t->eos, - smbios_system_manufacturer()); + t->manufacturer = smbios_add_string(t->eos, smbios_system_manufacturer()); t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE; t->thermal_state = SMBIOS_STATE_SAFE; @@ -762,15 +740,14 @@ * Fill in some fields with constant values, as gathering the information * from CPUID is impossible. */ -static int -smbios_write_type7(unsigned long *current, - const int handle, - const u8 level, - const u8 sram_type, - const enum smbios_cache_associativity associativity, - const enum smbios_cache_type type, - const size_t max_cache_size, - const size_t cache_size) +static int smbios_write_type7(unsigned long *current, + const int handle, + const u8 level, + const u8 sram_type, + const enum smbios_cache_associativity associativity, + const enum smbios_cache_type type, + const size_t max_cache_size, + const size_t cache_size) { struct smbios_type7 *t = (struct smbios_type7 *)*current; int len = sizeof(struct smbios_type7); @@ -837,8 +814,7 @@ }
/* Convert the associativity as integer to the SMBIOS enum if available */ -static enum smbios_cache_associativity -smbios_cache_associativity(const u8 num) +static enum smbios_cache_associativity smbios_cache_associativity(const u8 num) { switch (num) { case 1: @@ -924,8 +900,7 @@ const size_t partitions = CPUID_CACHE_PHYS_LINE(res) + 1; const size_t cache_line_size = CPUID_CACHE_COHER_LINE(res) + 1; const size_t number_of_sets = CPUID_CACHE_NO_OF_SETS(res) + 1; - const size_t cache_size = assoc * partitions * cache_line_size * - number_of_sets; + const size_t cache_size = assoc * partitions * cache_line_size * number_of_sets;
if (!cache_type) /* No more caches in the system */ @@ -1272,7 +1247,7 @@
/* Generate Type41 entries from devicetree */ static int smbios_walk_device_tree_type41(struct device *dev, int *handle, - unsigned long *current) + unsigned long *current) { static u8 type41_inst_cnt[SMBIOS_DEVICE_TYPE_COUNT + 1] = {};
@@ -1352,16 +1327,14 @@ dev->path.pci.devfn); }
-static int smbios_walk_device_tree(struct device *tree, int *handle, - unsigned long *current) +static int smbios_walk_device_tree(struct device *tree, int *handle, unsigned long *current) { struct device *dev; int len = 0;
for (dev = tree; dev; dev = dev->next) { if (dev->enabled && dev->ops && dev->ops->get_smbios_data) { - printk(BIOS_INFO, "%s (%s)\n", dev_path(dev), - dev_name(dev)); + printk(BIOS_INFO, "%s (%s)\n", dev_path(dev), dev_name(dev)); len += dev->ops->get_smbios_data(dev, handle, current); } len += smbios_walk_device_tree_type9(dev, handle, current); @@ -1391,42 +1364,32 @@ current = ALIGN_UP(current, 16);
tables = current; - update_max(len, max_struct_size, smbios_write_type0(¤t, - handle++)); - update_max(len, max_struct_size, smbios_write_type1(¤t, - handle++)); - update_max(len, max_struct_size, smbios_write_type2(¤t, - handle, handle + 1)); /* The chassis handle is the next one */ + update_max(len, max_struct_size, smbios_write_type0(¤t, handle++)); + update_max(len, max_struct_size, smbios_write_type1(¤t, handle++)); + + /* The chassis handle is the next one */ + update_max(len, max_struct_size, smbios_write_type2(¤t, handle, handle + 1)); handle++; - update_max(len, max_struct_size, smbios_write_type3(¤t, - handle++)); + update_max(len, max_struct_size, smbios_write_type3(¤t, handle++));
struct smbios_type4 *type4 = (struct smbios_type4 *)current; - update_max(len, max_struct_size, smbios_write_type4(¤t, - handle++)); - len += smbios_write_type7_cache_parameters(¤t, &handle, - &max_struct_size, type4); - update_max(len, max_struct_size, smbios_write_type11(¤t, - &handle)); + update_max(len, max_struct_size, smbios_write_type4(¤t, handle++)); + len += smbios_write_type7_cache_parameters(¤t, &handle, &max_struct_size, type4); + update_max(len, max_struct_size, smbios_write_type11(¤t, &handle)); if (CONFIG(ELOG)) update_max(len, max_struct_size, - elog_smbios_write_type15(¤t,handle++)); + elog_smbios_write_type15(¤t, handle++));
const int type16 = handle; - update_max(len, max_struct_size, smbios_write_type16(¤t, - &handle)); - update_max(len, max_struct_size, smbios_write_type17(¤t, - &handle, type16)); - update_max(len, max_struct_size, smbios_write_type19(¤t, - &handle)); - update_max(len, max_struct_size, smbios_write_type32(¤t, - handle++)); + update_max(len, max_struct_size, smbios_write_type16(¤t, &handle)); + update_max(len, max_struct_size, smbios_write_type17(¤t, &handle, type16)); + update_max(len, max_struct_size, smbios_write_type19(¤t, &handle)); + update_max(len, max_struct_size, smbios_write_type32(¤t, handle++));
update_max(len, max_struct_size, smbios_walk_device_tree(all_devices, - &handle, ¤t)); + &handle, ¤t));
- update_max(len, max_struct_size, smbios_write_type127(¤t, - handle++)); + update_max(len, max_struct_size, smbios_write_type127(¤t, handle++));
/* Install SMBIOS 2.1 entry point */ memset(se, 0, sizeof(struct smbios_entry)); @@ -1442,8 +1405,7 @@ se->struct_table_length = len;
se->intermediate_checksum = smbios_checksum((u8 *)se + 0x10, - sizeof(struct smbios_entry) - - 0x10); + sizeof(struct smbios_entry) - 0x10); se->checksum = smbios_checksum((u8 *)se, sizeof(struct smbios_entry));
/* Install SMBIOS 3.0 entry point */