Bluetooth: Verify that l2cap_get_conf_opt provides large enough buffer
[pandora-kernel.git] / lib / cpumask.c
index af3e581..7018459 100644 (file)
@@ -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
 /**