From 73e6318ec7c043066a6fbbecf36b10afed245644 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Thu, 11 May 2023 15:38:04 +0200 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75140 Reviewed-by: Christian Walter Tested-by: build bot (Jenkins) Reviewed-by: Lean Sheng Tan --- src/mainboard/prodrive/hermes/hda_verb.c | 3 --- src/mainboard/prodrive/hermes/mainboard.c | 32 +++++++------------------------ 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/mainboard/prodrive/hermes/hda_verb.c b/src/mainboard/prodrive/hermes/hda_verb.c index 7514ce971128..cab4fd344b13 100644 --- a/src/mainboard/prodrive/hermes/hda_verb.c +++ b/src/mainboard/prodrive/hermes/hda_verb.c @@ -132,9 +132,6 @@ static void mainboard_r0x_configure_alc888(u8 *base, u32 viddid) 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 18bd8a48b717..3173522a7776 100644 --- a/src/mainboard/prodrive/hermes/mainboard.c +++ b/src/mainboard/prodrive/hermes/mainboard.c @@ -146,13 +146,8 @@ static void update_board_layout(void) 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 @@ static void mainboard_final(struct device *dev) { 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 @@ static void mainboard_acpi_fill_ssdt(const struct device *dev) { 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 @@ static void mainboard_early(void *unused) 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 @@ BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_EXIT, mainboard_early, NULL); 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; -- cgit v1.2.3