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 <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2023-12-22 15:53:07 +02:00 committed by Fabio Baltieri
parent 4a17446636
commit fc8b53bf10
1 changed files with 3 additions and 1 deletions

View File

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