Skip to content

Commit f5297a0

Browse files
committed
PCI/ASPM: Return 0 or -ETIMEDOUT from pcie_retrain_link()
"pcie_retrain_link" is not a question with a true/false answer, so "bool" isn't quite the right return type. Return 0 for success or -ETIMEDOUT if the retrain failed. No functional change intended. [bhelgaas: based on Ilpo's patch below] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 911afb9 commit f5297a0

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

drivers/pci/pcie/aspm.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void pcie_clkpm_cap_init(struct pcie_link_state *link, int blacklist)
193193
link->clkpm_disable = blacklist ? 1 : 0;
194194
}
195195

196-
static bool pcie_retrain_link(struct pcie_link_state *link)
196+
static int pcie_retrain_link(struct pcie_link_state *link)
197197
{
198198
struct pci_dev *parent = link->pdev;
199199
unsigned long end_jiffies;
@@ -220,7 +220,9 @@ static bool pcie_retrain_link(struct pcie_link_state *link)
220220
break;
221221
msleep(1);
222222
} while (time_before(jiffies, end_jiffies));
223-
return !(reg16 & PCI_EXP_LNKSTA_LT);
223+
if (reg16 & PCI_EXP_LNKSTA_LT)
224+
return -ETIMEDOUT;
225+
return 0;
224226
}
225227

226228
/*
@@ -289,15 +291,15 @@ static void pcie_aspm_configure_common_clock(struct pcie_link_state *link)
289291
reg16 &= ~PCI_EXP_LNKCTL_CCC;
290292
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, reg16);
291293

292-
if (pcie_retrain_link(link))
293-
return;
294+
if (pcie_retrain_link(link)) {
294295

295-
/* Training failed. Restore common clock configurations */
296-
pci_err(parent, "ASPM: Could not configure common clock\n");
297-
list_for_each_entry(child, &linkbus->devices, bus_list)
298-
pcie_capability_write_word(child, PCI_EXP_LNKCTL,
296+
/* Training failed. Restore common clock configurations */
297+
pci_err(parent, "ASPM: Could not configure common clock\n");
298+
list_for_each_entry(child, &linkbus->devices, bus_list)
299+
pcie_capability_write_word(child, PCI_EXP_LNKCTL,
299300
child_reg[PCI_FUNC(child->devfn)]);
300-
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, parent_reg);
301+
pcie_capability_write_word(parent, PCI_EXP_LNKCTL, parent_reg);
302+
}
301303
}
302304

303305
/* Convert L0s latency encoding to ns */

0 commit comments

Comments
 (0)