Commit 88831a2c authored by Steve Wise's avatar Steve Wise Committed by Doug Ledford

RDMA/restrack: clean up res_to_dev()

Simplify res_to_dev() to make it easier to read/maintain.
Reviewed-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent d50a8a96
...@@ -60,31 +60,17 @@ static void set_kern_name(struct rdma_restrack_entry *res) ...@@ -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) static struct ib_device *res_to_dev(struct rdma_restrack_entry *res)
{ {
enum rdma_restrack_type type = res->type; switch (res->type) {
struct ib_device *dev;
struct ib_pd *pd;
struct ib_cq *cq;
struct ib_qp *qp;
switch (type) {
case RDMA_RESTRACK_PD: case RDMA_RESTRACK_PD:
pd = container_of(res, struct ib_pd, res); return container_of(res, struct ib_pd, res)->device;
dev = pd->device;
break;
case RDMA_RESTRACK_CQ: case RDMA_RESTRACK_CQ:
cq = container_of(res, struct ib_cq, res); return container_of(res, struct ib_cq, res)->device;
dev = cq->device;
break;
case RDMA_RESTRACK_QP: case RDMA_RESTRACK_QP:
qp = container_of(res, struct ib_qp, res); return container_of(res, struct ib_qp, res)->device;
dev = qp->device;
break;
default: 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 NULL;
} }
return dev;
} }
static bool res_is_user(struct rdma_restrack_entry *res) static bool res_is_user(struct rdma_restrack_entry *res)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment