[PATCH v1 3/8] drm/print: add new logging helper for drm logging

Sam Ravnborg sam at ravnborg.org
Sat Dec 21 09:55:48 UTC 2019


Add new helper so logging can use the standard logging
functions without an extra helper function.

Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
Cc: Jani Nikula <jani.nikula at intel.com>
Cc: Sean Paul <sean at poorly.run>
Cc: Daniel Vetter <daniel at ffwll.ch>
---
 include/drm/drm_print.h | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index d2b9ac6a6e18..c1d333bb7534 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -403,10 +403,15 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
  * Prefer drm_device based logging over device or printk based logging.
  */
 
-/* Helper for struct drm_device based logging. */
+/* Helpers for struct drm_device based logging. */
 #define __drm_printk(drm, level, type, fmt, ...)			\
 	dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
 
+#define __drm_cat_printk(drm, cat, fmt, ...)				\
+({									\
+	if (drm_debug_enabled(cat))					\
+		dev_dbg((drm)->dev, "[drm] " fmt, ##__VA_ARGS__);	\
+})
 
 #define drm_info(drm, fmt, ...)						\
 	__drm_printk((drm), info,, fmt, ##__VA_ARGS__)
@@ -430,24 +435,23 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
 	__drm_printk((drm), err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__)
 
 #define drm_dbg_core(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_CORE, fmt, ##__VA_ARGS__)
 #define drm_dbg(drm, fmt, ...)						\
-	drm_dev_dbg((drm)->dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
 #define drm_dbg_kms(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_KMS, fmt, ##__VA_ARGS__)
 #define drm_dbg_prime(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_PRIME, fmt, ##__VA_ARGS__)
 #define drm_dbg_atomic(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
 #define drm_dbg_vbl(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_VBL, fmt, ##__VA_ARGS__)
 #define drm_dbg_state(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_STATE, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_STATE, fmt, ##__VA_ARGS__)
 #define drm_dbg_lease(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_LEASE, fmt, ##__VA_ARGS__)
+	__drm_cat_printk((drm), DRM_UT_LEASE, fmt, ##__VA_ARGS__)
 #define drm_dbg_dp(drm, fmt, ...)					\
-	drm_dev_dbg((drm)->dev, DRM_UT_DP, fmt, ##__VA_ARGS__)
-
+	__drm_cat_printk((drm), DRM_UT_DP, fmt, ##__VA_ARGS__)
 
 /*
  * LEGACY logging support - do not use in new code
-- 
2.20.1



More information about the dri-devel mailing list