cpumask: to_cpumask()

There are times when we really want a static cpumask.  Yet we don't
want to expose the struct cpumask definition, to avoid casual on-stack
usage and assignment.

So this macro allows you to do DECLARE_BITMAP(map, NR_CPUS); then use
to_cpumask() to turn it into a cpumask as needed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/cpumask.h |    9 +++++++++
 1 file changed, 9 insertions(+)

diff -r 9bbd7f1947ae include/linux/cpumask.h
--- a/include/linux/cpumask.h	Mon Sep 29 00:27:19 2008 +1000
+++ b/include/linux/cpumask.h	Mon Sep 29 22:44:14 2008 +1000
@@ -57,6 +57,9 @@
  * CPU_MASK_ALL				Initializer - all bits set
  * CPU_MASK_NONE			Initializer - no bits set
  * unsigned long *cpumask_bits(mask)	Array of unsigned long's in mask
+ *
+ * struct cpumask *to_cpumask(const unsigned long[])
+ *					Convert a bitmap to a cpumask.
  *
  * ------------------------------------------------------------------------
  *
@@ -358,6 +361,12 @@ static inline void cpumask_copy(struct c
 #define cpumask_any(srcp) cpumask_first(srcp)
 #define cpumask_any_both(mask1, mask2) cpumask_first_both((mask1), (mask2))
 
+/* Used for static bitmaps of NR_CPUS bits. */
+static inline struct cpumask *to_cpumask(const unsigned long *bitmap)
+{
+	return (struct cpumask *)bitmap;
+}
+
 /*
  * Special-case data structure for "single bit set only" constant CPU masks.
  *
