summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2008-10-27 11:03:07 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2008-10-27 11:03:07 +1100
commit05b0494d23d7435b43a6b2d3a4e62773c6e74de5 (patch)
tree1d5750048be875161a26de3b0ff83a5d3d882f54 /lib
parentd05d14b969853ada2f53c23afcc4ae6fa5dd8acb (diff)
cpumask: add for_each_cpu_mask_and function
Add for_each_cpu_mask_and() function to eliminate need for a common use of a temporary cpumask_t variable. When the following procedure is being used: funcproto(const cpumask_t *mask, ...) { cpumask_t temp; cpus_and(temp, mask, cpu_online_map); for_each_cpu_mask(cpu, temp) ... It then becomes: funcproto(cpumask_t *mask, ...) { for_each_cpu_mask_and(cpu, *mask, cpu_online_map) ... ... eliminating the need for the temp cpumask. Applies to linux-2.6.tip/master. Signed-off-by: Mike Travis <travis@sgi.com> Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib')
-rw-r--r--lib/cpumask.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 5f97dc25ef9c..8e6f1af99fa0 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -15,6 +15,15 @@ int __next_cpu(int n, const cpumask_t *srcp)
}
EXPORT_SYMBOL(__next_cpu);
+int cpumask_next_and(int n, const cpumask_t *srcp, const cpumask_t *andp)
+{
+ while ((n = next_cpu_nr(n, *srcp)) < nr_cpu_ids)
+ if (cpu_isset(n, *andp))
+ break;
+ return n;
+}
+EXPORT_SYMBOL(cpumask_next_and);
+
#if NR_CPUS > 64
int __next_cpu_nr(int n, const cpumask_t *srcp)
{