cpumask: cpumask_any_but()

There's a common case where we want any online cpu except a particular
one.  This creates a helper to do that, otherwise we need a temp var
and cpumask_andnot().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 include/linux/cpumask.h |    3 +++
 lib/cpumask.c           |   10 ++++++++++
 2 files changed, 13 insertions(+)

diff -r 8b67d221b01f include/linux/cpumask.h
--- a/include/linux/cpumask.h	Sun Oct 05 16:52:09 2008 +1100
+++ b/include/linux/cpumask.h	Sun Oct 05 23:16:50 2008 +1100
@@ -112,6 +112,7 @@
  *
  * int cpumask_any(mask)		Any cpu in mask
  * int cpumask_any_both(mask1,mask2)	Any cpu in both masks
+ * int cpumask_any_but(mask,cpu)	Any cpu in mask except cpu
  *
  * for_each_possible_cpu(cpu)		for-loop cpu over cpu_possible_map
  * for_each_online_cpu(cpu)		for-loop cpu over cpu_online_map
@@ -440,6 +441,7 @@ extern cpumask_t cpu_mask_all;
 #define cpumask_next(n, src)	({ (void)(src); 1; })
 #define cpumask_first_both(src1, src2)	({ (void)(src1); (void)(src2); 0; })
 #define cpumask_next(n, src1, src2)	({ (void)(src1); (void)(src2); 1; })
+#define cpumask_any_but(mask, cpu)	({ (void)(mask); (void)(cpu); 0; })
 #define for_each_cpu(cpu, mask)	\
 	for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
 #define for_each_cpu_both(cpu, mask1, mask2) \
@@ -451,6 +453,7 @@ int cpumask_next(int n, const struct cpu
 int cpumask_next(int n, const struct cpumask *srcp);
 int cpumask_first_both(const struct cpumask *src1, const struct cpumask *src2);
 int cpumask_next_both(int n, const struct cpumask *, const struct cpumask *);
+int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
 
 #define for_each_cpu(cpu, mask)				\
 	for ((cpu) = cpumask_first(mask);		\
diff -r 8b67d221b01f lib/cpumask.c
--- a/lib/cpumask.c	Sun Oct 05 16:52:09 2008 +1100
+++ b/lib/cpumask.c	Sun Oct 05 23:16:50 2008 +1100
@@ -36,6 +36,16 @@ int cpumask_next_both(int n,
 }
 EXPORT_SYMBOL(cpumask_next_both);
 
+int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
+{
+	unsigned int i;
+
+	for_each_cpu(i, mask)
+		if (i != cpu)
+			break;
+	return i;
+}
+
 /* These are not inline because of header tangles. */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 bool alloc_cpumask_var(cpumask_var_t *mask, gfp_t flags)
