]> git.openfabrics.org - ~emulex/compat-rdma_3.12.git/commitdiff
ocrdma: idr_alloc backport for kernels < 3.9
authorVladimir Sokolovsky <vlad@mellanox.com>
Mon, 3 Feb 2014 15:50:00 +0000 (17:50 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Mon, 3 Feb 2014 15:50:00 +0000 (17:50 +0200)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
patches/0022-ocrdma-idr_alloc-backport-for-kernels-3.9.patch [new file with mode: 0644]

diff --git a/patches/0022-ocrdma-idr_alloc-backport-for-kernels-3.9.patch b/patches/0022-ocrdma-idr_alloc-backport-for-kernels-3.9.patch
new file mode 100644 (file)
index 0000000..8f286f3
--- /dev/null
@@ -0,0 +1,45 @@
+From: Vladimir Sokolovsky <vlad@mellanox.com>
+Subject: [PATCH] ocrdma: idr_alloc backport for kernels < 3.9
+
+Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
+---
+ drivers/infiniband/hw/ocrdma/ocrdma_main.c |   18 ++++++++++++++++++
+ 1 files changed, 18 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
++++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
+@@ -52,6 +52,20 @@ static DEFINE_IDR(ocrdma_dev_id);
+ static union ib_gid ocrdma_zero_sgid;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++static int ocrdma_get_instance(void)
++{
++      int instance = 0;
++
++      /* Assign an unused number */
++      if (!idr_pre_get(&ocrdma_dev_id, GFP_KERNEL))
++              return -1;
++      if (idr_get_new(&ocrdma_dev_id, NULL, &instance))
++              return -1;
++      return instance;
++}
++#endif
++
+ void ocrdma_get_guid(struct ocrdma_dev *dev, u8 *guid)
+ {
+       u8 mac_addr[6];
+@@ -411,7 +425,11 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
+               goto idr_err;
+       memcpy(&dev->nic_info, dev_info, sizeof(*dev_info));
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++      dev->id = ocrdma_get_instance();
++#else
+       dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL);
++#endif
+       if (dev->id < 0)
+               goto idr_err;