From patchwork Tue Jul 24 16:31:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1232251 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 AE52E3FD4F for ; Tue, 24 Jul 2012 16:37:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932150Ab2GXQgh (ORCPT ); Tue, 24 Jul 2012 12:36:37 -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 S932109Ab2GXQgf (ORCPT ); Tue, 24 Jul 2012 12:36:35 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so12916328pbb.19 for ; Tue, 24 Jul 2012 09:36:35 -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=4hUkOrHq6l09xEJW/5jaK0nyl0HfIWkElaTyP5Pc0fI=; b=dTrat+Pi7xiZwSGXstffP4vR6r9q/AJyDPFXPaXsBi5Aea7JcvLLqZ0OC/3HTLa3Vw S24t9zUgIUK7wnk2dXcjV8s5JDv/N6Q+J49xzMbdnLHDj7xHwd5G2ppONne8sK1t8LPC BzVq4xA8S/PRvcHsv/oTXeufkLNMvNkWDUQbRe+1HjBLOr/LmwDq11MD0C/vlMbBBdnw 2N2zVVnr2uIP2IH5gmupkIL/DTRgo9R7Dl2ileVP5jQOFxMw//p74OKcpV6AgBPNyi4H 8lAfybglkPBrZyp9M+6intQD5fDxGT4UHeV/2oxUXJIcjOyZrcoClnz17Ncsie0TJK8j 7CeQ== Received: by 10.68.221.10 with SMTP id qa10mr45770724pbc.154.1343147795429; Tue, 24 Jul 2012 09:36:35 -0700 (PDT) Received: from localhost.localdomain ([221.221.26.244]) by mx.google.com with ESMTPS id wi6sm12457583pbc.35.2012.07.24.09.36.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 09:36:33 -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 20/32] PCI/niu: use PCIe capabilities access functions to simplify implementation Date: Wed, 25 Jul 2012 00:31:32 +0800 Message-Id: <1343147504-25891-21-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 niu driver's implementation. Signed-off-by: Jiang Liu --- drivers/net/ethernet/sun/niu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 703c8cc..3f914c1 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c @@ -9768,7 +9768,7 @@ 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; @@ -9793,8 +9793,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 +9818,14 @@ 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); + pci_pcie_capability_read_word(pdev, 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_write_word(pdev, PCI_EXP_DEVCTL, val16); dma_mask = DMA_BIT_MASK(44); err = pci_set_dma_mask(pdev, dma_mask);