]> git.dujemihanovic.xyz Git - linux.git/commitdiff
drm/printer: add debug printer
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 28 Dec 2016 16:42:09 +0000 (17:42 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 30 Dec 2016 10:43:40 +0000 (11:43 +0100)
Useful for dumping lots of data into dmesg, e.g. drm_mm.

v2: Fixup export_symbol line, I misplaced a hunk (Chris).

Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1482943330-11592-1-git-send-email-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_print.c
include/drm/drm_print.h

index ad3caaa1f48b6a39f8c1c7e8203b16aa97d81f16..02a107d507067f70e4798a8df603780d26b11943 100644 (file)
@@ -40,6 +40,12 @@ void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
 }
 EXPORT_SYMBOL(__drm_printfn_info);
 
+void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
+{
+       pr_debug("%s %pV", p->prefix, vaf);
+}
+EXPORT_SYMBOL(__drm_printfn_debug);
+
 /**
  * drm_printf - print to a &drm_printer stream
  * @p: the &drm_printer
index 1adf84aea622b9dd2281afd46e953c24bcc968f1..e9d0ba20089c23d162ea0206935f82ebdb07f75f 100644 (file)
 
 /**
  * struct drm_printer - drm output "stream"
- * @printfn: actual output fxn
- * @arg: output fxn specific data
  *
  * Do not use struct members directly.  Use drm_printer_seq_file(),
  * drm_printer_info(), etc to initialize.  And drm_printf() for output.
  */
 struct drm_printer {
+       /* private: */
        void (*printfn)(struct drm_printer *p, struct va_format *vaf);
        void *arg;
+       const char *prefix;
 };
 
 void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
 void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
+void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
 
 void drm_printf(struct drm_printer *p, const char *f, ...);
 
@@ -109,4 +110,19 @@ static inline struct drm_printer drm_info_printer(struct device *dev)
        return p;
 }
 
+/**
+ * drm_debug_printer - construct a &drm_printer that outputs to pr_debug()
+ * @prefix: debug output prefix
+ *
+ * RETURNS:
+ * The &drm_printer object
+ */
+static inline struct drm_printer drm_debug_printer(const char *prefix)
+{
+       struct drm_printer p = {
+               .printfn = __drm_printfn_debug,
+               .prefix = prefix
+       };
+       return p;
+}
 #endif /* DRM_PRINT_H_ */