From patchwork Wed Aug 1 15:54:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1265211 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 A1D9F3FC23 for ; Wed, 1 Aug 2012 16:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752034Ab2HAP6b (ORCPT ); Wed, 1 Aug 2012 11:58:31 -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 S1755969Ab2HAP62 (ORCPT ); Wed, 1 Aug 2012 11:58:28 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so7449160yen.19 for ; Wed, 01 Aug 2012 08:58:27 -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=Tr5Fru4sxcrVeZQtaTlZHyokypfLXSbNqa5yyB2YAc8=; b=KOZfEfPK68pAyczKe4QKnjN5K6p4OWThMmcAFxB2mSPNBGb6AHPAwANJLLjXPn0eKR FkV3BQFfkFQ6HNam1iW9+iw6XoNPqODcNzwxkcys3GMXyPJflTsQUAjx+NaA+hI8GHDz Dgo94JlzqE6yszXstPKErNt9BuihtN8A9wmxHZwNK3HVeNLtnPzNJW5ebWFv15zlxKl8 34d14dXAV0b7uxUKo8yEEOf45gFIxAWr4H/AeXbX9G4+/UGZcQor0DkjQWmNPmwvT0MI FJ1y80h0V69qIqlQA3rRBYvrarohEmE+npzdBeBbRZUBFffDn5ZDbSwJOtED3jAGmLZZ GuWA== Received: by 10.66.77.71 with SMTP id q7mr40964135paw.0.1343836707403; Wed, 01 Aug 2012 08:58:27 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pe8sm2816231pbc.76.2012.08.01.08.58.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 08:58:26 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , "David S. Miller" 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 20/32] PCI/niu: use PCIe capabilities access functions to simplify implementation Date: Wed, 1 Aug 2012 23:54:25 +0800 Message-Id: <1343836477-7287-21-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 niu driver's implementation. Signed-off-by: Jiang Liu --- drivers/net/ethernet/sun/niu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 703c8cc..e8e2932 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -9768,9 +9768,8 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev, union niu_parent_id parent_id; struct net_device *dev; struct niu *np; - int err, pos; + int err; u64 dma_mask; - u16 val16; niu_driver_version(); @@ -9793,8 +9792,7 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev, goto err_out_disable_pdev; } - pos = pci_pcie_cap(pdev); - if (pos <= 0) { + if (!pci_is_pcie(pdev)) { dev_err(&pdev->dev, "Cannot find PCI Express capability, aborting\n"); goto err_out_free_res; } @@ -9819,14 +9817,10 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev, goto err_out_free_dev; } - pci_read_config_word(pdev, pos + PCI_EXP_DEVCTL, &val16); - val16 &= ~PCI_EXP_DEVCTL_NOSNOOP_EN; - val16 |= (PCI_EXP_DEVCTL_CERE | - PCI_EXP_DEVCTL_NFERE | - PCI_EXP_DEVCTL_FERE | - PCI_EXP_DEVCTL_URRE | - PCI_EXP_DEVCTL_RELAX_EN); - pci_write_config_word(pdev, pos + PCI_EXP_DEVCTL, val16); + pci_pcie_capability_change_word(pdev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | + PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE | + PCI_EXP_DEVCTL_RELAX_EN, PCI_EXP_DEVCTL_NOSNOOP_EN); dma_mask = DMA_BIT_MASK(44); err = pci_set_dma_mask(pdev, dma_mask);