[PATCH v1 8/8] drm/print: let legacy logging use new style functions

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


Update the legacy logging functions to use the new style logging
functions.
This will help people when transition to the new style as they can just
go and see what new style logging function to use.

This also makes logging look a bit more consistent as the same base is
now used for logging.

While converting, drop the unused ratelimited variants.

Delete the now unused logging support functions in drm_print.c

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>
Cc: Joe Perches <joe at perches.com>
---
 drivers/gpu/drm/drm_print.c |  80 ----------------
 include/drm/drm_print.h     | 184 ++++++------------------------------
 2 files changed, 31 insertions(+), 233 deletions(-)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index fd70205f8c5c..e5a3d2576d6f 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -235,86 +235,6 @@ void drm_print_bits(struct drm_printer *p, unsigned long value,
 }
 EXPORT_SYMBOL(drm_print_bits);
 
-void drm_dev_printk(const struct device *dev, const char *level,
-		    const char *format, ...)
-{
-	struct va_format vaf;
-	va_list args;
-
-	va_start(args, format);
-	vaf.fmt = format;
-	vaf.va = &args;
-
-	if (dev)
-		dev_printk(level, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk("%s" "[" DRM_NAME ":%ps] %pV",
-		       level, __builtin_return_address(0), &vaf);
-
-	va_end(args);
-}
-EXPORT_SYMBOL(drm_dev_printk);
-
-void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
-		   const char *format, ...)
-{
-	struct va_format vaf;
-	va_list args;
-
-	if (!drm_debug_enabled(category))
-		return;
-
-	va_start(args, format);
-	vaf.fmt = format;
-	vaf.va = &args;
-
-	if (dev)
-		dev_printk(KERN_DEBUG, dev, "[" DRM_NAME ":%ps] %pV",
-			   __builtin_return_address(0), &vaf);
-	else
-		printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
-		       __builtin_return_address(0), &vaf);
-
-	va_end(args);
-}
-EXPORT_SYMBOL(__drm_dev_dbg);
-
-void __drm_dbg(enum drm_debug_category category, const char *format, ...)
-{
-	struct va_format vaf;
-	va_list args;
-
-	if (!drm_debug_enabled(category))
-		return;
-
-	va_start(args, format);
-	vaf.fmt = format;
-	vaf.va = &args;
-
-	printk(KERN_DEBUG "[" DRM_NAME ":%ps] %pV",
-	       __builtin_return_address(0), &vaf);
-
-	va_end(args);
-}
-EXPORT_SYMBOL(__drm_dbg);
-
-void __drm_err(const char *format, ...)
-{
-	struct va_format vaf;
-	va_list args;
-
-	va_start(args, format);
-	vaf.fmt = format;
-	vaf.va = &args;
-
-	printk(KERN_ERR "[" DRM_NAME ":%ps] *ERROR* %pV",
-	       __builtin_return_address(0), &vaf);
-
-	va_end(args);
-}
-EXPORT_SYMBOL(__drm_err);
-
 /**
  * drm_print_regset32 - print the contents of registers to a
  * &drm_printer stream.
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index 0b0468340573..f305454544ee 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -655,176 +655,54 @@ static inline bool drm_debug_enabled(enum drm_debug_category category)
  * LEGACY logging support - do not use in new code
  */
 
