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

Commit 4d708ab0 authored by Casey Leedom's avatar Casey Leedom Committed by Bjorn Helgaas
Browse files

PCI: Use pci_wait_for_pending_transaction() instead of for loop



New routine has been added to avoid duplication of code to wait for
pending PCI transactions to complete.  This makes use of that function.

Signed-off-by: default avatarCasey Leedom <leedom@chelsio.com>
Signed-off-by: default avatarVipul Pandya <vipul@chelsio.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 8903b9eb
Loading
Loading
Loading
Loading
+2 −16
Original line number Original line Diff line number Diff line
@@ -3126,9 +3126,6 @@ static int reset_intel_generic_dev(struct pci_dev *dev, int probe)


static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
{
{
	int i;
	u16 status;

	/*
	/*
	 * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf
	 * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf
	 *
	 *
@@ -3140,20 +3137,9 @@ static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
	if (probe)
	if (probe)
		return 0;
		return 0;


	/* Wait for Transaction Pending bit clean */
	if (!pci_wait_for_pending_transaction(dev))
	for (i = 0; i < 4; i++) {
		dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
		if (i)
			msleep((1 << (i - 1)) * 100);

		pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);
		if (!(status & PCI_EXP_DEVSTA_TRPND))
			goto clear;
	}

	dev_err(&dev->dev, "transaction is not cleared; "
			"proceeding with reset anyway\n");


clear:
	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);


	msleep(100);
	msleep(100);