Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac10836b authored by Yijing Wang's avatar Yijing Wang Committed by Bjorn Helgaas
Browse files

PCI: pciehp: Simplify pcie_poll_cmd()



Move first slot status read into while to simplify code.

Signed-off-by: default avatarYijing Wang <wangyijing@huawei.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent a6ed1f4e
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -109,21 +109,17 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
	struct pci_dev *pdev = ctrl_dev(ctrl);
	u16 slot_status;

	while (true) {
		pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
		if (slot_status & PCI_EXP_SLTSTA_CC) {
			pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
						   PCI_EXP_SLTSTA_CC);
			return 1;
		}
	while (timeout > 0) {
		if (timeout < 0)
			break;
		msleep(10);
		timeout -= 10;
		pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
		if (slot_status & PCI_EXP_SLTSTA_CC) {
			pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
						   PCI_EXP_SLTSTA_CC);
			return 1;
		}
	}
	return 0;	/* timeout */
}