ixgbevf: replace enum with MACROs
Subsystems (3)
PATCH 1/1 ixgbevf: replace enum with MACROs
Sorry. Please ignore the last mail because there are some typos in the patch.
In this patch, these typos are corrected.
Zhu Yanjun
PATCH 1/1 ixgbevf: replace enum with MACROs
From: Zhu Yanjun <[email protected]>
With the original enum, when a several bits state is set, it is possible that the wrong test occurs.
For example,
a state is 0x3, its bits are 11. When testing a state 0x2 whose bits are 10, it is difficult to confirm that state 0x2 is set or not.
As such, the MACROs are defined to avoid the above error.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +10 -12
@@ -436,18 +436,16 @@ struct ixgbevf_adapter {u8 rss_indir_tbl[IXGBEVF_X550_VFRETA_SIZE ]; }; -enum ixbgevf_state_t { - __IXGBEVF_TESTING, - __IXGBEVF_RESETTING, - __IXGBEVF_DOWN, - __IXGBEVF_DISABLED, - __IXGBEVF_REMOVING, - __IXGBEVF_SERVICE_SCHED, - __IXGBEVF_SERVICE_INITED, - __IXGBEVF_RESET_REQUESTED, - __IXGBEVF_QUEUE_RESET_REQUESTED, - __IXGBEVF_HW_RESETTING, -}; +#define __IXGBEVF_TESTING 0x0001 +#define __IXGBEVF_RESETTING 0x0002 +#define __IXGBEVF_DOWN 0x0004 +#define __IXGBEVF_DISABLED 0x0008 +#define __IXGBEVF_REMOVING 0x0010 +#define __IXGBEVF_SERVICE_SCHED 0x0020 +#define __IXGBEVF_SERVICE_INITED 0x0040 +#define __IXGBEVF_RESET_REQUESTED 0x0080 +#define __IXGBEVF_QUEUE_RESET_REQUESTED 0x0100 +#define __IXGBEVF_HW_RESETTING 0x0200enum ixgbevf_boards { board_82599_vf,
Signature · 1 line
2.7.4
Quoted 41 lines · On Wed, Jul 20, 2016 at 3:41 AM, <[email protected]> wrote:
From: Zhu Yanjun <[email protected]>
With the original enum, when a several bits state is set, it is possible that the wrong test occurs.
For example,
a state is
0x3, its bits are 11. When testing a state0x2whose bits are 10, it is difficult to confirm that state0x2is set or not.As such, the MACROs are defined to avoid the above error.
Signed-off-by Zhu Yanjun <[email protected]>--- drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +3
-12@@ -436,18 +436,16 @@ struct ixgbevf_adapter {u8 rss_indir_tbl[IXGBEVF_X550_VFRETA_SIZE ]; }; -enum ixbgevf_state_t { - __IXGBEVF_TESTING, - __IXGBEVF_RESETTING, - __IXGBEVF_DOWN, - __IXGBEVF_DISABLED, - __IXGBEVF_REMOVING, - __IXGBEVF_SERVICE_SCHED, - __IXGBEVF_SERVICE_INITED, - __IXGBEVF_RESET_REQUESTED, - __IXGBEVF_QUEUE_RESET_REQUESTED, - __IXGBEVF_HW_RESETTING, -}; +#define __IXGBEVF_TESTING 0x0001 +#define __IXGBEVF_RESETTING 0x0002 +#define __IXGBEVF_DOWN 0x0004
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h struct ixgbevf_adapter { · line 451
Quoted 10 lines
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +7
-0+#define __IXGBEVF_DISABLED 0x0008 +#define __IXGBEVF_REMOVING 0x0010 +#define __IXGBEVF_SERVICE_SCHED 0x0020 +#define __IXGBEVF_SERVICE_INITED 0x0040 +#define __IXGBEVF_RESET_REQUESTED 0x0080 +#define __IXGBEVF_QUEUE_RESET_REQUESTED 0x0100 +#define __IXGBEVF_HW_RESETTING 0x0200enum ixgbevf_boards { board_82599_vf,
You cannot replace a bit offset with a mask without also having to update all the spots where the bit offset is used.
There isn't much point to replacing the enum with a macro anyway. Using multiple test_bit expressions should be valid for testing multiple bits.
- Alex
Got it. Thanks a lot.
Zhu Yanjun
On Wed, Jul 20, 2016 at 10:29 PM, Alexander Duyck <[email protected]
Quoted 59 lines
wrote:
Quoted 11 lines · On Wed, Jul 20, 2016 at 3:41 AM, <[email protected]> wrote:
From: Zhu Yanjun <[email protected]>
With the original enum, when a several bits state is set, it is possible that the wrong test occurs.
For example,
a state is
0x3, its bits are 11. When testing a state0x2whose bits are 10, it is difficult to confirm that state0x2is set or not.Review
Quoted 8 lines
As such, the MACROs are defined to avoid the above error.
Signed-off-by Zhu Yanjun <[email protected]>--- drivers/net/ethernet/intel/ixgbevf/ixgbevf.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.hQuoted 22 lines
index 60fc63b..d37b910 100644
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +3
-12@@ -436,18 +436,16 @@ struct ixgbevf_adapter {u8 rss_indir_tbl[IXGBEVF_X550_VFRETA_SIZE ]; }; -enum ixbgevf_state_t { - __IXGBEVF_TESTING, - __IXGBEVF_RESETTING, - __IXGBEVF_DOWN, - __IXGBEVF_DISABLED, - __IXGBEVF_REMOVING, - __IXGBEVF_SERVICE_SCHED, - __IXGBEVF_SERVICE_INITED, - __IXGBEVF_RESET_REQUESTED, - __IXGBEVF_QUEUE_RESET_REQUESTED, - __IXGBEVF_HW_RESETTING, -}; +#define __IXGBEVF_TESTING 0x0001 +#define __IXGBEVF_RESETTING 0x0002 +#define __IXGBEVF_DOWN 0x0004drivers/net/ethernet/intel/ixgbevf/ixgbevf.h struct ixgbevf_adapter { · line 451
Quoted 10 lines
drivers/net/ethernet/intel/ixgbevf/ixgbevf.h +7
-0+#define __IXGBEVF_DISABLED 0x0008 +#define __IXGBEVF_REMOVING 0x0010 +#define __IXGBEVF_SERVICE_SCHED 0x0020 +#define __IXGBEVF_SERVICE_INITED 0x0040 +#define __IXGBEVF_RESET_REQUESTED 0x0080 +#define __IXGBEVF_QUEUE_RESET_REQUESTED 0x0100 +#define __IXGBEVF_HW_RESETTING 0x0200enum ixgbevf_boards { board_82599_vf,You cannot replace a bit offset with a mask without also having to update all the spots where the bit offset is used.
Quoted 6 lines
There isn't much point to replacing the enum with a macro anyway. Using multiple
test_bitexpressions should be valid for testing multiple bits.- Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160721/d2d64899/attachment-0001.html>