[PATCH v6 3/3] drm/fourcc: Switch to %p4cc format modifier

Sakari Ailus sakari.ailus at linux.intel.com
Mon Feb 8 20:09:03 UTC 2021


Instead of constructing the FourCC code manually, use the %p4cc printk
modifier to print it. Also leave a message to avoid using this function.

The next step would be to convert the users to use %p4cc directly instead
and removing the function.

Signed-off-by: Sakari Ailus <sakari.ailus at linux.intel.com>
---
 drivers/gpu/drm/drm_fourcc.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 03262472059c..4ff40f2f27c0 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -30,11 +30,6 @@
 #include <drm/drm_device.h>
 #include <drm/drm_fourcc.h>
 
-static char printable_char(int c)
-{
-	return isascii(c) && isprint(c) ? c : '?';
-}
-
 /**
  * drm_mode_legacy_fb_format - compute drm fourcc code from legacy description
  * @bpp: bits per pixels
@@ -134,17 +129,12 @@ EXPORT_SYMBOL(drm_driver_legacy_fb_format);
  * drm_get_format_name - fill a string with a drm fourcc format's name
  * @format: format to compute name of
  * @buf: caller-supplied buffer
+ *
+ * Please use %p4cc printk format modifier instead of this function.
  */
 const char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf)
 {
-	snprintf(buf->str, sizeof(buf->str),
-		 "%c%c%c%c %s-endian (0x%08x)",
-		 printable_char(format & 0xff),
-		 printable_char((format >> 8) & 0xff),
-		 printable_char((format >> 16) & 0xff),
-		 printable_char((format >> 24) & 0x7f),
-		 format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
-		 format);
+	snprintf(buf->str, sizeof(buf->str), "%p4cc", &format);
 
 	return buf->str;
 }
-- 
2.29.2



More information about the dri-devel mailing list