From fc8b53bf106b16902f51b2f9857b2518cba16724 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Fri, 22 Dec 2023 15:53:07 +0200 Subject: [PATCH] drivers: pcie: Read register before actual usage Move reading PCIE_CONF_CMDSTAT before actual usage. There are four return branches before value is used. Signed-off-by: Andrei Emeltchenko --- drivers/pcie/host/pcie.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pcie/host/pcie.c b/drivers/pcie/host/pcie.c index 52c7053e5b7..d8e04a9ed73 100644 --- a/drivers/pcie/host/pcie.c +++ b/drivers/pcie/host/pcie.c @@ -126,7 +126,7 @@ static bool pcie_get_bar(pcie_bdf_t bdf, bool io) { uint32_t reg = bar_index + PCIE_CONF_BAR0; - uint32_t cmd_reg = pcie_conf_read(bdf, PCIE_CONF_CMDSTAT); + uint32_t cmd_reg; bool ret = false; #ifdef CONFIG_PCIE_CONTROLLER const struct device *dev; @@ -158,6 +158,8 @@ static bool pcie_get_bar(pcie_bdf_t bdf, return false; } + cmd_reg = pcie_conf_read(bdf, PCIE_CONF_CMDSTAT); + /* IO/memory decode should be disabled before sizing/update BAR. */ pcie_conf_write(bdf, PCIE_CONF_CMDSTAT, cmd_reg & (~(PCIE_CONF_CMDSTAT_IO | PCIE_CONF_CMDSTAT_MEM)));