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

Commit 2a80eebc authored by Jiang Liu's avatar Jiang Liu Committed by Bjorn Helgaas
Browse files

bnx2x: Use PCI Express Capability accessors



Use PCI Express Capability access functions to simplify bnx2x driver.

[bhelgaas: split bnx2x and tg3 into separate patches]
Signed-off-by: default avatarJiang Liu <jiang.liu@huawei.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 8200bc72
Loading
Loading
Loading
Loading
+5 −20
Original line number Original line Diff line number Diff line
@@ -1162,14 +1162,9 @@ static int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func,


static u8 bnx2x_is_pcie_pending(struct pci_dev *dev)
static u8 bnx2x_is_pcie_pending(struct pci_dev *dev)
{
{
	int pos;
	u16 status;
	u16 status;


	pos = pci_pcie_cap(dev);
	pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);
	if (!pos)
		return false;

	pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status);
	return status & PCI_EXP_DEVSTA_TRPND;
	return status & PCI_EXP_DEVSTA_TRPND;
}
}


@@ -6149,8 +6144,7 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
	u16 devctl;
	u16 devctl;
	int r_order, w_order;
	int r_order, w_order;


	pci_read_config_word(bp->pdev,
	pcie_capability_read_word(bp->pdev, PCI_EXP_DEVCTL, &devctl);
			     pci_pcie_cap(bp->pdev) + PCI_EXP_DEVCTL, &devctl);
	DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
	DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
	w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
	w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
	if (bp->mrrs == -1)
	if (bp->mrrs == -1)
@@ -9386,15 +9380,10 @@ static int __devinit bnx2x_prev_mark_path(struct bnx2x *bp)


static bool __devinit bnx2x_can_flr(struct bnx2x *bp)
static bool __devinit bnx2x_can_flr(struct bnx2x *bp)
{
{
	int pos;
	u32 cap;
	u32 cap;
	struct pci_dev *dev = bp->pdev;
	struct pci_dev *dev = bp->pdev;


	pos = pci_pcie_cap(dev);
	pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
	if (!pos)
		return false;

	pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP, &cap);
	if (!(cap & PCI_EXP_DEVCAP_FLR))
	if (!(cap & PCI_EXP_DEVCAP_FLR))
		return false;
		return false;


@@ -9403,7 +9392,7 @@ static bool __devinit bnx2x_can_flr(struct bnx2x *bp)


static int __devinit bnx2x_do_flr(struct bnx2x *bp)
static int __devinit bnx2x_do_flr(struct bnx2x *bp)
{
{
	int i, pos;
	int i;
	u16 status;
	u16 status;
	struct pci_dev *dev = bp->pdev;
	struct pci_dev *dev = bp->pdev;


@@ -9411,16 +9400,12 @@ static int __devinit bnx2x_do_flr(struct bnx2x *bp)
	if (bnx2x_can_flr(bp))
	if (bnx2x_can_flr(bp))
		return -ENOTTY;
		return -ENOTTY;


	pos = pci_pcie_cap(dev);
	if (!pos)
		return -ENOTTY;

	/* Wait for Transaction Pending bit clean */
	/* Wait for Transaction Pending bit clean */
	for (i = 0; i < 4; i++) {
	for (i = 0; i < 4; i++) {
		if (i)
		if (i)
			msleep((1 << (i - 1)) * 100);
			msleep((1 << (i - 1)) * 100);


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