Skip to contentSkip to conversation

bitops.h: use BITS_PER_LONG to simplify BITS_TO_LONGS

PATCH In review Wei Yang 2 participants 4 messages Mar 18, 2017 – May 3, 2017 Bitops API

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 bitops.h: use BITS_PER_LONG to simplify BITS_TO_LONGS

The second parameter is the number of bits for type "long", which is already defined in header file.

This patch replace the calculation with macro to make it more readable.

---
 include/linux/bitops.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bitops.h +1 -1
index a83c822c35c2..923fe72d31e3 100644
@@ -10,7 +10,7 @@
 #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
 #define BIT_ULL_WORD(nr)	((nr) / BITS_PER_LONG_LONG)
 #define BITS_PER_BYTE		8
-#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_LONG)
 #endif
 
 /*
Signature · 1 line
2.11.0
author
#1 lore raw

Hi, masters

Not sure this one is acceptable?

Quoted 25 lines · Wei Yang

The second parameter is the number of bits for type "long", which is already defined in header file.

This patch replace the calculation with macro to make it more readable.

---
include/linux/bitops.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bitops.h +1 -1
index a83c822c35c2..923fe72d31e3 100644
@@ -10,7 +10,7 @@
 #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
 #define BIT_ULL_WORD(nr)	((nr) / BITS_PER_LONG_LONG)
 #define BITS_PER_BYTE		8
-#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_LONG)
 #endif
 
 /*
Signature · 1 line
2.11.0
Signature · 2 lines
Wei Yang
Help you, Help me
#2 lore raw
Quoted 3 lines · Wei Yang

Hi, masters

Not sure this one is acceptable?

You'd have better luck getting a response if you post things like this to akpm - he tends to collect miscellaneous bits and pieces. I don't think the patch makes more that a tiny improvement and I wouldn't bother with it, but maybe Andrew will.

NeilBrown

Quoted 31 lines · Wei Yang
Quoted 25 lines

The second parameter is the number of bits for type "long", which is already defined in header file.

This patch replace the calculation with macro to make it more readable.

---
include/linux/bitops.h | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bitops.h +1 -1
index a83c822c35c2..923fe72d31e3 100644
@@ -10,7 +10,7 @@
 #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
 #define BIT_ULL_WORD(nr)	((nr) / BITS_PER_LONG_LONG)
 #define BITS_PER_BYTE		8
-#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_LONG)
 #endif
 
 /*
Signature · 1 line
2.11.0
Signature · 2 lines
Wei Yang
Help you, Help me
author
#3 lore raw
Quoted 4 lines · NeilBrown
Quoted 2 lines · Wei Yang

Hi, masters

Quoted 9 lines
Quoted 1 line

Not sure this one is acceptable?

You'd have better luck getting a response if you post things like this to akpm - he tends to collect miscellaneous bits and pieces. I don't think the patch makes more that a tiny improvement and I wouldn't bother with it, but maybe Andrew will.

NeilBrown

Yep, thanks for your comment :-)

Signature · 2 lines
Wei Yang
Help you, Help me