Skip to content

Commit

Permalink
RDMA/rtrs: Introduce destroy_cq helper
Browse files Browse the repository at this point in the history
The same code snip used twice, to avoid duplicate, replace it with a
destroy_cq helper.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jack Wang <[email protected]>
Signed-off-by: Md Haris Iqbal <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
hiqbal-ionos authored and jgunthorpe committed Oct 4, 2021
1 parent 36332de commit 6f5649a
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions drivers/infiniband/ulp/rtrs/rtrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,17 @@ static int create_qp(struct rtrs_con *con, struct ib_pd *pd,
return ret;
}

static void destroy_cq(struct rtrs_con *con)
{
if (con->cq) {
if (is_pollqueue(con))
ib_free_cq(con->cq);
else
ib_cq_pool_put(con->cq, con->nr_cqe);
}
con->cq = NULL;
}

int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con,
u32 max_send_sge, int cq_vector, int nr_cqe,
u32 max_send_wr, u32 max_recv_wr,
Expand All @@ -293,11 +304,7 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con,
err = create_qp(con, sess->dev->ib_pd, max_send_wr, max_recv_wr,
max_send_sge);
if (err) {
if (is_pollqueue(con))
ib_free_cq(con->cq);
else
ib_cq_pool_put(con->cq, con->nr_cqe);
con->cq = NULL;
destroy_cq(con);
return err;
}
con->sess = sess;
Expand All @@ -312,13 +319,7 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con)
rdma_destroy_qp(con->cm_id);
con->qp = NULL;
}
if (con->cq) {
if (is_pollqueue(con))
ib_free_cq(con->cq);
else
ib_cq_pool_put(con->cq, con->nr_cqe);
con->cq = NULL;
}
destroy_cq(con);
}
EXPORT_SYMBOL_GPL(rtrs_cq_qp_destroy);

Expand Down

0 comments on commit 6f5649a

Please sign in to comment.