]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
r8169: remove unnecessary read of PCI_CAP_ID_EXP
authorJon Mason <jdmason@kudzu.us>
Mon, 27 Jun 2011 07:46:31 +0000 (07:46 +0000)
committerJoe Jin <joe.jin@oracle.com>
Fri, 18 May 2012 02:01:51 +0000 (10:01 +0800)
The PCIE capability offset is saved during PCI bus walking.  Use the
value from pci_dev instead of checking in the driver and saving it off
the the driver specific structure.  Also, it will remove an unnecessary
search in the PCI configuration space if this value is referenced
instead of reacquiring it.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit e44daaded19baf8b7cf9ab3dedad8a01b8c49251)

Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/r8169.c

index 5f838ef924945c79360fc4b51f3ab49568694a3f..b3448009f498422bbc78a9e7c6fe7f62961ef9d2 100644 (file)
@@ -659,7 +659,6 @@ struct rtl8169_private {
        unsigned int (*phy_reset_pending)(struct rtl8169_private *tp);
        unsigned int (*link_ok)(void __iomem *);
        int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
-       int pcie_cap;
        struct delayed_work task;
        unsigned features;
 
@@ -3350,9 +3349,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        tp->mmio_addr = ioaddr;
 
-       tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-       if (!tp->pcie_cap)
-               netif_info(tp, probe, dev, "no PCI Express capability\n");
+       if (!pci_is_pcie(pdev))
+               netif_info(tp, probe, dev, "not PCI Express\n");
 
        RTL_W16(IntrMask, 0x0000);
 
@@ -3781,9 +3779,7 @@ static void rtl_hw_start_8169(struct net_device *dev)
 
 static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force)
 {
-       struct net_device *dev = pci_get_drvdata(pdev);
-       struct rtl8169_private *tp = netdev_priv(dev);
-       int cap = tp->pcie_cap;
+       int cap = pci_pcie_cap(pdev);
 
        if (cap) {
                u16 ctl;
@@ -3831,9 +3827,7 @@ static void rtl_ephy_init(void __iomem *ioaddr, const struct ephy_info *e, int l
 
 static void rtl_disable_clock_request(struct pci_dev *pdev)
 {
-       struct net_device *dev = pci_get_drvdata(pdev);
-       struct rtl8169_private *tp = netdev_priv(dev);
-       int cap = tp->pcie_cap;
+       int cap = pci_pcie_cap(pdev);
 
        if (cap) {
                u16 ctl;
@@ -3846,9 +3840,7 @@ static void rtl_disable_clock_request(struct pci_dev *pdev)
 
 static void rtl_enable_clock_request(struct pci_dev *pdev)
 {
-       struct net_device *dev = pci_get_drvdata(pdev);
-       struct rtl8169_private *tp = netdev_priv(dev);
-       int cap = tp->pcie_cap;
+       int cap = pci_pcie_cap(pdev);
 
        if (cap) {
                u16 ctl;
@@ -4278,7 +4270,7 @@ static void rtl_hw_start_8101(struct net_device *dev)
 
        if (tp->mac_version == RTL_GIGA_MAC_VER_13 ||
            tp->mac_version == RTL_GIGA_MAC_VER_16) {
-               int cap = tp->pcie_cap;
+               int cap = pci_pcie_cap(pdev);
 
                if (cap) {
                        pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL,