From patchwork Tue Jul 10 15:54:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1178151 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 4D6BEDFF34 for ; Tue, 10 Jul 2012 15:57:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756087Ab2GJP4Y (ORCPT ); Tue, 10 Jul 2012 11:56:24 -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 S1752464Ab2GJP4V (ORCPT ); Tue, 10 Jul 2012 11:56:21 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so456687pbb.19 for ; Tue, 10 Jul 2012 08:56:21 -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=JMFj4icww0iCMkhwTKnWPHbnWDXtKDqJIHNle1zuYX4=; b=w/oGoDuf4hpu0jl8KWu7odhiddsgoHXzqY6arsEhS61qomaJiyUepGSabZWoRiKq2z ZMyLLaXnHHpLlsu1fkzAThyjp4vFaASriY0MTQgLCWaEDsLRWSXX/W1zbSqS0emmtx3L MECMtxcpUJf731SAbi+9g0jNBVNRsVv9S3OZwhjZpeBDQyxxktVvANZ9R4JLOGfq347p zQKN2HcGVV4nVC5vJrTKi1qDNqD2h63LyfmNYlS7WHaum/g+LYHputJR+fUGFVB/+dbO 0kEsZyLxksw6DQffzfsR7UU754NuCJhhfZ+vsrhq8G6Slij2bBQenU/ob36gADJp/Vdo 3Obw== Received: by 10.68.192.73 with SMTP id he9mr39819325pbc.17.1341935781048; Tue, 10 Jul 2012 08:56:21 -0700 (PDT) Received: from localhost.localdomain ([221.221.21.23]) by mx.google.com with ESMTPS id oq4sm3056662pbb.21.2012.07.10.08.56.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 08:56:20 -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 10/14] PME/PCI: use PCIe cap access functions to simplify implementation Date: Tue, 10 Jul 2012 23:54:11 +0800 Message-Id: <1341935655-5381-11-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 PCIe PME implementation Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang --- drivers/pci/pcie/pme.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c index 30897bf..d561d16 100644 --- a/drivers/pci/pcie/pme.c +++ b/drivers/pci/pcie/pme.c @@ -57,17 +57,14 @@ struct pcie_pme_service_data { */ void pcie_pme_interrupt_enable(struct pci_dev *dev, bool enable) { - int rtctl_pos; u16 rtctl; - rtctl_pos = pci_pcie_cap(dev) + PCI_EXP_RTCTL; - - pci_read_config_word(dev, rtctl_pos, &rtctl); + pci_pcie_cap_read_word(dev, PCI_EXP_RTCTL, &rtctl); if (enable) rtctl |= PCI_EXP_RTCTL_PMEIE; else rtctl &= ~PCI_EXP_RTCTL_PMEIE; - pci_write_config_word(dev, rtctl_pos, rtctl); + pci_pcie_cap_write_word(dev, PCI_EXP_RTCTL, rtctl); } /** @@ -226,18 +223,15 @@ static void pcie_pme_work_fn(struct work_struct *work) struct pcie_pme_service_data *data = container_of(work, struct pcie_pme_service_data, work); struct pci_dev *port = data->srv->port; - int rtsta_pos; u32 rtsta; - rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; - spin_lock_irq(&data->lock); for (;;) { if (data->noirq) break; - pci_read_config_dword(port, rtsta_pos, &rtsta); + pci_pcie_cap_read_dword(port, PCI_EXP_RTSTA, &rtsta); if (rtsta & PCI_EXP_RTSTA_PME) { /* * Clear PME status of the port. If there are other @@ -276,17 +270,14 @@ static irqreturn_t pcie_pme_irq(int irq, void *context) { struct pci_dev *port; struct pcie_pme_service_data *data; - int rtsta_pos; u32 rtsta; unsigned long flags; port = ((struct pcie_device *)context)->port; data = get_service_data((struct pcie_device *)context); - rtsta_pos = pci_pcie_cap(port) + PCI_EXP_RTSTA; - spin_lock_irqsave(&data->lock, flags); - pci_read_config_dword(port, rtsta_pos, &rtsta); + pci_pcie_cap_read_dword(port, PCI_EXP_RTSTA, &rtsta); if (!(rtsta & PCI_EXP_RTSTA_PME)) { spin_unlock_irqrestore(&data->lock, flags);