aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/restrack.c
diff options
context:
space:
mode:
authorSteve Wise <swise@opengridcomputing.com>2018-03-01 13:57:22 -0800
committerDoug Ledford <dledford@redhat.com>2018-03-08 15:03:03 -0500
commit88831a2cfe2245822200ecf4bd7ff77abdf1499a (patch)
treefd58e23b59e6370da9c83b92fc6a719a548d23d9 /drivers/infiniband/core/restrack.c
parentIB/mlx4: Move mlx4_uverbs_ex_query_device_resp to include/uapi/ (diff)
downloadlinux-dev-88831a2cfe2245822200ecf4bd7ff77abdf1499a.tar.xz
linux-dev-88831a2cfe2245822200ecf4bd7ff77abdf1499a.zip
RDMA/restrack: clean up res_to_dev()
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>
Diffstat (limited to '')
-rw-r--r--drivers/infiniband/core/restrack.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/infiniband/core/restrack.c b/drivers/infiniband/core/restrack.c
index 3dbc4e4cca41..41a780085e6d 100644
--- a/drivers/infiniband/core/restrack.c
+++ b/drivers/infiniband/core/restrack.c
@@ -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)