Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1180514

[RFC Patch V1 12/12] genirq, PCI: Move alloc_msi_entry() from PCI MSI code into generic MSI code

From Jiang Liu <jiang.liu@linux.intel.com>
Newsgroups linux.kernel
Subject [RFC Patch V1 12/12] genirq, PCI: Move alloc_msi_entry() from PCI MSI code into generic MSI code
Date 2015-07-09 10:10 +0200
Message-ID <pKf46-69s-27@gated-at.bofh.it> (permalink)
References <pKeUq-5Qy-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Move alloc_msi_entry() from PCI MSI code into generic MSI code, so it
could be reused by other generic MSI drivers.
Also introduce free_msi_entry() for completeness.

This is suggested by Stuart Yoder <stuart.yoder@freescale.com>.

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
 drivers/pci/msi.c   |   16 ++--------------
 include/linux/msi.h |    2 ++
 kernel/irq/msi.c    |   17 +++++++++++++++++
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 260c1653701d..373d96e06cbd 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -406,18 +406,6 @@ static void free_msi_irqs(struct pci_dev *dev)
 	}
 }
 
-static struct msi_desc *alloc_msi_entry(struct pci_dev *dev)
-{
-	struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL);
-	if (!desc)
-		return NULL;
-
-	INIT_LIST_HEAD(&desc->list);
-	desc->dev = &dev->dev;
-
-	return desc;
-}
-
 static void pci_intx_for_msi(struct pci_dev *dev, int enable)
 {
 	if (!(dev->dev_flags & PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG))
@@ -572,7 +560,7 @@ static struct msi_desc *msi_setup_entry(struct pci_dev *dev, int nvec)
 	struct msi_desc *entry;
 
 	/* MSI Entry Initialization */
-	entry = alloc_msi_entry(dev);
+	entry = alloc_msi_entry(&dev->dev);
 	if (!entry)
 		return NULL;
 
@@ -700,7 +688,7 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
 	int i;
 
 	for (i = 0; i < nvec; i++) {
-		entry = alloc_msi_entry(dev);
+		entry = alloc_msi_entry(&dev->dev);
 		if (!entry) {
 			if (!i)
 				iounmap(base);
diff --git a/include/linux/msi.h b/include/linux/msi.h
index f6845bc83774..c10ec5687efa 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -67,6 +67,8 @@ static inline void *msi_desc_to_pci_sysdata(struct msi_desc *desc)
 }
 #endif /* CONFIG_PCI_MSI */
 
+struct msi_desc *alloc_msi_entry(struct device *dev);
+void free_msi_entry(struct msi_desc *entry);
 void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
 void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
 void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg);
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 7bf1f1bbb7fa..7e6512b9dc1f 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -18,6 +18,23 @@
 /* Temparory solution for building, will be removed later */
 #include <linux/pci.h>
 
+struct msi_desc *alloc_msi_entry(struct device *dev)
+{
+	struct msi_desc *desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+	if (!desc)
+		return NULL;
+
+	INIT_LIST_HEAD(&desc->list);
+	desc->dev = dev;
+
+	return desc;
+}
+
+void free_msi_entry(struct msi_desc *entry)
+{
+	kfree(entry);
+}
+
 void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 {
 	*msg = entry->msg;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC Patch V1 00/12] Reorganize struct msi_desc to prepare for support of generic MSI Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:00 +0200
  [RFC Patch V1 03/12] PowerPC, PCI: Use for_pci_msi_entry() to access MSI device list Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:00 +0200
  [RFC Patch V1 05/12] x86, PCI: Use for_pci_msi_entry() to access MSI device list Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 09/12] genirq: Move msi_list from struct pci_dev to struct device Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
    Re: [RFC Patch V1 09/12] genirq: Move msi_list from struct pci_dev  to struct device Paul Gortmaker <paul.gortmaker@windriver.com> - 2015-07-10 02:30 +0200
  [RFC Patch V1 06/12] PCI: Use for_pci_msi_entry() to access MSI device list Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  Re: [RFC Patch V1 07/12] sparc, PCI: Use helper functions to  access fields in struct msi_desc David Miller <davem@davemloft.net> - 2015-07-09 10:10 +0200
  [RFC Patch V1 12/12] genirq, PCI: Move alloc_msi_entry() from PCI MSI code into generic MSI code Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 10/12] genirq, PCI: Store 'struct device *' instead 'struct pci_dev *' in struct msi_desc Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 11/12] genirq, PCI: Reorginize struct msi_desc to prepare for support of generic MSI Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 08/12] PCI: Use helper functions to access fields in struct msi_desc Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 07/12] sparc, PCI: Use helper functions to access fields in struct msi_desc Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
  [RFC Patch V1 04/12] s390/pci: Use for_pci_msi_entry() to access MSI device list Jiang Liu <jiang.liu@linux.intel.com> - 2015-07-09 10:10 +0200
    Re: [RFC Patch V1 04/12] s390/pci: Use for_pci_msi_entry() to access  MSI device list Sebastian Ott <sebott@linux.vnet.ibm.com> - 2015-07-13 14:50 +0200
  Re: [RFC Patch V1 00/12] Reorganize struct msi_desc to prepare for  support of generic MSI Yijing Wang <wangyijing@huawei.com> - 2015-07-10 03:50 +0200

csiph-web