From patchwork Wed Aug 1 15:54:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1265241 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 863003FC23 for ; Wed, 1 Aug 2012 16:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755771Ab2HAP6E (ORCPT ); Wed, 1 Aug 2012 11:58:04 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:61462 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034Ab2HAP6B (ORCPT ); Wed, 1 Aug 2012 11:58:01 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so7449160yen.19 for ; Wed, 01 Aug 2012 08:58:01 -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=nNJFRjQyugs+ymioRp0GcBLR9X4sAwVf3fs6j5ElXqg=; b=sIRSXJ3u7QulGEnP/UHXB3j4KzdlygsvqVyvihxY/6wftAs2iX2TiyLCYF63ZhZou1 kmfNRMvQLUZf/UVoCciAhCyPbjOKmMPV8bhdeOyKzrhm1ILo2uoIdCq/7whV0BEu96C4 bYhwjsSTYFL9aWmffGXLEE+oBCTKhB8lodzj60bSNuDAcJBT9n8Ar2qQE0IswuxytFkG elMxUqINcDEZkRBf/UpHJueIRFwBCtLGw25lUhcicD86sUZh+cbgUZh+COZaoS2k0AbI hooB0Prhtl7pv3+f3WIkjLlRbbECzuJHVH4SQ9ysCVo63/WkmO8BiMdrl8eXyTZDOElB JAXw== Received: by 10.66.74.195 with SMTP id w3mr40751284pav.64.1343836680797; Wed, 01 Aug 2012 08:58:00 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pe8sm2816231pbc.76.2012.08.01.08.57.47 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 08:57:58 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , Jeff Kirsher , Jesse Brandeburg , Bruce Allan , Carolyn Wyborny , Don Skidmore , Greg Rose , Peter P Waskiewicz Jr , Alex Duyck , John Ronciak 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 17/32] PCI/igb: use PCIe capabilities access functions to simplify implementation Date: Wed, 1 Aug 2012 23:54:22 +0800 Message-Id: <1343836477-7287-18-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 Intel ethernet drivers' implementation. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang Acked-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 27 ++++++++------------------- drivers/net/ethernet/intel/igb/igb_main.c | 12 ++---------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index a4b0435..30b647f 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5582,16 +5582,15 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep, */ if (adapter->flags & FLAG_IS_QUAD_PORT) { struct pci_dev *us_dev = pdev->bus->self; - int pos = pci_pcie_cap(us_dev); u16 devctl; - pci_read_config_word(us_dev, pos + PCI_EXP_DEVCTL, &devctl); - pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, - (devctl & ~PCI_EXP_DEVCTL_CERE)); + pci_pcie_capability_read_word(us_dev, PCI_EXP_DEVCTL, &devctl); + pci_pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL, + (devctl & ~PCI_EXP_DEVCTL_CERE)); e1000_power_off(pdev, sleep, wake); - pci_write_config_word(us_dev, pos + PCI_EXP_DEVCTL, devctl); + pci_pcie_capability_write_word(us_dev, PCI_EXP_DEVCTL, devctl); } else { e1000_power_off(pdev, sleep, wake); } @@ -5605,25 +5604,15 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) #else static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state) { - int pos; - u16 reg16; - /* * Both device and parent should have the same ASPM setting. * Disable ASPM in downstream component first and then upstream. */ - pos = pci_pcie_cap(pdev); - pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16); - reg16 &= ~state; - pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); - - if (!pdev->bus->self) - return; + pci_pcie_capability_change_word(pdev, PCI_EXP_LNKCTL, 0, state); - pos = pci_pcie_cap(pdev->bus->self); - pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, ®16); - reg16 &= ~state; - pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16); + if (pdev->bus->self) + pci_pcie_capability_change_word(pdev->bus->self, PCI_EXP_LNKCTL, + 0, state); } #endif static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index dd3bfe8..3d46830 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -6446,28 +6446,20 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) { struct igb_adapter *adapter = hw->back; - u16 cap_offset; - cap_offset = adapter->pdev->pcie_cap; - if (!cap_offset) + if (pci_pcie_capability_read_word(adapter->pdev, reg, value)) return -E1000_ERR_CONFIG; - pci_read_config_word(adapter->pdev, cap_offset + reg, value); - return 0; } s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) { struct igb_adapter *adapter = hw->back; - u16 cap_offset; - cap_offset = adapter->pdev->pcie_cap; - if (!cap_offset) + if (pci_pcie_capability_write_word(adapter->pdev, reg, *value)) return -E1000_ERR_CONFIG; - pci_write_config_word(adapter->pdev, cap_offset + reg, *value); - return 0; }