genirq/MSI: Move alloc_msi_entry() from PCI into generic MSI code
authorJiang Liu <jiang.liu@linux.intel.com>
Thu, 9 Jul 2015 08:00:47 +0000 (16:00 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 22 Jul 2015 16:37:44 +0000 (18:37 +0200)
Move alloc_msi_entry() from PCI MSI code into generic MSI code, so it
can be reused by other generic MSI drivers.  Also introduce
free_msi_entry() for completeness.

Suggested-by: Stuart Yoder <stuart.yoder@freescale.com>.
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Yijing Wang <wangyijing@huawei.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Alexander Gordeev <agordeev@redhat.com>
Link: http://lkml.kernel.org/r/1436428847-8886-13-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/pci/msi.c
include/linux/msi.h
kernel/irq/msi.c

index 897e1a4bce066aeb127eeb42d44068c1ce6db7ee..cd4c78c193de16ce07bf544fe3f65e29bf516f30 100644 (file)
@@ -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);
index 518e8c4a406483ba6fe81e23bb742e6f64ae0121..f83c87e447bc5f63802743eb9e7875f594396e9a 100644 (file)
@@ -96,6 +96,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);
index 7bf1f1bbb7fa5620a270ca1d42d9d54e54b61288..7e6512b9dc1ff2682394cdd0fea9a8c6d01cf6e9 100644 (file)
 /* 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;