]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm: Move for_each_if() to util_macros.h for wider use
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 13 Feb 2025 18:24:00 +0000 (20:24 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 17 Feb 2025 13:27:35 +0000 (14:27 +0100)
Other subsystem(s) may want to reuse the for_each_if() macro.
Move it to util_macros.h to make it globally available.

Suggested-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250213182527.3092371-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
include/drm/drm_util.h
include/linux/util_macros.h

index 79952d8c4bbadfa850f364f46e128739723748bb..4401996186208c243eea9fbcf5083f605a4746b1 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/kgdb.h>
 #include <linux/preempt.h>
 #include <linux/smp.h>
+#include <linux/util_macros.h>
 
 /*
  * Use EXPORT_SYMBOL_FOR_TESTS_ONLY() for functions that shall
 #define EXPORT_SYMBOL_FOR_TESTS_ONLY(x)
 #endif
 
-/**
- * for_each_if - helper for handling conditionals in various for_each macros
- * @condition: The condition to check
- *
- * Typical use::
- *
- *     #define for_each_foo_bar(x, y) \'
- *             list_for_each_entry(x, y->list, head) \'
- *                     for_each_if(x->something == SOMETHING)
- *
- * The for_each_if() macro makes the use of for_each_foo_bar() less error
- * prone.
- */
-#define for_each_if(condition) if (!(condition)) {} else
-
 /**
  * drm_can_sleep - returns true if currently okay to sleep
  *
index 825487fb66faf9525bb90f07f28d2dcc318b0700..3b570b765b7504805ef55084cea1df79d7368d3a 100644 (file)
@@ -4,6 +4,21 @@
 
 #include <linux/math.h>
 
+/**
+ * for_each_if - helper for handling conditionals in various for_each macros
+ * @condition: The condition to check
+ *
+ * Typical use::
+ *
+ *     #define for_each_foo_bar(x, y) \'
+ *             list_for_each_entry(x, y->list, head) \'
+ *                     for_each_if(x->something == SOMETHING)
+ *
+ * The for_each_if() macro makes the use of for_each_foo_bar() less error
+ * prone.
+ */
+#define for_each_if(condition) if (!(condition)) {} else
+
 /**
  * find_closest - locate the closest element in a sorted array
  * @x: The reference value.