iavf: field prep conversion
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Wed, 6 Dec 2023 01:01:04 +0000 (17:01 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 18 Dec 2023 19:16:15 +0000 (11:16 -0800)
commit9b7f18042d4c12ecc5fc797c0a31b0ff0bcef3cc
tree4b8f79df0e96471e0588f17dd6e62acf56d6ef90
parent9e3ab72c049929afccea62a08dbaeaeee8e06c46
iavf: field prep conversion

Refactor iavf driver to use FIELD_PREP(), which reduces lines of code
and adds clarity of intent.

This code was generated by the following coccinelle/spatch script and
then manually repaired.

Clean up a couple spots in the code that had repetitive
y = cpu_to_*((blah << blah_blah) & blat)
y |= cpu_to_*((blahs << blahs_blahs) & blats)
to
x = FIELD_PREP(blat blah)
x |= FIELD_PREP(blats, blahs)
y = cpu_to_*(x);

@prep2@
constant shift,mask;
type T;
expression a;
@@
-(((T)(a) << shift) & mask)
+FIELD_PREP(mask, a)

@prep@
constant shift,mask;
type T;
expression a;
@@
-((T)((a) << shift) & mask)
+FIELD_PREP(mask, a)

Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: Ahmed Zaki <ahmed.zaki@intel.com>
Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/iavf/iavf_common.c
drivers/net/ethernet/intel/iavf/iavf_fdir.c