From patchwork Mon Jun 27 17:46:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 102236 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 5D11AB6F65 for ; Tue, 28 Jun 2011 03:46:47 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559Ab1F0Rqj (ORCPT ); Mon, 27 Jun 2011 13:46:39 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:48728 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752598Ab1F0Rqg (ORCPT ); Mon, 27 Jun 2011 13:46:36 -0400 Received: by pvg12 with SMTP id 12so2993071pvg.19 for ; Mon, 27 Jun 2011 10:46:35 -0700 (PDT) Received: by 10.68.31.40 with SMTP id x8mr3023246pbh.114.1309196795760; Mon, 27 Jun 2011 10:46:35 -0700 (PDT) Received: from scylla (cpe-70-113-48-102.austin.res.rr.com [70.113.48.102]) by mx.google.com with ESMTPS id d1sm4457436pbj.56.2011.06.27.10.46.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 10:46:34 -0700 (PDT) Received: by scylla (sSMTP sendmail emulation); Mon, 27 Jun 2011 12:46:31 -0500 From: Jon Mason To: nic_swsd@realtek.com Cc: Francois Romieu , netdev@vger.kernel.org Subject: [PATCH 13/19] r8169: remove unnecessary read of PCI_CAP_ID_EXP Date: Mon, 27 Jun 2011 12:46:31 -0500 Message-Id: <1309196791-16157-1-git-send-email-jdmason@kudzu.us> X-Mailer: git-send-email 1.7.5.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/net/r8169.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index f8c4435..fbd6838 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -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; @@ -3444,9 +3443,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); @@ -3898,9 +3896,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; @@ -3948,9 +3944,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; @@ -3963,9 +3957,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; @@ -4395,7 +4387,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,