diff options
author | Omer Dagan <omer.dagan@tandemg.com> | 2018-10-03 09:18:09 +0000 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2018-11-05 08:16:20 +0100 |
commit | 162a6b312f1b439cf0cf191564b21df0d3393564 (patch) | |
tree | b4a7e1cbf527f7443bbd96f216ac396f89a57ec2 /backport/compat/backport-4.8.c | |
parent | 6f2b0d73e567844a8c8766218c4e34739643b029 (diff) |
add support for pci_alloc_irq_vectors
add support for function in kernels under 4.8
function is a wrapper around 'pci_enable_msi_block' or
'pci_enable_msi_range' depending on the kernel version
the min\max number of interrupts was overridden to always use the
max number of interrupts which seems correct since it was not
supported in the old APIs
Signed-off-by: Omer Dagan <omer.dagan@tandemg.com>
[use GPL expert as everything in backports, remove unused ifdef]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport/compat/backport-4.8.c')
-rw-r--r-- | backport/compat/backport-4.8.c | 23 |
1 files changed, 23 insertions, 0 deletions
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); |