fm10k: don't use BIT() macro where the value isn't a bitmask
Subsystems (2)
PATCH 1/1 fm10k: don't use BIT() macro where the value isn't a bitmask
The FM10K_MAX_DATA_PER_TXD is really just using a bitshift as a power of 2 operation in an efficient manner. We shouldn't represent this as a BIT() because that obscures the intention of the operation.
--- drivers/net/ethernet/intel/fm10k/fm10k.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/fm10k/fm10k.h +1 -1
@@ -406,7 +406,7 @@ static inline u16 fm10k_desc_unused(struct fm10k_ring *ring) (&(((union fm10k_rx_desc *)((R)->desc))[i]))#define FM10K_MAX_TXD_PWR 14 -#define FM10K_MAX_DATA_PER_TXD BIT(FM10K_MAX_TXD_PWR) +#define FM10K_MAX_DATA_PER_TXD (1u << FM10K_MAX_TXD_PWR)/* Tx Descriptors needed, worst case */ #define TXD_USE_COUNT (S ) DIV_ROUND_UP((S), FM10K_MAX_DATA_PER_TXD)
Signature · 1 line
2.8.1.102.ga49ec4a
Keller
PATCH 1/1 fm10k: don't use BIT() macro where the value isn't a bitmask
Quoted 23 lines · Jacob Keller
The
FM10K_MAX_DATA_PER_TXDis really just using a bitshift as a power of
2 operation in an efficient manner. We shouldn't represent this as aBIT()
because that obscures the intention of the operation.Signed-off-by Jacob Keller <[email protected]>---
?drivers/net/ethernet/intel/fm10k/fm10k.h | 2 +-
?1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/fm10k/fm10k.h +0
-0@@ -406,7 +406,7 @@ static inline u16 fm10k_desc_unused(struct fm10k_ring *ring) ? ?(&(((union fm10k_rx_desc *)((R)->desc))[i]))?
?#defineFM10K_MAX_TXD_PWR14drivers/net/ethernet/intel/fm10k/fm10k.h +1
-1-#define FM10K_MAX_DATA_PER_TXD BIT(FM10K_MAX_TXD_PWR) +#define FM10K_MAX_DATA_PER_TXD (1u << FM10K_MAX_TXD_PWR)
Quoted 4 lines
?
?/* Tx Descriptors needed, worst case */
?#defineTXD_USE_COUNT(S)DIV_ROUND_UP((S),FM10K_MAX_DATA_PER_TXD)
Note: this *will* cause a checkpatch warning, but as per discussion with Alex, I think this is a false positive. I don't know if there is a good way to fix it? Perhaps we could introduce some sort of "power of 2" macro that would leave in a single place, but I really don't know if that makes a lot of sense. I also am not sure how to make checkpatch.pl avoid the complaints for specific cases such as this.
Thanks,
Jake
Singh
PATCH 1/1 fm10k: don't use BIT() macro where the value isn't a bitmask
In reply to Jacob Keller-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Thursday, April 14, 2016 1:17 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PATCH] fm10k: don't use BIT() macro where the value isn't a bitmask
The FM10K_MAX_DATA_PER_TXD is really just using a bitshift as a power of
2 operation in an efficient manner. We shouldn't represent this as a BIT() because that obscures the intention of the operation.
---