All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitops: Introduce BITS_PER_TYPE
@ 2018-07-06  9:44 Chris Wilson
  2018-07-06 10:03 ` Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Chris Wilson @ 2018-07-06  9:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Chris Wilson, Jani Nikula, Andy Gospodarek, David S . Miller,
	Thomas Gleixner, Andrew Morton, Ingo Molnar

net_dim.h has a rather useful extension to BITS_PER_BYTE to compute the
number of bits in a type (BITS_PER_BYTE * sizeof(T)), so promote the
macro to bitops.h, alongside BITS_PER_BYTE, for wider usage.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Andy Gospodarek <gospo@broadcom.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
---
 include/linux/bitops.h  | 3 ++-
 include/linux/net_dim.h | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 4cac4e1a72ff..091cb17d1a9b 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -11,7 +11,8 @@
 #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_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
+#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
 #endif
 
 /*
diff --git a/include/linux/net_dim.h b/include/linux/net_dim.h
index 29ed8fd6379a..14f1734e740a 100644
--- a/include/linux/net_dim.h
+++ b/include/linux/net_dim.h
@@ -326,7 +326,6 @@ static inline void net_dim_sample(u16 event_ctr,
 }
 
 #define NET_DIM_NEVENTS 64
-#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
 #define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1))
 
 static inline void net_dim_calc_stats(struct net_dim_sample *start,
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-06 21:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-06  9:44 [PATCH] bitops: Introduce BITS_PER_TYPE Chris Wilson
2018-07-06 10:03 ` Jani Nikula
2018-07-06 17:48 ` Randy Dunlap
2018-07-06 17:51   ` Chris Wilson
2018-07-06 17:55     ` Randy Dunlap
2018-07-06 18:00       ` Chris Wilson
2018-07-06 18:38         ` Randy Dunlap
2018-07-06 21:57 ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.