mirror of
https://github.com/torvalds/linux.git
synced 2026-07-29 10:41:49 +02:00
RDMA/qedr: Replace qedr_ib_copy_to_udata() with ib_respond_udata()
This is another instance of the min() pattern. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
addf681eed
commit
49e9e65561
|
|
@ -64,14 +64,6 @@ enum {
|
|||
QEDR_USER_MMAP_PHYS_PAGE,
|
||||
};
|
||||
|
||||
static inline int qedr_ib_copy_to_udata(struct ib_udata *udata, void *src,
|
||||
size_t len)
|
||||
{
|
||||
size_t min_len = min_t(size_t, len, udata->outlen);
|
||||
|
||||
return ib_copy_to_udata(udata, src, min_len);
|
||||
}
|
||||
|
||||
int qedr_query_pkey(struct ib_device *ibdev, u32 port, u16 index, u16 *pkey)
|
||||
{
|
||||
if (index >= QEDR_ROCE_PKEY_TABLE_LEN)
|
||||
|
|
@ -340,7 +332,7 @@ int qedr_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
|
|||
uresp.sges_per_srq_wr = dev->attr.max_srq_sge;
|
||||
uresp.max_cqes = QEDR_MAX_CQES;
|
||||
|
||||
rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rc = ib_respond_udata(udata, uresp);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
|
|
@ -459,9 +451,8 @@ int qedr_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
|
|||
struct qedr_ucontext *context = rdma_udata_to_drv_context(
|
||||
udata, struct qedr_ucontext, ibucontext);
|
||||
|
||||
rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rc = ib_respond_udata(udata, uresp);
|
||||
if (rc) {
|
||||
DP_ERR(dev, "copy error pd_id=0x%x.\n", pd_id);
|
||||
dev->ops->rdma_dealloc_pd(dev->rdma_ctx, pd_id);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -696,12 +687,10 @@ static void qedr_db_recovery_del(struct qedr_dev *dev,
|
|||
dev->ops->common->db_recovery_del(dev->cdev, db_addr, db_data);
|
||||
}
|
||||
|
||||
static int qedr_copy_cq_uresp(struct qedr_dev *dev,
|
||||
struct qedr_cq *cq, struct ib_udata *udata,
|
||||
static int qedr_copy_cq_uresp(struct qedr_cq *cq, struct ib_udata *udata,
|
||||
u32 db_offset)
|
||||
{
|
||||
struct qedr_create_cq_uresp uresp;
|
||||
int rc;
|
||||
|
||||
memset(&uresp, 0, sizeof(uresp));
|
||||
|
||||
|
|
@ -711,11 +700,7 @@ static int qedr_copy_cq_uresp(struct qedr_dev *dev,
|
|||
uresp.db_rec_addr =
|
||||
rdma_user_mmap_get_offset(cq->q.db_mmap_entry);
|
||||
|
||||
rc = qedr_ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
if (rc)
|
||||
DP_ERR(dev, "copy error cqid=0x%x.\n", cq->icid);
|
||||
|
||||
return rc;
|
||||
return ib_respond_udata(udata, uresp);
|
||||
}
|
||||
|
||||
static void consume_cqe(struct qedr_cq *cq)
|
||||
|
|
@ -994,7 +979,7 @@ int qedr_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
|||
spin_lock_init(&cq->cq_lock);
|
||||
|
||||
if (udata) {
|
||||
rc = qedr_copy_cq_uresp(dev, cq, udata, db_offset);
|
||||
rc = qedr_copy_cq_uresp(cq, udata, db_offset);
|
||||
if (rc)
|
||||
goto err2;
|
||||
|
||||
|
|
@ -1298,8 +1283,6 @@ static int qedr_copy_qp_uresp(struct qedr_dev *dev,
|
|||
struct qedr_qp *qp, struct ib_udata *udata,
|
||||
struct qedr_create_qp_uresp *uresp)
|
||||
{
|
||||
int rc;
|
||||
|
||||
memset(uresp, 0, sizeof(*uresp));
|
||||
|
||||
if (qedr_qp_has_sq(qp))
|
||||
|
|
@ -1311,13 +1294,7 @@ static int qedr_copy_qp_uresp(struct qedr_dev *dev,
|
|||
uresp->atomic_supported = dev->atomic_cap != IB_ATOMIC_NONE;
|
||||
uresp->qp_id = qp->qp_id;
|
||||
|
||||
rc = qedr_ib_copy_to_udata(udata, uresp, sizeof(*uresp));
|
||||
if (rc)
|
||||
DP_ERR(dev,
|
||||
"create qp: failed a copy to user space with qp icid=0x%x.\n",
|
||||
qp->icid);
|
||||
|
||||
return rc;
|
||||
return ib_respond_udata(udata, *uresp);
|
||||
}
|
||||
|
||||
static void qedr_reset_qp_hwq_info(struct qedr_qp_hwq_info *qph)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user