aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-11-08 13:18:55 +0200
committerBjorn Helgaas <bhelgaas@google.com>2019-11-11 18:15:36 -0600
commitb94ec12dfaee41bdd6a8b6d75e5715d9ba2c92cc (patch)
treee61728baa7e31add2cba66d9b455a631fa745221 /drivers/pci/hotplug
parentPCI: pciehp: Avoid returning prematurely from sysfs requests (diff)
downloadwireguard-linux-b94ec12dfaee41bdd6a8b6d75e5715d9ba2c92cc.tar.xz
wireguard-linux-b94ec12dfaee41bdd6a8b6d75e5715d9ba2c92cc.zip
PCI: pciehp: Refactor infinite loop in pcie_poll_cmd()
Infinite timeout loops are hard to read. Refactor it to plausible 'do {} while ()'. Note, the supplied timeout can't be negative for current use, though if it's not dividable to 10, we may go below 0, that's why type of the parameter is int. And thus, we may move the check to the loop condition. No functional change intended. Link: https://lore.kernel.org/r/20191108111855.85866-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 86d97f3112f0..764384153c7d 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -68,7 +68,7 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
struct pci_dev *pdev = ctrl_dev(ctrl);
u16 slot_status;
- while (true) {
+ do {
pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
if (slot_status == (u16) ~0) {
ctrl_info(ctrl, "%s: no response from device\n",
@@ -81,11 +81,9 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
PCI_EXP_SLTSTA_CC);
return 1;
}
- if (timeout < 0)
- break;
msleep(10);
timeout -= 10;
- }
+ } while (timeout >= 0);
return 0; /* timeout */
}