-/*
- * struct device based logging
- *
- * Prefer drm_device based logging over device or prink based logging.
- */
-
-__printf(3, 4)
-void drm_dev_printk(const struct device *dev, const char *level,
-		    const char *format, ...);
-__printf(3, 4)
-void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
-		   const char *format, ...);
+#define DRM_DEV_ERROR(dev, fmt, ...)		\
+	drm_dev_err((dev), fmt, ##__VA_ARGS__)
+#define DRM_DEV_INFO(dev, fmt, ...)		\
+	drm_dev_info((dev), fmt, ##__VA_ARGS__)
+#define DRM_DEV_INFO_ONCE(dev, fmt, ...)	\
+	drm_dev_info_once((dev), fmt, ##__VA_ARGS__)
 
-/**
- * Error output.
- *
- * @dev: device pointer
- * @fmt: printf() like format string.
- */
-#define DRM_DEV_ERROR(dev, fmt, ...)					\
-	drm_dev_printk(dev, KERN_ERR, "*ERROR* " fmt, ##__VA_ARGS__)
-
-/**
- * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
- *
- * @dev: device pointer
- * @fmt: printf() like format string.
- */
-#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)			\
-({									\
-	static DEFINE_RATELIMIT_STATE(_rs,				\
-				      DEFAULT_RATELIMIT_INTERVAL,	\
-				      DEFAULT_RATELIMIT_BURST);		\
-									\
-	if (__ratelimit(&_rs))						\
-		DRM_DEV_ERROR(dev, fmt, ##__VA_ARGS__);			\
-})
-
-#define DRM_DEV_INFO(dev, fmt, ...)				\
-	drm_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__)
-
-#define DRM_DEV_INFO_ONCE(dev, fmt, ...)				\
-({									\
-	static bool __print_once __read_mostly;				\
-	if (!__print_once) {						\
-		__print_once = true;					\
-		DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__);			\
-	}								\
-})
-
-/**
- * Debug output.
- *
- * @dev: device pointer
- * @fmt: printf() like format string.
- */
 #define DRM_DEV_DEBUG(dev, fmt, ...)					\
-	__drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+	drm_dev_dbg_core((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...)				\
-	__drm_dev_dbg(dev, DRM_UT_DRIVER,	fmt, ##__VA_ARGS__)
+	drm_dev_dbg((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_KMS(dev, fmt, ...)				\
-	__drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__VA_ARGS__)
+	drm_dev_dbg_kms((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_PRIME(dev, fmt, ...)				\
-	__drm_dev_dbg(dev, DRM_UT_PRIME, fmt, ##__VA_ARGS__)
+	drm_dev_dbg_prime((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_ATOMIC(dev, fmt, ...)				\
-	__drm_dev_dbg(dev, DRM_UT_ATOMIC,	fmt, ##__VA_ARGS__)
+	drm_dev_dbg_atomic((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_VBL(dev, fmt, ...)				\
-	__drm_dev_dbg(dev, DRM_UT_VBL, fmt, ##__VA_ARGS__)
+	drm_dev_dbg_vbl((dev), fmt, ##__VA_ARGS__)
 #define	DRM_DEV_DEBUG_DP(dev, fmt, ...)					\
-	__drm_dev_dbg(dev, DRM_UT_DP, fmt, ## __VA_ARGS__)
-
-#define _DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, category, fmt, ...)	\
-({									\
-	static DEFINE_RATELIMIT_STATE(_rs,				\
-				      DEFAULT_RATELIMIT_INTERVAL,	\
-				      DEFAULT_RATELIMIT_BURST);		\
-	if (__ratelimit(&_rs))						\
-		__drm_dev_dbg(dev, category, fmt, ##__VA_ARGS__);		\
-})
+	drm_dev_dbg_dp((dev), fmt, ## __VA_ARGS__)
 
-/**
- * Rate limited debug output. Like DRM_DEBUG() but won't flood the log.
- *
- * @dev: device pointer
- * @fmt: printf() like format string.
- */
-#define DRM_DEV_DEBUG_RATELIMITED(dev, fmt, ...)			\
-	_DEV_DRM_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_CORE,		\
-					  fmt, ##__VA_ARGS__)
-#define DRM_DEV_DEBUG_DRIVER_RATELIMITED(dev, fmt, ...)			\
-	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_DRIVER,		\
-					  fmt, ##__VA_ARGS__)
+#define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)			\
+	drm_dev_err_ratelimited((dev), fmt, ##__VA_ARGS__)
 #define DRM_DEV_DEBUG_KMS_RATELIMITED(dev, fmt, ...)			\
-	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_KMS,		\
-					  fmt, ##__VA_ARGS__)
-#define DRM_DEV_DEBUG_PRIME_RATELIMITED(dev, fmt, ...)			\
-	_DRM_DEV_DEFINE_DEBUG_RATELIMITED(dev, DRM_UT_PRIME,		\
-					  fmt, ##__VA_ARGS__)
-
-/*
- * printk based logging
- *
- * Prefer drm_device based logging over device or prink based logging.
- */
-
-__printf(2, 3)
-void __drm_dbg(enum drm_debug_category category, const char *format, ...);
-__printf(1, 2)
-void __drm_err(const char *format, ...);
-
-/* Macros to make printk easier */
-
-#define _DRM_PRINTK(once, level, fmt, ...)				\
-	printk##once(KERN_##level "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
-
-#define DRM_INFO(fmt, ...)						\
-	_DRM_PRINTK(, INFO, fmt, ##__VA_ARGS__)
-#define DRM_NOTE(fmt, ...)						\
-	_DRM_PRINTK(, NOTICE, fmt, ##__VA_ARGS__)
-#define DRM_WARN(fmt, ...)						\
-	_DRM_PRINTK(, WARNING, fmt, ##__VA_ARGS__)
+	drm_dev_dbg_kms_ratelimited((dev), fmt, ##__VA_ARGS__)
 
-#define DRM_INFO_ONCE(fmt, ...)						\
-	_DRM_PRINTK(_once, INFO, fmt, ##__VA_ARGS__)
-#define DRM_NOTE_ONCE(fmt, ...)						\
-	_DRM_PRINTK(_once, NOTICE, fmt, ##__VA_ARGS__)
-#define DRM_WARN_ONCE(fmt, ...)						\
-	_DRM_PRINTK(_once, WARNING, fmt, ##__VA_ARGS__)
+#define DRM_INFO(fmt, ...) drm_pr_info(fmt, ##__VA_ARGS__)
+#define DRM_NOTE(fmt, ...) drm_pr_notice(fmt, ##__VA_ARGS__)
+#define DRM_WARN(fmt, ...) drm_pr_warn(fmt, ##__VA_ARGS__)
 
-#define DRM_ERROR(fmt, ...)						\
-	__drm_err(fmt, ##__VA_ARGS__)
+#define DRM_INFO_ONCE(fmt, ...) drm_pr_info_once(fmt, ##__VA_ARGS__)
+#define DRM_NOTE_ONCE(fmt, ...) drm_pr_notice_once(fmt, ##__VA_ARGS__)
+#define DRM_WARN_ONCE(fmt, ...) drm_pr_warn_once(fmt, ##__VA_ARGS__)
+#define DRM_ERROR(fmt, ...)     drm_pr_err(fmt, ##__VA_ARGS__)
 
 #define DRM_ERROR_RATELIMITED(fmt, ...)					\
 	DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG(fmt, ...)						\
-	__drm_dbg(DRM_UT_CORE, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_DRIVER(fmt, ...)					\
-	__drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_KMS(fmt, ...)						\
-	__drm_dbg(DRM_UT_KMS, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_PRIME(fmt, ...)					\
-	__drm_dbg(DRM_UT_PRIME, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_ATOMIC(fmt, ...)					\
-	__drm_dbg(DRM_UT_ATOMIC, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_VBL(fmt, ...)						\
-	__drm_dbg(DRM_UT_VBL, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_LEASE(fmt, ...)					\
-	__drm_dbg(DRM_UT_LEASE, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_DP(fmt, ...)						\
-	__drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__)
-
-
-#define DRM_DEBUG_RATELIMITED(fmt, ...)					\
-	DRM_DEV_DEBUG_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
-
-#define DRM_DEBUG_DRIVER_RATELIMITED(fmt, ...)				\
-	DRM_DEV_DEBUG_DRIVER_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
-
 #define DRM_DEBUG_KMS_RATELIMITED(fmt, ...)				\
 	DRM_DEV_DEBUG_KMS_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
 
-#define DRM_DEBUG_PRIME_RATELIMITED(fmt, ...)				\
-	DRM_DEV_DEBUG_PRIME_RATELIMITED(NULL, fmt, ##__VA_ARGS__)
+#define DRM_DEBUG(fmt, ...)        drm_pr_dbg_core(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_DRIVER(fmt, ...) drm_pr_dbg(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_KMS(fmt, ...)    drm_pr_dbg_kms(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_PRIME(fmt, ...)  drm_pr_dbg_prime(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_ATOMIC(fmt, ...) drm_pr_dbg_atomic(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_VBL(fmt, ...)    drm_pr_dbg_vbl(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_LEASE(fmt, ...)  drm_pr_dbg_lease(fmt, ##__VA_ARGS__)
+#define DRM_DEBUG_DP(fmt, ...)     drm_pr_dbg_dp(fmt, ##__VA_ARGS__)
 
 #endif /* DRM_PRINT_H_ */
-- 
2.20.1



More information about the dri-devel mailing list