Skip to content

Commit fc8b53b

Browse files
finikorgfabiobaltieri
authored andcommitted
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 <[email protected]>
1 parent 4a17446 commit fc8b53b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pcie/host/pcie.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static bool pcie_get_bar(pcie_bdf_t bdf,
126126
bool io)
127127
{
128128
uint32_t reg = bar_index + PCIE_CONF_BAR0;
129-
uint32_t cmd_reg = pcie_conf_read(bdf, PCIE_CONF_CMDSTAT);
129+
uint32_t cmd_reg;
130130
bool ret = false;
131131
#ifdef CONFIG_PCIE_CONTROLLER
132132
const struct device *dev;
@@ -158,6 +158,8 @@ static bool pcie_get_bar(pcie_bdf_t bdf,
158158
return false;
159159
}
160160

161+
cmd_reg = pcie_conf_read(bdf, PCIE_CONF_CMDSTAT);
162+
161163
/* IO/memory decode should be disabled before sizing/update BAR. */
162164
pcie_conf_write(bdf, PCIE_CONF_CMDSTAT,
163165
cmd_reg & (~(PCIE_CONF_CMDSTAT_IO | PCIE_CONF_CMDSTAT_MEM)));

0 commit comments

Comments
 (0)