aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x
diff options
context:
space:
mode:
authorJiang Liu <jiang.liu@huawei.com>2012-08-20 15:26:51 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-08-23 12:11:12 -0400
commit2a80eebcbf3e0f2cc7df6aced54058fbdff37518 (patch)
treec5c854465d31f1450080263f3f503e8bbae02c3e /drivers/net/ethernet/broadcom/bnx2x
parent8200bc72a88cbb63ee13d7f9f16ec4f7249c2ec2 (diff)
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: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index dd451c3dd83d..281cf3f7bc20 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -1162,14 +1162,9 @@ static int bnx2x_send_final_clnup(struct bnx2x *bp, u8 clnup_func,
1162 1162
1163static u8 bnx2x_is_pcie_pending(struct pci_dev *dev) 1163static u8 bnx2x_is_pcie_pending(struct pci_dev *dev)
1164{ 1164{
1165 int pos;
1166 u16 status; 1165 u16 status;
1167 1166
1168 pos = pci_pcie_cap(dev); 1167 pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);
1169 if (!pos)
1170 return false;
1171
1172 pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status);
1173 return status & PCI_EXP_DEVSTA_TRPND; 1168 return status & PCI_EXP_DEVSTA_TRPND;
1174} 1169}
1175 1170
@@ -6149,8 +6144,7 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
6149 u16 devctl; 6144 u16 devctl;
6150 int r_order, w_order; 6145 int r_order, w_order;
6151 6146
6152 pci_read_config_word(bp->pdev, 6147 pcie_capability_read_word(bp->pdev, PCI_EXP_DEVCTL, &devctl);
6153 pci_pcie_cap(bp->pdev) + PCI_EXP_DEVCTL, &devctl);
6154 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl); 6148 DP(NETIF_MSG_HW, "read 0x%x from devctl\n", devctl);
6155 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5); 6149 w_order = ((devctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
6156 if (bp->mrrs == -1) 6150 if (bp->mrrs == -1)
@@ -9386,15 +9380,10 @@ static int __devinit bnx2x_prev_mark_path(struct bnx2x *bp)
9386 9380
9387static bool __devinit bnx2x_can_flr(struct bnx2x *bp) 9381static bool __devinit bnx2x_can_flr(struct bnx2x *bp)
9388{ 9382{
9389 int pos;
9390 u32 cap; 9383 u32 cap;
9391 struct pci_dev *dev = bp->pdev; 9384 struct pci_dev *dev = bp->pdev;
9392 9385
9393 pos = pci_pcie_cap(dev); 9386 pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
9394 if (!pos)
9395 return false;
9396
9397 pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP, &cap);
9398 if (!(cap & PCI_EXP_DEVCAP_FLR)) 9387 if (!(cap & PCI_EXP_DEVCAP_FLR))
9399 return false; 9388 return false;
9400 9389
@@ -9403,7 +9392,7 @@ static bool __devinit bnx2x_can_flr(struct bnx2x *bp)
9403 9392
9404static int __devinit bnx2x_do_flr(struct bnx2x *bp) 9393static int __devinit bnx2x_do_flr(struct bnx2x *bp)
9405{ 9394{
9406 int i, pos; 9395 int i;
9407 u16 status; 9396 u16 status;
9408 struct pci_dev *dev = bp->pdev; 9397 struct pci_dev *dev = bp->pdev;
9409 9398
@@ -9411,16 +9400,12 @@ static int __devinit bnx2x_do_flr(struct bnx2x *bp)
9411 if (bnx2x_can_flr(bp)) 9400 if (bnx2x_can_flr(bp))
9412 return -ENOTTY; 9401 return -ENOTTY;
9413 9402
9414 pos = pci_pcie_cap(dev);
9415 if (!pos)
9416 return -ENOTTY;
9417
9418 /* Wait for Transaction Pending bit clean */ 9403 /* Wait for Transaction Pending bit clean */
9419 for (i = 0; i < 4; i++) { 9404 for (i = 0; i < 4; i++) {
9420 if (i) 9405 if (i)
9421 msleep((1 << (i - 1)) * 100); 9406 msleep((1 << (i - 1)) * 100);
9422 9407
9423 pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &status); 9408 pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &status);
9424 if (!(status & PCI_EXP_DEVSTA_TRPND)) 9409 if (!(status & PCI_EXP_DEVSTA_TRPND))
9425 goto clear; 9410 goto clear;
9426 } 9411 }