X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcpumask.c;h=70184596853ec20f16128c9c071d547b96beeac9;hb=040c686caa16b1b7018c0d132f48d76474b0b930;hp=af3e5817de98fe2614194b1899436a70034c4a97;hpb=a2d773023552f68baa2db2226dfd6d761c0df5da;p=pandora-kernel.git diff --git a/lib/cpumask.c b/lib/cpumask.c index af3e5817de98..70184596853e 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -75,6 +75,38 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) return i; } +/** + * cpumask_next_wrap - helper to implement for_each_cpu_wrap + * @n: the cpu prior to the place to search + * @mask: the cpumask pointer + * @start: the start point of the iteration + * @wrap: assume @n crossing @start terminates the iteration + * + * Returns >= nr_cpu_ids on completion + * + * Note: the @wrap argument is required for the start condition when + * we cannot assume @start is set in @mask. + */ +int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) +{ + int next; + +again: + next = cpumask_next(n, mask); + + if (wrap && n < start && next >= start) { + return nr_cpumask_bits; + + } else if (next >= nr_cpumask_bits) { + wrap = true; + n = -1; + goto again; + } + + return next; +} +EXPORT_SYMBOL(cpumask_next_wrap); + /* These are not inline because of header tangles. */ #ifdef CONFIG_CPUMASK_OFFSTACK /**