if (dev_attr->max_dpi)
dpit->max = min_t(u32, dpit->max, dev_attr->max_dpi);
- dpit->app_tbl = kcalloc(dpit->max, sizeof(void *), GFP_KERNEL);
+ dpit->app_tbl = kzalloc_objs(void *, dpit->max);
if (!dpit->app_tbl)
return -ENOMEM;
if (tinfo->length == 0)
return -EINVAL;
- tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL);
+ tidbuf = kzalloc_obj(*tidbuf);
if (!tidbuf)
return -ENOMEM;
tidbuf->vaddr = tinfo->vaddr;
tidbuf->length = tinfo->length;
tidbuf->npages = num_user_pages(tidbuf->vaddr, tidbuf->length);
- tidbuf->psets = kcalloc(uctxt->expected_count, sizeof(*tidbuf->psets),
- GFP_KERNEL);
+ tidbuf->psets = kzalloc_objs(*tidbuf->psets, uctxt->expected_count);
if (!tidbuf->psets) {
ret = -ENOMEM;
goto fail_release_mem;
}
ngroups = pageset_count / dd->rcv_entries.group_size;
- tidlist = kcalloc(pageset_count, sizeof(*tidlist), GFP_KERNEL);
+ tidlist = kzalloc_objs(*tidlist, pageset_count);
if (!tidlist) {
ret = -ENOMEM;
goto fail_unreserve;
* for a long time.
* Copy the data to a local buffer so we can release the lock.
*/
- array = kcalloc(uctxt->expected_count, sizeof(*array), GFP_KERNEL);
+ array = kzalloc_objs(*array, uctxt->expected_count);
if (!array)
return -EFAULT;
unsigned long num_bt_l1;
num_bt_l1 = DIV_ROUND_UP(num_hem, bt_chunk_num);
- table->bt_l1 = kcalloc(num_bt_l1,
- sizeof(*table->bt_l1),
- GFP_KERNEL);
+ table->bt_l1 = kzalloc_objs(*table->bt_l1, num_bt_l1);
if (!table->bt_l1)
goto err_kcalloc_bt_l1;
if (check_whether_bt_num_2(type, hop_num) ||
check_whether_bt_num_3(type, hop_num)) {
- table->bt_l0 = kcalloc(num_bt_l0, sizeof(*table->bt_l0),
- GFP_KERNEL);
+ table->bt_l0 = kzalloc_objs(*table->bt_l0, num_bt_l0);
if (!table->bt_l0)
goto err_kcalloc_bt_l0;
static int alloc_kernel_wrid(struct hns_roce_dev *hr_dev,
struct hns_roce_qp *hr_qp)
{
- struct ib_device *ibdev = &hr_dev->ib_dev;
- u64 *sq_wrid = NULL;
- u64 *rq_wrid = NULL;
+ u64 *sq_wrid, *rq_wrid = NULL;
int ret;
- sq_wrid = kcalloc(hr_qp->sq.wqe_cnt, sizeof(u64), GFP_KERNEL);
- if (!sq_wrid) {
- ibdev_err(ibdev, "failed to alloc SQ wrid.\n");
+ sq_wrid = kzalloc_objs(*sq_wrid, hr_qp->sq.wqe_cnt);
+ if (!sq_wrid)
return -ENOMEM;
- }
if (hr_qp->rq.wqe_cnt) {
- rq_wrid = kcalloc(hr_qp->rq.wqe_cnt, sizeof(u64), GFP_KERNEL);
+ rq_wrid = kzalloc_objs(*rq_wrid, hr_qp->rq.wqe_cnt);
if (!rq_wrid) {
- ibdev_err(ibdev, "failed to alloc RQ wrid.\n");
ret = -ENOMEM;
goto err_sq;
}
if (!cqp->cqp_requests)
return -ENOMEM;
- cqp->scratch_array = kcalloc(sqsize, sizeof(*cqp->scratch_array), GFP_KERNEL);
+ cqp->scratch_array = kzalloc_objs(*cqp->scratch_array, sqsize);
if (!cqp->scratch_array) {
status = -ENOMEM;
goto err_scratch;
if (status)
return status;
- stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL);
+ stats_info.pestat = kzalloc_obj(*stats_info.pestat);
if (!stats_info.pestat) {
irdma_cleanup_cm_core(&iwdev->cm_core);
return -ENOMEM;
if (!*pdescs)
return -ENOMEM;
- *offset = kcalloc(num_counters, sizeof(**offset), GFP_KERNEL);
+ *offset = kzalloc_objs(**offset, num_counters);
if (!*offset)
goto err;
if (IS_ERR(cmd_out))
return PTR_ERR(cmd_out);
- obj = kzalloc(sizeof(struct devx_obj), GFP_KERNEL);
+ obj = kzalloc_obj(*obj);
if (!obj)
return -ENOMEM;
if (err)
goto err;
- event_sub = kzalloc(sizeof(*event_sub), GFP_KERNEL);
+ event_sub = kzalloc_obj(*event_sub);
if (!event_sub) {
err = -ENOMEM;
goto err;
if (err)
return err;
- obj = kzalloc(sizeof(struct devx_umem), GFP_KERNEL);
+ obj = kzalloc_obj(*obj);
if (!obj)
return -ENOMEM;
if (!err || err != -ENOENT)
goto err_unlock;
- op_entry = kzalloc(sizeof(*op_entry), GFP_KERNEL);
+ op_entry = kzalloc_obj(*op_entry);
if (!op_entry)
goto err_unlock;
struct mlx5_ib_flow_matcher *obj;
int err;
- obj = kzalloc(sizeof(struct mlx5_ib_flow_matcher), GFP_KERNEL);
+ obj = kzalloc_obj(*obj);
if (!obj)
return -ENOMEM;
if (err)
return err;
- obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+ obj = kzalloc_obj(*obj);
if (!obj)
return -ENOMEM;
if (!mlx5_ib_flow_action_packet_reformat_valid(mdev, dv_prt, ft_type))
return -EOPNOTSUPP;
- maction = kzalloc(sizeof(*maction), GFP_KERNEL);
+ maction = kzalloc_obj(*maction);
if (!maction)
return -ENOMEM;
mutex_init(&bfregi->lock);
bfregi->lib_uar_4k = lib_uar_4k;
- bfregi->count = kcalloc(bfregi->total_num_bfregs, sizeof(*bfregi->count),
- GFP_KERNEL);
+ bfregi->count = kzalloc_objs(*bfregi->count, bfregi->total_num_bfregs);
if (!bfregi->count) {
err = -ENOMEM;
goto out_ucap;
}
- bfregi->sys_pages = kcalloc(bfregi->num_sys_pages,
- sizeof(*bfregi->sys_pages),
- GFP_KERNEL);
+ bfregi->sys_pages =
+ kzalloc_objs(*bfregi->sys_pages, bfregi->num_sys_pages);
if (!bfregi->sys_pages) {
err = -ENOMEM;
goto out_count;
return -EINVAL;
dev = to_mdev(c->ibucontext.device);
- pp_entry = kzalloc(sizeof(*pp_entry), GFP_KERNEL);
+ pp_entry = kzalloc_obj(*pp_entry);
if (!pp_entry)
return -ENOMEM;
void *va;
dma_addr_t pa;
- mr->pbl_table = kzalloc_objs(struct ocrdma_pbl, mr->num_pbls);
+ mr->pbl_table = kzalloc_objs(*mr->pbl_table, mr->num_pbls);
if (!mr->pbl_table)
return -ENOMEM;
static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp)
{
- qp->wqe_wr_id_tbl =
- kzalloc_objs(*(qp->wqe_wr_id_tbl), qp->sq.max_cnt);
+ qp->wqe_wr_id_tbl = kzalloc_objs(*qp->wqe_wr_id_tbl, qp->sq.max_cnt);
if (qp->wqe_wr_id_tbl == NULL)
return -ENOMEM;
- qp->rqe_wr_id_tbl =
- kcalloc(qp->rq.max_cnt, sizeof(u64), GFP_KERNEL);
+
+ qp->rqe_wr_id_tbl = kzalloc_objs(*qp->rqe_wr_id_tbl, qp->rq.max_cnt);
if (qp->rqe_wr_id_tbl == NULL)
return -ENOMEM;
return status;
if (!udata) {
- srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, sizeof(u64),
- GFP_KERNEL);
+ srq->rqe_wr_id_tbl =
+ kzalloc_objs(*srq->rqe_wr_id_tbl, srq->rq.max_cnt);
if (!srq->rqe_wr_id_tbl) {
status = -ENOMEM;
goto arm_err;
if (!mr)
return ERR_PTR(-ENOMEM);
- mr->pages = kcalloc(max_num_sg, sizeof(u64), GFP_KERNEL);
+ mr->pages = kzalloc_objs(*mr->pages, max_num_sg);
if (!mr->pages) {
status = -ENOMEM;
goto pl_err;
goto err;
pdir->ntables = PVRDMA_PAGE_DIR_TABLE(npages - 1) + 1;
- pdir->tables = kcalloc(pdir->ntables, sizeof(*pdir->tables),
- GFP_KERNEL);
+ pdir->tables = kzalloc_objs(*pdir->tables, pdir->ntables);
if (!pdir->tables)
goto err;