From patchwork Tue Jul 24 16:31:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1232291 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 9AF9C3FD4F for ; Tue, 24 Jul 2012 16:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755949Ab2GXQfv (ORCPT ); Tue, 24 Jul 2012 12:35:51 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39412 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753909Ab2GXQft (ORCPT ); Tue, 24 Jul 2012 12:35:49 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so12916328pbb.19 for ; Tue, 24 Jul 2012 09:35:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=5vWtXwvZsxM1b0CnYJNo7gurt6qIRC/mTCwrYNcirZI=; b=mV4RnSnzPmPJWm3sxntZ3FqF93ageJgmZNKOZtGpiqtuDbAMes47XQvYIGunSYdJA0 np+RJmbDb2AyXmz8J5VXHQLh9ThwjQ4t0yR34/LyqbqyFXE6W6BVYJr9lZNsE/E/fPLg 94UUPHH+Mj4BcaBPY0PCctt+K0FovX53m7Q78VCLjbxujdD1Yud1wGWOYG3FfRUwVA6Y 5u642jLzV7XC6TDiCpJ87FE+hZGtQntf79RqVdscWCT68YspFvf/p1/ZdQ+bCKKJ/m5W eD8e86PeE4A7rHs+Fbgtuln4wNi771Qc6MPD1moqBSQZZ0nD+s2L63WIjI63cAm63olC XKYw== Received: by 10.68.194.4 with SMTP id hs4mr45540847pbc.128.1343147749270; Tue, 24 Jul 2012 09:35:49 -0700 (PDT) Received: from localhost.localdomain ([221.221.26.244]) by mx.google.com with ESMTPS id wi6sm12457583pbc.35.2012.07.24.09.35.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 09:35:48 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile Cc: Jiang Liu , Yinghai Lu , Taku Izumi , "Rafael J . Wysocki" , Kenji Kaneshige , Yijing Wang , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH v2 15/32] PCI/r8169: use PCIe capabilities access functions to simplify implementation Date: Wed, 25 Jul 2012 00:31:27 +0800 Message-Id: <1343147504-25891-16-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343147504-25891-1-git-send-email-jiang.liu@huawei.com> References: <1343147504-25891-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jiang Liu Use PCIe capabilities access functions to simplify r8169 driver's implementation. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang --- drivers/net/ethernet/realtek/r8169.c | 35 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 9757ce3..2f6ff78 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -807,14 +807,12 @@ static void rtl_unlock_work(struct rtl8169_private *tp) static void rtl_tx_performance_tweak(struct pci_dev *pdev, u16 force) { - int cap = pci_pcie_cap(pdev); - - if (cap) { + if (pci_is_pcie(pdev)) { u16 ctl; - pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl); + pci_pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &ctl); ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | force; - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl); + pci_pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, ctl); } } @@ -4504,27 +4502,23 @@ 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) { - int cap = pci_pcie_cap(pdev); - - if (cap) { + if (pci_is_pcie(pdev)) { u16 ctl; - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); + pci_pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &ctl); ctl &= ~PCI_EXP_LNKCTL_CLKREQ_EN; - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); + pci_pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, ctl); } } static void rtl_enable_clock_request(struct pci_dev *pdev) { - int cap = pci_pcie_cap(pdev); - - if (cap) { + if (pci_is_pcie(pdev)) { u16 ctl; - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); + pci_pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &ctl); ctl |= PCI_EXP_LNKCTL_CLKREQ_EN; - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); + pci_pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, ctl); } } @@ -5132,14 +5126,9 @@ static void rtl_hw_start_8101(struct net_device *dev) tp->event_slow &= ~RxFIFOOver; if (tp->mac_version == RTL_GIGA_MAC_VER_13 || - tp->mac_version == RTL_GIGA_MAC_VER_16) { - int cap = pci_pcie_cap(pdev); - - if (cap) { - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, - PCI_EXP_DEVCTL_NOSNOOP_EN); - } - } + tp->mac_version == RTL_GIGA_MAC_VER_16) + pci_pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_NOSNOOP_EN); RTL_W8(Cfg9346, Cfg9346_Unlock);