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>
This commit is contained in:
Angel Pons 2023-05-11 15:38:04 +02:00 committed by Lean Sheng Tan
parent e0b1406276
commit 73e6318ec7
2 changed files with 7 additions and 28 deletions

View File

@ -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);

View File

@ -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;