From patchwork Thu Aug 8 11:56:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 2841047 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A2AE3BF535 for ; Thu, 8 Aug 2013 11:56:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9489A203AD for ; Thu, 8 Aug 2013 11:56:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 571F02035E for ; Thu, 8 Aug 2013 11:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525Ab3HHL4h (ORCPT ); Thu, 8 Aug 2013 07:56:37 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:27393 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689Ab3HHL4e (ORCPT ); Thu, 8 Aug 2013 07:56:34 -0400 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BGJ68594; Thu, 08 Aug 2013 19:56:31 +0800 (CST) Received: from SZXEML454-HUB.china.huawei.com (10.82.67.197) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.1.323.7; Thu, 8 Aug 2013 19:56:29 +0800 Received: from localhost (10.135.76.69) by SZXEML454-HUB.china.huawei.com (10.82.67.197) with Microsoft SMTP Server id 14.1.323.7; Thu, 8 Aug 2013 19:56:22 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , Hanjun Guo , , Yijing Wang Subject: [PATCH] PCI: use msi/x_set_enable() to simplify pci_msi_off() Date: Thu, 8 Aug 2013 19:56:09 +0800 Message-ID: <1375962969-34824-1-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.11.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.135.76.69] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move pci_msi_off() to driver/pci/msi.c and use msi_set_enable() and msix_set_enable() to simplify pci_msi_off() function code. Signed-off-by: Yijing Wang --- drivers/pci/msi.c | 17 +++++++++++++++++ drivers/pci/pci.c | 28 ---------------------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index aca7578..080d14f 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1002,6 +1002,23 @@ void pci_disable_msix(struct pci_dev *dev) EXPORT_SYMBOL(pci_disable_msix); /** + * pci_msi_off - disables any msi or msix capabilities + * @dev: the PCI device to operate on + * + * If you want to use msi see pci_enable_msi and friends. + * This is a lower level primitive that allows us to disable + * msi operation at the device level. + */ +void pci_msi_off(struct pci_dev *dev) +{ + if (dev->msi_cap) + msi_set_enable(dev, 0); + if (dev->msix_cap) + msix_set_enable(dev, 0); +} +EXPORT_SYMBOL_GPL(pci_msi_off); + +/** * msi_remove_pci_irq_vectors - reclaim MSI(X) irqs to unused state * @dev: pointer to the pci_dev data structure of MSI(X) device function * diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e37fea6..6975f2a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3058,34 +3058,6 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx); -/** - * pci_msi_off - disables any msi or msix capabilities - * @dev: the PCI device to operate on - * - * If you want to use msi see pci_enable_msi and friends. - * This is a lower level primitive that allows us to disable - * msi operation at the device level. - */ -void pci_msi_off(struct pci_dev *dev) -{ - int pos; - u16 control; - - pos = pci_find_capability(dev, PCI_CAP_ID_MSI); - if (pos) { - pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control); - control &= ~PCI_MSI_FLAGS_ENABLE; - pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control); - } - pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); - if (pos) { - pci_read_config_word(dev, pos + PCI_MSIX_FLAGS, &control); - control &= ~PCI_MSIX_FLAGS_ENABLE; - pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); - } -} -EXPORT_SYMBOL_GPL(pci_msi_off); - int pci_set_dma_max_seg_size(struct pci_dev *dev, unsigned int size) { return dma_set_max_seg_size(&dev->dev, size);