IB/{hw,sw}: Remove 'uobject->context' dependency in object creation APIs
[linux-block.git] / drivers / infiniband / hw / mthca / mthca_srq.c
index b8333c79e3fa7466982c9767e42358000e124c66..06b9203855122fcba23d59a124c14ef010af8bb2 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <asm/io.h>
 
+#include <rdma/uverbs_ioctl.h>
+
 #include "mthca_dev.h"
 #include "mthca_cmd.h"
 #include "mthca_memfree.h"
@@ -96,17 +98,19 @@ static void mthca_tavor_init_srq_context(struct mthca_dev *dev,
                                         struct mthca_pd *pd,
                                         struct mthca_srq *srq,
                                         struct mthca_tavor_srq_context *context,
-                                        bool is_user)
+                                        struct ib_udata *udata)
 {
+       struct mthca_ucontext *ucontext = rdma_udata_to_drv_context(
+               udata, struct mthca_ucontext, ibucontext);
+
        memset(context, 0, sizeof *context);
 
        context->wqe_base_ds = cpu_to_be64(1 << (srq->wqe_shift - 4));
        context->state_pd    = cpu_to_be32(pd->pd_num);
        context->lkey        = cpu_to_be32(srq->mr.ibmr.lkey);
 
-       if (is_user)
-               context->uar =
-                       cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
+       if (udata)
+               context->uar = cpu_to_be32(ucontext->uar.index);
        else
                context->uar = cpu_to_be32(dev->driver_uar.index);
 }
@@ -115,8 +119,10 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
                                         struct mthca_pd *pd,
                                         struct mthca_srq *srq,
                                         struct mthca_arbel_srq_context *context,
-                                        bool is_user)
+                                        struct ib_udata *udata)
 {
+       struct mthca_ucontext *ucontext = rdma_udata_to_drv_context(
+               udata, struct mthca_ucontext, ibucontext);
        int logsize, max;
 
        memset(context, 0, sizeof *context);
@@ -131,9 +137,8 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
        context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
        context->db_index = cpu_to_be32(srq->db_index);
        context->logstride_usrpage = cpu_to_be32((srq->wqe_shift - 4) << 29);
-       if (is_user)
-               context->logstride_usrpage |=
-                       cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
+       if (udata)
+               context->logstride_usrpage |= cpu_to_be32(ucontext->uar.index);
        else
                context->logstride_usrpage |= cpu_to_be32(dev->driver_uar.index);
        context->eq_pd = cpu_to_be32(MTHCA_EQ_ASYNC << 24 | pd->pd_num);