diff mbox series

[v1] RDMA/core: Cosmetic change - move member initialization to correct block

Message ID 20190218142322.25572-1-yuval.shaia@oracle.com (mailing list archive)
State Mainlined
Commit e278173fd19eb537e73190c50c162950f192e047
Delegated to: Jason Gunthorpe
Headers show
Series [v1] RDMA/core: Cosmetic change - move member initialization to correct block | expand

Commit Message

Yuval Shaia Feb. 18, 2019, 2:23 p.m. UTC
old_pd is used only if IB_MR_REREG_PD flags is set.
For readability move it's initialization to where it is used.

While there rewrite the whole 'if-else' block so on error jump directly
to label and no need for 'else'

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
v0 -> v1:
	* Accept comment from Leon and rewrite the whole if-else block
---
 drivers/infiniband/core/uverbs_cmd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

Leon Romanovsky Feb. 18, 2019, 8:05 p.m. UTC | #1
On Mon, Feb 18, 2019 at 04:23:22PM +0200, Yuval Shaia wrote:
> old_pd is used only if IB_MR_REREG_PD flags is set.
> For readability move it's initialization to where it is used.
>
> While there rewrite the whole 'if-else' block so on error jump directly
> to label and no need for 'else'
>
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
> v0 -> v1:
> 	* Accept comment from Leon and rewrite the whole if-else block
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)

Except that subject looks a little bit weird,

Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Thanks
Jason Gunthorpe Feb. 19, 2019, 10:02 p.m. UTC | #2
On Mon, Feb 18, 2019 at 04:23:22PM +0200, Yuval Shaia wrote:
> old_pd is used only if IB_MR_REREG_PD flags is set.
> For readability move it's initialization to where it is used.
> 
> While there rewrite the whole 'if-else' block so on error jump directly
> to label and no need for 'else'
> 
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> v0 -> v1:
> 	* Accept comment from Leon and rewrite the whole if-else block
> ---
>  drivers/infiniband/core/uverbs_cmd.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)

Applied to for-next

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index d4f1a2ef5015..66bdc2b32887 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -810,19 +810,18 @@  static int ib_uverbs_rereg_mr(struct uverbs_attr_bundle *attrs)
 		}
 	}
 
-	old_pd = mr->pd;
 	ret = mr->device->ops.rereg_user_mr(mr, cmd.flags, cmd.start,
 					    cmd.length, cmd.hca_va,
 					    cmd.access_flags, pd,
 					    &attrs->driver_udata);
-	if (!ret) {
-		if (cmd.flags & IB_MR_REREG_PD) {
-			atomic_inc(&pd->usecnt);
-			mr->pd = pd;
-			atomic_dec(&old_pd->usecnt);
-		}
-	} else {
+	if (ret)
 		goto put_uobj_pd;
+
+	if (cmd.flags & IB_MR_REREG_PD) {
+		old_pd = mr->pd;
+		atomic_inc(&pd->usecnt);
+		mr->pd = pd;
+		atomic_dec(&old_pd->usecnt);
 	}
 
 	memset(&resp, 0, sizeof(resp));