summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backport/backport-include/linux/pci.h19
-rw-r--r--backport/compat/backport-4.8.c23
2 files changed, 42 insertions, 0 deletions
diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h
index 67ac40fc..531f5a47 100644
--- a/backport/backport-include/linux/pci.h
+++ b/backport/backport-include/linux/pci.h
@@ -134,6 +134,25 @@ static inline int pci_vfs_assigned(struct pci_dev *dev)
#endif /* LINUX_VERSION_IS_LESS(3,10,0) */
+#if LINUX_VERSION_IS_LESS(4,8,0)
+#define pci_alloc_irq_vectors LINUX_BACKPORT(pci_alloc_irq_vectors)
+#ifdef CONFIG_PCI_MSI
+int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+ unsigned int max_vecs, unsigned int flags);
+#else
+static inline int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+ unsigned int max_vecs, unsigned int flags)
+{ return -ENOSYS; }
+#endif
+#endif
+
+#if LINUX_VERSION_IS_LESS(4,8,0)
+#define pci_free_irq_vectors LINUX_BACKPORT(pci_free_irq_vectors)
+static inline void pci_free_irq_vectors(struct pci_dev *dev)
+{
+}
+#endif
+
#if LINUX_VERSION_IS_LESS(3,14,0)
#define pci_enable_msi_range LINUX_BACKPORT(pci_enable_msi_range)
#ifdef CONFIG_PCI_MSI
diff --git a/backport/compat/backport-4.8.c b/backport/compat/backport-4.8.c
index 7d056444..e583c1ec 100644
--- a/backport/compat/backport-4.8.c
+++ b/backport/compat/backport-4.8.c
@@ -9,6 +9,7 @@
*/
#include <linux/usb.h>
#include <linux/usb/cdc.h>
+#include <linux/pci.h>
int cdc_parse_cdc_header(struct usb_cdc_parsed_header *hdr,
struct usb_interface *intf,
@@ -144,3 +145,25 @@ next_desc:
return cnt;
}
EXPORT_SYMBOL_GPL(cdc_parse_cdc_header);
+
+int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+ unsigned int max_vecs, unsigned int flags)
+{
+ int res;
+ int msi_nvect = max_vecs;
+
+ if (max_vecs < min_vecs)
+ return -ERANGE;
+
+#if LINUX_VERSION_IS_LESS(3,15,0)
+ res = pci_enable_msi_block(dev, msi_nvect);
+ if (res == 0) {
+ return msi_nvect;
+ }
+#else
+ res = pci_enable_msi_range(dev, msi_nvect, msi_nvect);
+ return msi_nvect;
+#endif /*LINUX_VERSION_IS_LESS(3,15,0)*/
+ return -ENOSPC;
+}
+EXPORT_SYMBOL_GPL(pci_alloc_irq_vectors);