From patchwork Tue Jul 24 16:31:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1232351 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 7D10A3FD4F for ; Tue, 24 Jul 2012 16:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755947Ab2GXQes (ORCPT ); Tue, 24 Jul 2012 12:34:48 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:40539 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755260Ab2GXQer (ORCPT ); Tue, 24 Jul 2012 12:34:47 -0400 Received: by mail-pb0-f46.google.com with SMTP id rp8so12915236pbb.19 for ; Tue, 24 Jul 2012 09:34:47 -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=igJ0T+JFM/5Aas+2Q9aZvjP5nw/MhgtksiSg6ZkY5WM=; b=HE95dGG0vOCWT+grCM9tqER6ZHdJtGlrJ3yw4h0AetaIuGhxXZ9FdxK4FQfR2UIrgo GPuJEoVk4DRlurw9w0/oq85CePh6t3P1grMMcYm5s4nQ2J1dijP12RG6fxmnoiTKDKbS WBTdp5aCpuK+uvoN4qt8tS3OpvkYlu5CnVOaktXbUl2bKcDejViRkCXLbLMFGfakr3+t 1RH3M0iFJ7cdVG57Km8jx2xtq8sECBo44Bn9KiPlb03RcMM+7C4E4sSNuKUw/MIz0oqG xlafEcg3orrSa/AHZExW03d5E3RL2jc7h5/RGDKwXezjgUW6d8pwzuJNBhD7bPLbRkuK p2NQ== Received: by 10.68.203.98 with SMTP id kp2mr45680099pbc.132.1343147687003; Tue, 24 Jul 2012 09:34:47 -0700 (PDT) Received: from localhost.localdomain ([221.221.26.244]) by mx.google.com with ESMTPS id wi6sm12457583pbc.35.2012.07.24.09.34.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 09:34:46 -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 09/32] PCI/PME: use PCIe capabilities access functions to simplify implementation Date: Wed, 25 Jul 2012 00:31:21 +0800 Message-Id: <1343147504-25891-10-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 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..6cd6ab7 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_capability_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_capability_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_capability_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_capability_read_dword(port, PCI_EXP_RTSTA, &rtsta); if (!(rtsta & PCI_EXP_RTSTA_PME)) { spin_unlock_irqrestore(&data->lock, flags);