Merge tag 'cpumask-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / lib / cpumask.c
index 75379b759d3f64e55fbd9cb9768449b08801cbdf..830dd5dec40f1697b2bf2e40a294e05284ded89c 100644 (file)
 int cpumask_next_and(int n, const struct cpumask *src1p,
                     const struct cpumask *src2p)
 {
-       while ((n = cpumask_next(n, src1p)) < nr_cpu_ids)
-               if (cpumask_test_cpu(n, src2p))
-                       break;
-       return n;
+       struct cpumask tmp;
+
+       if (cpumask_and(&tmp, src1p, src2p))
+               return cpumask_next(n, &tmp);
+       return nr_cpu_ids;
 }
 EXPORT_SYMBOL(cpumask_next_and);