Skip to content

Commit

Permalink
RDMA/restrack: clean up res_to_dev()
Browse files Browse the repository at this point in the history
Simplify res_to_dev() to make it easier to read/maintain.

Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
  • Loading branch information
Steve Wise authored and Doug Ledford committed Mar 8, 2018
1 parent d50a8a9 commit 88831a2
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions drivers/infiniband/core/restrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,17 @@ static void set_kern_name(struct rdma_restrack_entry *res)

static struct ib_device *res_to_dev(struct rdma_restrack_entry *res)
{
enum rdma_restrack_type type = res->type;
struct ib_device *dev;
struct ib_pd *pd;
struct ib_cq *cq;
struct ib_qp *qp;

switch (type) {
switch (res->type) {
case RDMA_RESTRACK_PD:
pd = container_of(res, struct ib_pd, res);
dev = pd->device;
break;
return container_of(res, struct ib_pd, res)->device;
case RDMA_RESTRACK_CQ:
cq = container_of(res, struct ib_cq, res);
dev = cq->device;
break;
return container_of(res, struct ib_cq, res)->device;
case RDMA_RESTRACK_QP:
qp = container_of(res, struct ib_qp, res);
dev = qp->device;
break;
return container_of(res, struct ib_qp, res)->device;
default:
WARN_ONCE(true, "Wrong resource tracking type %u\n", type);
WARN_ONCE(true, "Wrong resource tracking type %u\n", res->type);
return NULL;
}

return dev;
}

static bool res_is_user(struct rdma_restrack_entry *res)
Expand Down

0 comments on commit 88831a2

Please sign in to comment.