Skip to content

Commit b168979

Browse files
maciej-w-rozyckibjorn-helgaas
authored andcommitted
PCI/ASPM: Use distinct local vars in pcie_retrain_link()
Use separate local variables to hold the respective values retrieved from the Link Control Register and the Link Status Register. Improves readability and it makes it possible for the compiler to detect actual uninitialised use should this code change in the future. [bhelgaas: reorder to clean up before exposing to PCI core] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Maciej W. Rozycki <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 3bff63e commit b168979

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/pci/pcie/aspm.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,30 +197,31 @@ static bool pcie_retrain_link(struct pcie_link_state *link)
197197
{
198198
struct pci_dev *parent = link->pdev;
199199
unsigned long end_jiffies;
200-
u16 reg16;
200+
u16 lnkctl;
201+
u16 lnksta;
201202

202-
pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &reg16);
203-
reg16 |= PCI_EXP_LNKCTL_RL;
204-
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16);
203+
pcie_capability_read_word(parent, PCI_EXP_LNKCTL, &lnkctl);
204+
lnkctl |= PCI_EXP_LNKCTL_RL;
205+
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, lnkctl);
205206
if (parent->clear_retrain_link) {
206207
/*
207208
* Due to an erratum in some devices the Retrain Link bit
208209
* needs to be cleared again manually to allow the link
209210
* training to succeed.
210211
*/
211-
reg16 &= ~PCI_EXP_LNKCTL_RL;
212-
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16);
212+
lnkctl &= ~PCI_EXP_LNKCTL_RL;
213+
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, lnkctl);
213214
}
214215

215216
/* Wait for link training end. Break out after waiting for timeout */
216217
end_jiffies = jiffies + LINK_RETRAIN_TIMEOUT;
217218
do {
218-
pcie_capability_read_word(parent, PCI_EXP_LNKSTA, &reg16);
219-
if (!(reg16 & PCI_EXP_LNKSTA_LT))
219+
pcie_capability_read_word(parent, PCI_EXP_LNKSTA, &lnksta);
220+
if (!(lnksta & PCI_EXP_LNKSTA_LT))
220221
break;
221222
msleep(1);
222223
} while (time_before(jiffies, end_jiffies));
223-
return !(reg16 & PCI_EXP_LNKSTA_LT);
224+
return !(lnksta & PCI_EXP_LNKSTA_LT);
224225
}
225226

226227
/*

0 commit comments

Comments
 (0)