RDMA/cm: Use IBA functions for simple structure members
authorJason Gunthorpe <jgg@mellanox.com>
Thu, 16 Jan 2020 17:00:35 +0000 (13:00 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Sat, 25 Jan 2020 19:06:00 +0000 (15:06 -0400)
commit91b60a7128d96244794beb9b324eb39273872da2
tree7cbaa405981a2bbc9b5a1d8817fa61ba840f8bef
parent01adb7f46fe455975d9aec07966e72958bc20f8e
RDMA/cm: Use IBA functions for simple structure members

Use a Coccinelle spatch script to replace use of simple CM structure
members with IBA_GET/SET versions. Applied with

$ spatch --sp-file edits.sp --in-place drivers/infiniband/core/cm.c

The spatch file was generated using the template pattern:

@@
expression val;
{struct} *msg;
@@
- msg->{old_name} = val
+ IBA_SET({new_name}, msg, be{bits}_to_cpu(val))
@@
{struct} *msg;
@@
- msg->{old_name}
+ cpu_to_be{bits}(IBA_GET({new_name}, msg))

Iterated for every IBA_CHECK_OFF that isn't a CM_FIELD_MLOC.

And the below iterated over all byte sizes to remove doubled byte swaps:

@@
expression val;
@@
-be{bits}_to_cpu(cpu_to_be{bits}(val))
+val

(and __be_to_cpu and ntoh varients)

Touched up with clang-format after.

Link: https://lore.kernel.org/r/20200116170037.30109-6-jgg@ziepe.ca
Tested-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cm.c