drm/print: Add drm_coredump_printer_is_full
authorMatthew Brost <matthew.brost@intel.com>
Wed, 23 Apr 2025 17:17:24 +0000 (10:17 -0700)
committerMatthew Brost <matthew.brost@intel.com>
Thu, 24 Apr 2025 22:51:41 +0000 (15:51 -0700)
Add drm_coredump_printer_is_full which indicates if a drm printer's
output is full. Useful to short circuit coredump printing once printer's
output is full.

v2:
 - s/drm_printer_is_full/drm_coredump_printer_is_full (Jani)
v3:
 - Bail if not a coredump printer (Michal)

Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://lore.kernel.org/r/20250423171725.597955-4-matthew.brost@intel.com
include/drm/drm_print.h

index f31eba1c7cab2ff8bfc27a3aec4285b8a8bfbe7e..ab017b05e1751b97e39bdc6a145462fbbf743e57 100644 (file)
@@ -344,6 +344,26 @@ drm_coredump_printer(struct drm_print_iterator *iter)
        return p;
 }
 
+/**
+ * drm_coredump_printer_is_full() - DRM coredump printer output is full
+ * @p: DRM coredump printer
+ *
+ * DRM printer output is full, useful to short circuit coredump printing once
+ * printer is full.
+ *
+ * RETURNS:
+ * True if DRM coredump printer output buffer is full, False otherwise
+ */
+static inline bool drm_coredump_printer_is_full(struct drm_printer *p)
+{
+       struct drm_print_iterator *iterator = p->arg;
+
+       if (p->printfn != __drm_printfn_coredump)
+               return true;
+
+       return !iterator->remain;
+}
+
 /**
  * drm_seq_file_printer - construct a &drm_printer that outputs to &seq_file
  * @f:  the &struct seq_file to output to