ice: compress branches in ice_set_features()
authorMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Thu, 7 Jul 2022 10:16:50 +0000 (12:16 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 28 Jul 2022 18:44:40 +0000 (11:44 -0700)
commitc67672fa26959b5b636c149634e69491a4d64206
treea4f531c342d09e266158fcb9f913e4a88ff221a4
parenta419526de6079e4b8a001bcbb8ac7370ba581963
ice: compress branches in ice_set_features()

Instead of rather verbose comparison of current netdev->features bits vs
the incoming ones from user, let us compress them by a helper features
set that will be the result of netdev->features XOR features. This way,
current, extensive branches:

if (features & NETIF_F_BIT && !(netdev->features & NETIF_F_BIT))
set_feature(true);
else if (!(features & NETIF_F_BIT) && netdev->features & NETIF_F_BIT)
set_feature(false);

can become:

netdev_features_t changed = netdev->features ^ features;

if (changed & NETIF_F_BIT)
set_feature(!!(features & NETIF_F_BIT));

This is nothing new as currently several other drivers use this
approach, which I find much more convenient.

Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_main.c