From patchwork Tue Jul 24 16:31:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 172951 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E3C2E2C0087 for ; Wed, 25 Jul 2012 02:39:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755840Ab2GXQeR (ORCPT ); Tue, 24 Jul 2012 12:34:17 -0400 Received: from mail-gg0-f174.google.com ([209.85.161.174]:45118 "EHLO mail-gg0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755581Ab2GXQeP (ORCPT ); Tue, 24 Jul 2012 12:34:15 -0400 Received: by mail-gg0-f174.google.com with SMTP id u4so6856486ggl.19 for ; Tue, 24 Jul 2012 09:34:15 -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=ZW6IObN5jN/bQM9j2qP9ivmyz4HXHjNskv0tJQfVHgA=; b=ctkY2Z9bR0wwFRtka8toUPQmmVWKDp62r8QEg+MX+0ngb+aAz08lQ3OqVD6fQPzvNs PUVWboIC9mar714xfa8lp/BVv/Iu6wbZHSssCRiCV9HsRHJmuHQr2dKH3ynAabWEjhCa hFPeqe9AH7ADevCNXhsQTJCiQLzWPzSf5ANqSyoLYPDl75E9/XSApRr43lUScGS9t4Y0 g/GAuBVh9slYtGlgBUYQYhPauDeEmpvTjNoO9ooEByL4HvV3hRN+GEUfnOuAz54viDs3 GwoMu1oyfvN5eBMtFL9EfQbNUKagA/1SJJxfapxGdpc5uarNITEL9af6luEhzvWtDoyI 8IyA== Received: by 10.66.75.202 with SMTP id e10mr5957296paw.55.1343147654817; Tue, 24 Jul 2012 09:34:14 -0700 (PDT) Received: from localhost.localdomain ([221.221.26.244]) by mx.google.com with ESMTPS id wi6sm12457583pbc.35.2012.07.24.09.34.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 09:34:14 -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 06/32] PCI/hotplug: use PCIe capabilities access functions to simplify implementation Date: Wed, 25 Jul 2012 00:31:18 +0800 Message-Id: <1343147504-25891-7-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 cpihp_slot.c. Signed-off-by: Jiang Liu --- drivers/pci/hotplug/pcihp_slot.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index 8c05a18..b7bd558 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c @@ -102,9 +102,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) if (!hpp) return; - /* Find PCI Express capability */ - pos = pci_pcie_cap(dev); - if (!pos) + if (!pci_is_pcie(dev)) return; if (hpp->revision > 1) { @@ -114,16 +112,16 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp) } /* Initialize Device Control Register */ - pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, ®16); + pci_pcie_capability_read_word(dev, PCI_EXP_DEVCTL, ®16); reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or; - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); + pci_pcie_capability_write_word(dev, PCI_EXP_DEVCTL, reg16); /* Initialize Link Control Register */ if (dev->subordinate) { - pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, ®16); + pci_pcie_capability_read_word(dev, PCI_EXP_LNKCTL, ®16); reg16 = (reg16 & hpp->pci_exp_lnkctl_and) | hpp->pci_exp_lnkctl_or; - pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, reg16); + pci_pcie_capability_write_word(dev, PCI_EXP_LNKCTL, reg16); } /* Find Advanced Error Reporting Enhanced Capability */