From patchwork Wed Aug 1 15:54:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1265261 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 97763DF215 for ; Wed, 1 Aug 2012 16:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755104Ab2HAP5b (ORCPT ); Wed, 1 Aug 2012 11:57: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 S1753913Ab2HAP52 (ORCPT ); Wed, 1 Aug 2012 11:57:28 -0400 Received: by mail-yx0-f174.google.com with SMTP id l2so7449160yen.19 for ; Wed, 01 Aug 2012 08:57: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=zvASDillO9rBSIxeMIEjzolV/8YqqiAv/N2bNQ3RklQ=; b=NfJPgUG9lBc9NtJzOVQPglyejmB5HBrkk0ib/kHYgQTNIWxtMBF79pTus/mISwelTX +fqrE6eohM37hfkBXfUxx4pEowoXWyMaa9fw9LlV2I+DOLe4sjQLVaifUqH/hc5URsYk tQX2qW7oSA1EskyD+sxJSfCm4jpmOEcfzr6yoJlngvF5+tvZNwsJ1535IuzODpB+nuAV PPF4chumg4px0Zi3JjXkEVxHJFV7P8ZjgLkJ2HeFyS61vFBBS3KWsADNGTraW66xrb1E aEZN8ijIXOGI8RZambG9a49hx2nxllxGWspJxPNNj5Rnxa5hbWRdqDLk5w8xrPtiJBiL dwQw== Received: by 10.66.81.3 with SMTP id v3mr40739015pax.62.1343836647481; Wed, 01 Aug 2012 08:57:27 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pe8sm2816231pbc.76.2012.08.01.08.57.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Aug 2012 08:57:25 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , Chris Metcalf 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 14/32] PCI/tile: use PCIe capabilities access functions to simplify implementation Date: Wed, 1 Aug 2012 23:54:19 +0800 Message-Id: <1343836477-7287-15-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 PCIe tile implementation. Signed-off-by: Jiang Liu Acked-by: Chris Metcalf --- arch/tile/kernel/pci.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c index 0fdd99d..4640690 100644 --- a/arch/tile/kernel/pci.c +++ b/arch/tile/kernel/pci.c @@ -246,16 +246,13 @@ static void __devinit fixup_read_and_payload_sizes(void) /* Scan for the smallest maximum payload size. */ while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - int pcie_caps_offset; u32 devcap; int max_payload; - pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP); - if (pcie_caps_offset == 0) + if (!pci_is_pcie(dev)) continue; - pci_read_config_dword(dev, pcie_caps_offset + PCI_EXP_DEVCAP, - &devcap); + pci_pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &devcap); max_payload = devcap & PCI_EXP_DEVCAP_PAYLOAD; if (max_payload < smallest_max_payload) smallest_max_payload = max_payload; @@ -263,21 +260,9 @@ static void __devinit fixup_read_and_payload_sizes(void) /* Now, set the max_payload_size for all devices to that value. */ new_values = (max_read_size << 12) | (smallest_max_payload << 5); - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - int pcie_caps_offset; - u16 devctl; - - pcie_caps_offset = pci_find_capability(dev, PCI_CAP_ID_EXP); - if (pcie_caps_offset == 0) - continue; - - pci_read_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL, - &devctl); - devctl &= ~(PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ); - devctl |= new_values; - pci_write_config_word(dev, pcie_caps_offset + PCI_EXP_DEVCTL, - devctl); - } + while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) + pci_pcie_capability_change_word(dev, PCI_EXP_DEVCTL, new_values, + PCI_EXP_DEVCTL_PAYLOAD | PCI_EXP_DEVCTL_READRQ); }