From patchwork Wed Aug 1 15:54:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1265251 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 24ED73FC81 for ; Wed, 1 Aug 2012 16:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755890Ab2HAP5j (ORCPT ); Wed, 1 Aug 2012 11:57:39 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:56250 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755771Ab2HAP5h (ORCPT ); Wed, 1 Aug 2012 11:57:37 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so985545ghr.19 for ; Wed, 01 Aug 2012 08:57:37 -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=b31Ik8ey1ylqCSjTHlWnSmYBMTwkr0r4lmpJsEQcf18=; b=VCgssoc5TbtxGYqD9Gj/1AftYoNUsbqYmaGPjeCqnLqF6DRlGNKZYMCqn/mFhmTN6t ICKQ06EkGInsuQx02pG1AxY2eQ8qm8/fy4yTzLJW97TcQGytf1oe2hW4dMViC91IyLvX aptu+E8qmNRVEPLMtl4cJ8pIDTf8afH1GG2sGIU0LEP1mKhjrcJPtzPdUhThgpXokaE+ LtNC3gZXIk82BCrGXvMJ4op6f5e5q3JrZKWMz48I4FNuk/4ca8y4t8gQYVmetkorHkSy LD3tLIWTilM8G+eoSbb6b+lUQFzuUL78l5lik67NNkobFpOVwIHXWy9FG6vCqUWxUAP3 fpug== Received: by 10.66.74.3 with SMTP id p3mr40800217pav.49.1343836656726; Wed, 01 Aug 2012 08:57:36 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pe8sm2816231pbc.76.2012.08.01.08.57.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 08:57:35 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , Realtek linux nic maintainers , Francois Romieu 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: [PATCH v3 15/32] PCI/r8169: use PCIe capabilities access functions to simplify implementation Date: Wed, 1 Aug 2012 23:54:20 +0800 Message-Id: <1343836477-7287-16-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343836477-7287-1-git-send-email-jiang.liu@huawei.com> References: <1343836477-7287-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 | 44 +++++++--------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index 9757ce3..d575fbf 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c @@ -807,15 +807,8 @@ 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) { - u16 ctl; - - pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &ctl); - ctl = (ctl & ~PCI_EXP_DEVCTL_READRQ) | force; - pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, ctl); - } + pci_pcie_capability_change_word(pdev, PCI_EXP_DEVCTL, + force, PCI_EXP_DEVCTL_READRQ); } static u32 ocp_read(struct rtl8169_private *tp, u8 mask, u16 reg) @@ -4504,28 +4497,14 @@ 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) { - u16 ctl; - - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); - ctl &= ~PCI_EXP_LNKCTL_CLKREQ_EN; - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); - } + pci_pcie_capability_change_word(pdev, PCI_EXP_LNKCTL, + 0, PCI_EXP_LNKCTL_CLKREQ_EN); } static void rtl_enable_clock_request(struct pci_dev *pdev) { - int cap = pci_pcie_cap(pdev); - - if (cap) { - u16 ctl; - - pci_read_config_word(pdev, cap + PCI_EXP_LNKCTL, &ctl); - ctl |= PCI_EXP_LNKCTL_CLKREQ_EN; - pci_write_config_word(pdev, cap + PCI_EXP_LNKCTL, ctl); - } + pci_pcie_capability_change_word(pdev, PCI_EXP_LNKCTL, + PCI_EXP_LNKCTL_CLKREQ_EN, 0); } #define R8168_CPCMD_QUIRK_MASK (\ @@ -5132,14 +5111,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);