Skip to content

Commit dd3e7cb

Browse files
andy-shevtorvalds
authored andcommitted
ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use
There are users already and will be more of BITS_TO_BYTES() macro. Move it to bitops.h for wider use. In the case of ocfs2 the replacement is identical. As for bnx2x, there are two places where floor version is used. In the first case to calculate the amount of structures that can fit one memory page. In this case obviously the ceiling variant is correct and original code might have a potential bug, if amount of bits % 8 is not 0. In the second case the macro is used to calculate bytes transmitted in one microsecond. This will work for all speeds which is multiply of 1Gbps without any change, for the rest new code will give ceiling value, for instance 100Mbps will give 13 bytes, while old code gives 12 bytes and the arithmetically correct one is 12.5 bytes. Further the value is used to setup timer threshold which in any case has its own margins due to certain resolution. I don't see here an issue with slightly shifting thresholds for low speed connections, the card is supposed to utilize highest available rate, which is usually 10Gbps. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Acked-by: Sudarsana Reddy Kalluru <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d8f1875 commit dd3e7cb

File tree

3 files changed

+1
-5
lines changed

3 files changed

+1
-5
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_init.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ static inline void bnx2x_dcb_config_qm(struct bnx2x *bp, enum cos_mode mode,
296296
* possible, the driver should only write the valid vnics into the internal
297297
* ram according to the appropriate port mode.
298298
*/
299-
#define BITS_TO_BYTES(x) ((x)/8)
300299

301300
/* CMNG constants, as derived from system spec calculations */
302301

fs/ocfs2/dlm/dlmcommon.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,6 @@ struct dlm_begin_reco
688688
__be32 pad2;
689689
};
690690

691-
692-
#define BITS_PER_BYTE 8
693-
#define BITS_TO_BYTES(bits) (((bits)+BITS_PER_BYTE-1)/BITS_PER_BYTE)
694-
695691
struct dlm_query_join_request
696692
{
697693
u8 node_idx;

include/linux/bitops.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
1515
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
16+
#define BITS_TO_BYTES(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(char))
1617

1718
extern unsigned int __sw_hweight8(unsigned int w);
1819
extern unsigned int __sw_hweight16(unsigned int w);

0 commit comments

Comments
 (0)