mb/prodrive/hermes: Simplify handling board cfg
The `get_board_settings()` function always returns non-NULL, so there is
no need for NULL checks. When only one member is accessed, also drop the
local variable and directly dereference the function's return value.
Change-Id: I4fc62ca2454f4da7c8ade506064a7b0e6ba48749
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/75140
Reviewed-by: Christian Walter <christian.walter@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
diff --git a/src/mainboard/prodrive/hermes/hda_verb.c b/src/mainboard/prodrive/hermes/hda_verb.c
index 7514ce9..cab4fd3 100644
--- a/src/mainboard/prodrive/hermes/hda_verb.c
+++ b/src/mainboard/prodrive/hermes/hda_verb.c
@@ -132,9 +132,6 @@
const struct eeprom_board_settings *const board_cfg = get_board_settings();
- if (!board_cfg)
- return;
-
const u32 front_panel_cfg = get_front_panel_cfg(board_cfg->front_panel_audio);
const u32 front_mic_cfg = get_front_mic_cfg(board_cfg->front_panel_audio);
diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c
index 18bd8a4..3173522a 100644
--- a/src/mainboard/prodrive/hermes/mainboard.c
+++ b/src/mainboard/prodrive/hermes/mainboard.c
@@ -146,13 +146,8 @@
static void mainboard_init(void *chip_info)
{
- const struct eeprom_board_settings *const board_cfg = get_board_settings();
-
- if (!board_cfg)
- return;
-
/* Enable internal speaker amplifier */
- if (board_cfg->front_panel_audio == 2)
+ if (get_board_settings()->front_panel_audio == 2)
mb_hda_amp_enable(1);
else
mb_hda_amp_enable(0);
@@ -162,13 +157,8 @@
{
update_board_layout();
- const struct eeprom_board_settings *const board_cfg = get_board_settings();
-
- if (!board_cfg)
- return;
-
/* Encoding: 0 -> S0, 1 -> S5 */
- const bool on = !board_cfg->power_state_after_g3;
+ const bool on = !get_board_settings()->power_state_after_g3;
pmc_soc_set_afterg3_en(on);
}
@@ -197,9 +187,6 @@
{
const struct eeprom_board_settings *const board_cfg = get_board_settings();
- if (!board_cfg)
- return;
-
const unsigned int usb_power_gpios[] = { GPP_G0, GPP_G1, GPP_G2, GPP_G3, GPP_G4 };
/* Function pointer to write STXS or CTXS according to EEPROM board setting */
@@ -292,13 +279,11 @@
const struct eeprom_board_settings *const board_cfg = get_board_settings();
config_t *config = config_of_soc();
- if (board_cfg) {
- /* Set Deep Sx */
- config->deep_s5_enable_ac = board_cfg->deep_sx_enabled;
- config->deep_s5_enable_dc = board_cfg->deep_sx_enabled;
+ /* Set Deep Sx */
+ config->deep_s5_enable_ac = board_cfg->deep_sx_enabled;
+ config->deep_s5_enable_dc = board_cfg->deep_sx_enabled;
- config->disable_vmx = board_cfg->vtx_disabled;
- }
+ config->disable_vmx = board_cfg->vtx_disabled;
if (check_signature(offsetof(struct eeprom_layout, supd), FSPS_UPD_SIGNATURE)) {
struct {
@@ -325,11 +310,8 @@
static void mainboard_configure_internal_gfx(void *unused)
{
struct device *dev;
- const struct eeprom_board_settings *board_cfg = get_board_settings();
- if (!board_cfg)
- return;
- if (board_cfg->primary_video == PRIMARY_VIDEO_INTEL) {
+ if (get_board_settings()->primary_video == PRIMARY_VIDEO_INTEL) {
dev = dev_find_device(PCI_VID_ASPEED, PCI_DID_ASPEED_AST2050_VGA, NULL);
dev->on_mainboard = false;
dev->enabled = false;