diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2025-02-13 20:24:00 +0200 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2025-02-17 14:27:35 +0100 |
commit | b2108fc82a0acda34388bff3e3ee3544013b1623 (patch) | |
tree | 77f17ac4c6fe23a47a3323739f043ba5a1a35967 | |
parent | 8efee9c43127662b7642e0146aba8d31606277e1 (diff) |
drm: Move for_each_if() to util_macros.h for wider use
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>
-rw-r--r-- | include/drm/drm_util.h | 16 | ||||
-rw-r--r-- | include/linux/util_macros.h | 15 |
2 files changed, 16 insertions, 15 deletions
diff --git a/include/drm/drm_util.h b/include/drm/drm_util.h index 79952d8c4bba..440199618620 100644 --- a/include/drm/drm_util.h +++ b/include/drm/drm_util.h @@ -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 @@ -48,21 +49,6 @@ #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 * * This function shall not be used in new code. diff --git a/include/linux/util_macros.h b/include/linux/util_macros.h index 825487fb66fa..3b570b765b75 100644 --- a/include/linux/util_macros.h +++ b/include/linux/util_macros.h @@ -5,6 +5,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. * @a: The array in which to look for the closest element. Must be sorted |