From patchwork Tue Jul 10 15:54:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1178181 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 16DC7402D2 for ; Tue, 10 Jul 2012 15:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756021Ab2GJPzx (ORCPT ); Tue, 10 Jul 2012 11:55:53 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:43454 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464Ab2GJPzv (ORCPT ); Tue, 10 Jul 2012 11:55:51 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so456687pbb.19 for ; Tue, 10 Jul 2012 08:55:51 -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 :in-reply-to:references; bh=pz1zWz9E/OWJbdWKS+rR1JhX6wf0ThAg6300j3yRC48=; b=sk4TYJaGnvyOPRww3Ipvtxpbfpr8wjDYjQlR69MiMmaFbNnon0V9sife6t+0mhpfq9 kDX0Bh4OKGAYO8VtLD6rl8xBK79eJKm1OW8THO2A0w+OQwPCYkR+GPccc5tJTTUYVI7d kxK7TndEBHoHyD5Z4EnHP8UpIMXjmwIJhn8R4Nc8LRA9byJqyEdfsp1Fns1sivsldFZO Z9yW4v9Qh2KJHGRbxA4AJcF0GVZrZfPCKbwKKUlCAtWaVwgXoxwwbmQMC4ZaDiO2aTA7 pqQa+UM2APJlHeYbbCDBOkTx3jm8oFmMx9mcwq+RJgTeUBW4QsjzKxWRECAq4Ap5QGGz vnQA== Received: by 10.68.201.7 with SMTP id jw7mr15821404pbc.60.1341935751043; Tue, 10 Jul 2012 08:55:51 -0700 (PDT) Received: from localhost.localdomain ([221.221.21.23]) by mx.google.com with ESMTPS id oq4sm3056662pbb.21.2012.07.10.08.55.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 08:55:49 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile Cc: Jiang Liu , Yinghai Lu , Taku Izumi , "Rafael J . Wysocki" , Kenji Kaneshige , Yijing Wang , Keping Chen , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH 07/14] hotplug/PCI: use PCIe cap access functions to simplify implementation Date: Tue, 10 Jul 2012 23:54:08 +0800 Message-Id: <1341935655-5381-8-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341935655-5381-1-git-send-email-jiang.liu@huawei.com> References: <1341935655-5381-1-git-send-email-jiang.liu@huawei.com> In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Jiang Liu Use PCIe cap access functions to simplify pcihp_slot.c Signed-off-by: Jiang Liu --- drivers/pci/hotplug/pcihp_slot.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index 8c05a18..08ca019 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c @@ -103,8 +103,7 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *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 +113,18 @@ 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); + if (pci_pcie_cap_read_word(dev, PCI_EXP_DEVCTL, ®16)) + return; reg16 = (reg16 & hpp->pci_exp_devctl_and) | hpp->pci_exp_devctl_or; - pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, reg16); + pci_pcie_cap_write_word(dev, PCI_EXP_DEVCTL, reg16); /* Initialize Link Control Register */ if (dev->subordinate) { - pci_read_config_word(dev, pos + 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); + if (pci_pcie_cap_read_word(dev, PCI_EXP_LNKCTL, ®16)) { + reg16 = (reg16 & hpp->pci_exp_lnkctl_and) + | hpp->pci_exp_lnkctl_or; + pci_pcie_cap_write_word(dev, PCI_EXP_LNKCTL, reg16); + } } /* Find Advanced Error Reporting Enhanced Capability */