[RFC i-g-t v3 4/5] igt_debugfs: Make igt_crc_to_string() work with other CRC types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Intel GPUs have CRC values with 5 n_words, but the Chamelium's definitely
doesn't. So make igt_crc_to_string() a little smarter so it can handle this.

Signed-off-by: Lyude <lyude@xxxxxxxxxx>
---
 lib/igt_debugfs.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 9142e3f..4809b73 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -290,11 +290,18 @@ void igt_assert_crc_equal(igt_crc_t *a, igt_crc_t *b)
 char *igt_crc_to_string(igt_crc_t *crc)
 {
 	char buf[128];
+	char *p;
+	int i, len;
+
+	for (i = 0, p = buf;
+	     i < crc->n_words;
+	     i++, p += len) {
+		snprintf(p, sizeof(buf) - (p - buf), "%08x %n",
+			 crc->crc[i], &len);
+	}
 
-	igt_assert_eq(crc->n_words, 5);
-
-	sprintf(buf, "%08x %08x %08x %08x %08x", crc->crc[0],
-		crc->crc[1], crc->crc[2], crc->crc[3], crc->crc[4]);
+	/* Strip the trailing space */
+	*strrchr(buf, ' ') = '\0';
 
 	return strdup(buf);
 }
-- 
2.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux