From 9fd6f61a297e944fa045a1cb6cd53916d0fea454 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Tue, 16 Jan 2024 15:07:28 +0200 Subject: drm/print: add drm_dbg_printer() for drm device specific printer We've lacked a device specific debug printer. Add one. Take category into account too. __builtin_return_address(0) is inaccurate here, so don't use it. If necessary, we can later pass __func__ to drm_dbg_printer() by wrapping it inside a macro. Signed-off-by: Jani Nikula Reviewed-by: Luca Coelho Acked-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/48607d58e5cdf8341ffdd522257542fa2ce41a19.1705410327.git.jani.nikula@intel.com --- drivers/gpu/drm/drm_print.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'drivers/gpu/drm/drm_print.c') diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 91dbcdeaad3f..673b29c732ea 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -189,6 +189,27 @@ void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) } EXPORT_SYMBOL(__drm_printfn_debug); +void __drm_printfn_dbg(struct drm_printer *p, struct va_format *vaf) +{ + const struct drm_device *drm = p->arg; + const struct device *dev = drm ? drm->dev : NULL; + enum drm_debug_category category = p->category; + const char *prefix = p->prefix ?: ""; + const char *prefix_pad = p->prefix ? " " : ""; + + if (!__drm_debug_enabled(category)) + return; + + /* Note: __builtin_return_address(0) is useless here. */ + if (dev) + dev_printk(KERN_DEBUG, dev, "[" DRM_NAME "]%s%s %pV", + prefix_pad, prefix, vaf); + else + printk(KERN_DEBUG "[" DRM_NAME "]%s%s %pV", + prefix_pad, prefix, vaf); +} +EXPORT_SYMBOL(__drm_printfn_dbg); + void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) { struct drm_device *drm = p->arg; -- cgit v1.2.3