mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
RDMA: Convert drivers using sizeof() to ib_respond_udata()
Convert the pattern:
ib_copy_to_udata(udata, &resp, sizeof(resp));
Using Coccinelle:
@@
identifier resp;
expression udata;
@@
- ib_copy_to_udata(udata, &resp, sizeof(resp))
+ ib_respond_udata(udata, resp)
Run another pass with AI to propagate the return code correctly and
remove redundant prints.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
a5e9f0ae62
commit
5189936049
|
|
@ -52,6 +52,7 @@
|
|||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
#include <rdma/uverbs_ioctl.h>
|
||||
|
||||
#include "iw_cxgb4.h"
|
||||
|
||||
|
|
@ -209,8 +210,9 @@ static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)
|
|||
{
|
||||
struct c4iw_pd *php = to_c4iw_pd(pd);
|
||||
struct ib_device *ibdev = pd->device;
|
||||
u32 pdid;
|
||||
struct c4iw_dev *rhp;
|
||||
u32 pdid;
|
||||
int ret;
|
||||
|
||||
pr_debug("ibdev %p\n", ibdev);
|
||||
rhp = (struct c4iw_dev *) ibdev;
|
||||
|
|
@ -223,9 +225,10 @@ static int c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)
|
|||
if (udata) {
|
||||
struct c4iw_alloc_pd_resp uresp = {.pdid = php->pdid};
|
||||
|
||||
if (ib_copy_to_udata(udata, &uresp, sizeof(uresp))) {
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret) {
|
||||
c4iw_deallocate_pd(&php->ibpd, udata);
|
||||
return -EFAULT;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
mutex_lock(&rhp->rdev.stats.lock);
|
||||
|
|
|
|||
|
|
@ -2280,7 +2280,7 @@ int c4iw_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *attrs,
|
|||
ucontext->key += PAGE_SIZE;
|
||||
}
|
||||
spin_unlock(&ucontext->mmap_lock);
|
||||
ret = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret)
|
||||
goto err_free_ma_sync_key;
|
||||
sq_key_mm->key = uresp.sq_key;
|
||||
|
|
@ -2777,7 +2777,7 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,
|
|||
uresp.srq_db_gts_key = ucontext->key;
|
||||
ucontext->key += PAGE_SIZE;
|
||||
spin_unlock(&ucontext->mmap_lock);
|
||||
ret = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret)
|
||||
goto err_free_srq_db_key_mm;
|
||||
srq_key_mm->key = uresp.srq_key;
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,7 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
|
|||
uresp.qp_id = QP_ID(qp);
|
||||
uresp.rq_offset = qp->user_qp.rq_offset;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret)
|
||||
goto err_out_cmd;
|
||||
} else {
|
||||
|
|
@ -1571,7 +1571,7 @@ int erdma_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
|
|||
|
||||
uresp.dev_id = dev->pdev->device;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret)
|
||||
goto err_put_mmap_entries;
|
||||
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ int ionic_alloc_ucontext(struct ib_ucontext *ibctx, struct ib_udata *udata)
|
|||
if (dev->lif_cfg.rq_expdb)
|
||||
resp.expdb_qtypes |= IONIC_EXPDB_RQ;
|
||||
|
||||
rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
rc = ib_respond_udata(udata, resp);
|
||||
if (rc)
|
||||
goto err_resp;
|
||||
|
||||
|
|
@ -752,7 +752,7 @@ int ionic_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
|
|||
if (udata) {
|
||||
resp.ahid = ah->ahid;
|
||||
|
||||
rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
rc = ib_respond_udata(udata, resp);
|
||||
if (rc)
|
||||
goto err_resp;
|
||||
}
|
||||
|
|
@ -1263,7 +1263,7 @@ int ionic_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
|||
if (udata) {
|
||||
resp.udma_mask = vcq->udma_mask;
|
||||
|
||||
rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
rc = ib_respond_udata(udata, resp);
|
||||
if (rc)
|
||||
goto err_resp;
|
||||
}
|
||||
|
|
@ -2315,7 +2315,7 @@ int ionic_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attr,
|
|||
resp.rq_cmb = qp->rq_cmb;
|
||||
}
|
||||
|
||||
rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
rc = ib_respond_udata(udata, resp);
|
||||
if (rc)
|
||||
goto err_resp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,13 +210,9 @@ static int mana_ib_create_qp_rss(struct ib_qp *ibqp, struct ib_pd *pd,
|
|||
if (ret)
|
||||
goto fail;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
if (ret) {
|
||||
ibdev_dbg(&mdev->ib_dev,
|
||||
"Failed to copy to udata create rss-qp, %d\n",
|
||||
ret);
|
||||
ret = ib_respond_udata(udata, resp);
|
||||
if (ret)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
kfree(mana_ind_table);
|
||||
|
||||
|
|
@ -349,13 +345,9 @@ static int mana_ib_create_qp_raw(struct ib_qp *ibqp, struct ib_pd *ibpd,
|
|||
resp.cqid = send_cq->queue.id;
|
||||
resp.tx_vp_offset = pd->tx_vp_offset;
|
||||
|
||||
err = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
if (err) {
|
||||
ibdev_dbg(&mdev->ib_dev,
|
||||
"Failed copy udata for create qp-raw, %d\n",
|
||||
err);
|
||||
err = ib_respond_udata(udata, resp);
|
||||
if (err)
|
||||
goto err_remove_cq_cb;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1121,16 +1121,16 @@ static int mlx4_ib_alloc_ucontext(struct ib_ucontext *uctx,
|
|||
mutex_init(&context->wqn_ranges_mutex);
|
||||
|
||||
if (ibdev->ops.uverbs_abi_ver == MLX4_IB_UVERBS_NO_DEV_CAPS_ABI_VERSION)
|
||||
err = ib_copy_to_udata(udata, &resp_v3, sizeof(resp_v3));
|
||||
err = ib_respond_udata(udata, resp_v3);
|
||||
else
|
||||
err = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
err = ib_respond_udata(udata, resp);
|
||||
|
||||
if (err) {
|
||||
mlx4_uar_free(to_mdev(ibdev)->dev, &context->uar);
|
||||
return -EFAULT;
|
||||
return err;
|
||||
}
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mlx4_ib_dealloc_ucontext(struct ib_ucontext *ibcontext)
|
||||
|
|
|
|||
|
|
@ -2796,9 +2796,10 @@ static int mlx5_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
|
|||
pd->uid = uid;
|
||||
if (udata) {
|
||||
resp.pdn = pd->pdn;
|
||||
if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
|
||||
err = ib_respond_udata(udata, resp);
|
||||
if (err) {
|
||||
mlx5_cmd_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn, uid);
|
||||
return -EFAULT;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -311,10 +311,11 @@ static int mthca_alloc_ucontext(struct ib_ucontext *uctx,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (ib_copy_to_udata(udata, &uresp, sizeof(uresp))) {
|
||||
err = ib_respond_udata(udata, uresp);
|
||||
if (err) {
|
||||
mthca_cleanup_user_db_tab(to_mdev(ibdev), &context->uar, context->db_tab);
|
||||
mthca_uar_free(to_mdev(ibdev), &context->uar);
|
||||
return -EFAULT;
|
||||
return err;
|
||||
}
|
||||
|
||||
context->reg_mr_warned = 0;
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ int ocrdma_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
|
|||
resp.dpp_wqe_size = dev->attr.wqe_size;
|
||||
|
||||
memcpy(resp.fw_ver, dev->attr.fw_ver, sizeof(resp.fw_ver));
|
||||
status = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
status = ib_respond_udata(udata, resp);
|
||||
if (status)
|
||||
goto cpy_err;
|
||||
return 0;
|
||||
|
|
@ -611,7 +611,7 @@ static int ocrdma_copy_pd_uresp(struct ocrdma_dev *dev, struct ocrdma_pd *pd,
|
|||
rsp.dpp_page_addr_lo = dpp_page_addr;
|
||||
}
|
||||
|
||||
status = ib_copy_to_udata(udata, &rsp, sizeof(rsp));
|
||||
status = ib_respond_udata(udata, rsp);
|
||||
if (status)
|
||||
goto ucopy_err;
|
||||
|
||||
|
|
@ -945,12 +945,9 @@ static int ocrdma_copy_cq_uresp(struct ocrdma_dev *dev, struct ocrdma_cq *cq,
|
|||
uresp.db_page_addr = ocrdma_get_db_addr(dev, uctx->cntxt_pd->id);
|
||||
uresp.db_page_size = dev->nic_info.db_page_size;
|
||||
uresp.phase_change = cq->phase_change ? 1 : 0;
|
||||
status = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
if (status) {
|
||||
pr_err("%s(%d) copy error cqid=0x%x.\n",
|
||||
__func__, dev->id, cq->id);
|
||||
status = ib_respond_udata(udata, uresp);
|
||||
if (status)
|
||||
goto err;
|
||||
}
|
||||
status = ocrdma_add_mmap(uctx, uresp.db_page_addr, uresp.db_page_size);
|
||||
if (status)
|
||||
goto err;
|
||||
|
|
@ -1206,11 +1203,9 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
|
|||
uresp.dpp_credit = dpp_credit_lmt;
|
||||
uresp.dpp_offset = dpp_offset;
|
||||
}
|
||||
status = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
if (status) {
|
||||
pr_err("%s(%d) user copy error.\n", __func__, dev->id);
|
||||
status = ib_respond_udata(udata, uresp);
|
||||
if (status)
|
||||
goto err;
|
||||
}
|
||||
status = ocrdma_add_mmap(pd->uctx, uresp.sq_page_addr[0],
|
||||
uresp.sq_page_size);
|
||||
if (status)
|
||||
|
|
@ -1754,7 +1749,7 @@ static int ocrdma_copy_srq_uresp(struct ocrdma_dev *dev, struct ocrdma_srq *srq,
|
|||
uresp.db_shift = 16;
|
||||
}
|
||||
|
||||
status = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
status = ib_respond_udata(udata, uresp);
|
||||
if (status)
|
||||
return status;
|
||||
status = ocrdma_add_mmap(srq->pd->uctx, uresp.rq_page_addr[0],
|
||||
|
|
|
|||
|
|
@ -1251,15 +1251,10 @@ static int qedr_copy_srq_uresp(struct qedr_dev *dev,
|
|||
struct qedr_srq *srq, struct ib_udata *udata)
|
||||
{
|
||||
struct qedr_create_srq_uresp uresp = {};
|
||||
int rc;
|
||||
|
||||
uresp.srq_id = srq->srq_id;
|
||||
|
||||
rc = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
if (rc)
|
||||
DP_ERR(dev, "create srq: problem copying data to user space\n");
|
||||
|
||||
return rc;
|
||||
return ib_respond_udata(udata, uresp);
|
||||
}
|
||||
|
||||
static void qedr_copy_rq_uresp(struct qedr_dev *dev,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ static void usnic_ib_fw_string_to_u64(char *fw_ver_str, u64 *fw_ver)
|
|||
static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev;
|
||||
struct usnic_ib_create_qp_resp resp;
|
||||
struct pci_dev *pdev;
|
||||
struct vnic_dev_bar *bar;
|
||||
|
|
@ -92,7 +91,6 @@ static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
|
|||
|
||||
memset(&resp, 0, sizeof(resp));
|
||||
|
||||
us_ibdev = qp_grp->vf->pf;
|
||||
pdev = usnic_vnic_get_pdev(qp_grp->vf->vnic);
|
||||
if (!pdev) {
|
||||
usnic_err("Failed to get pdev of qp_grp %d\n",
|
||||
|
|
@ -157,12 +155,9 @@ static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
|
|||
struct usnic_ib_qp_grp_flow, link);
|
||||
resp.transport = default_flow->trans_type;
|
||||
|
||||
err = ib_copy_to_udata(udata, &resp, sizeof(resp));
|
||||
if (err) {
|
||||
usnic_err("Failed to copy udata for %s",
|
||||
dev_name(&us_ibdev->ib_dev.dev));
|
||||
err = ib_respond_udata(udata, resp);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,11 +203,10 @@ int pvrdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
|||
cq->uar = &context->uar;
|
||||
|
||||
/* Copy udata back. */
|
||||
if (ib_copy_to_udata(udata, &cq_resp, sizeof(cq_resp))) {
|
||||
dev_warn(&dev->pdev->dev,
|
||||
"failed to copy back udata\n");
|
||||
ret = ib_respond_udata(udata, cq_resp);
|
||||
if (ret) {
|
||||
pvrdma_destroy_cq(&cq->ibcq, udata);
|
||||
return -EINVAL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -195,10 +195,10 @@ int pvrdma_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init_attr,
|
|||
spin_unlock_irqrestore(&dev->srq_tbl_lock, flags);
|
||||
|
||||
/* Copy udata back. */
|
||||
if (ib_copy_to_udata(udata, &srq_resp, sizeof(srq_resp))) {
|
||||
dev_warn(&dev->pdev->dev, "failed to copy back udata\n");
|
||||
ret = ib_respond_udata(udata, srq_resp);
|
||||
if (ret) {
|
||||
pvrdma_destroy_srq(&srq->ibsrq, udata);
|
||||
return -EINVAL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -320,11 +320,11 @@ int pvrdma_alloc_ucontext(struct ib_ucontext *uctx, struct ib_udata *udata)
|
|||
|
||||
/* copy back to user */
|
||||
uresp.qp_tab_size = vdev->dsr->caps.max_qp;
|
||||
ret = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
ret = ib_respond_udata(udata, uresp);
|
||||
if (ret) {
|
||||
pvrdma_uar_free(vdev, &context->uar);
|
||||
pvrdma_dealloc_ucontext(&context->ibucontext);
|
||||
return -EFAULT;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -430,11 +430,10 @@ int pvrdma_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
|
|||
pd_resp.pdn = resp->pd_handle;
|
||||
|
||||
if (udata) {
|
||||
if (ib_copy_to_udata(udata, &pd_resp, sizeof(pd_resp))) {
|
||||
dev_warn(&dev->pdev->dev,
|
||||
"failed to copy back protection domain\n");
|
||||
ret = ib_respond_udata(udata, pd_resp);
|
||||
if (ret) {
|
||||
pvrdma_dealloc_pd(&pd->ibpd, udata);
|
||||
return -EFAULT;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ int rvt_resize_cq(struct ib_cq *ibcq, unsigned int cqe, struct ib_udata *udata)
|
|||
if (udata && udata->outlen >= sizeof(__u64)) {
|
||||
__u64 offset = 0;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &offset, sizeof(offset));
|
||||
ret = ib_respond_udata(udata, offset);
|
||||
if (ret)
|
||||
goto bail_free;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1192,8 +1192,7 @@ int rvt_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
|
|||
if (!qp->r_rq.wq) {
|
||||
__u64 offset = 0;
|
||||
|
||||
ret = ib_copy_to_udata(udata, &offset,
|
||||
sizeof(offset));
|
||||
ret = ib_respond_udata(udata, offset);
|
||||
if (ret)
|
||||
goto bail_qpn;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ int siw_alloc_ucontext(struct ib_ucontext *base_ctx, struct ib_udata *udata)
|
|||
rv = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rv = ib_respond_udata(udata, uresp);
|
||||
if (rv)
|
||||
goto err_out;
|
||||
|
||||
|
|
@ -472,7 +472,7 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
|
|||
rv = -EINVAL;
|
||||
goto err_out_xa;
|
||||
}
|
||||
rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rv = ib_respond_udata(udata, uresp);
|
||||
if (rv)
|
||||
goto err_out_xa;
|
||||
}
|
||||
|
|
@ -1205,7 +1205,7 @@ int siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
|
|||
rv = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rv = ib_respond_udata(udata, uresp);
|
||||
if (rv)
|
||||
goto err_out;
|
||||
}
|
||||
|
|
@ -1386,7 +1386,7 @@ struct ib_mr *siw_reg_user_mr(struct ib_pd *pd, u64 start, u64 len,
|
|||
rv = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rv = ib_respond_udata(udata, uresp);
|
||||
if (rv)
|
||||
goto err_out;
|
||||
}
|
||||
|
|
@ -1646,7 +1646,7 @@ int siw_create_srq(struct ib_srq *base_srq,
|
|||
rv = -EINVAL;
|
||||
goto err_out;
|
||||
}
|
||||
rv = ib_copy_to_udata(udata, &uresp, sizeof(uresp));
|
||||
rv = ib_respond_udata(udata, uresp);
|
||||
if (rv)
|
||||
goto err_out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user