[igt PATCH 2/6] intel_bios_reader: abstract a more generic hex dumper

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

 



Let us reuse the dumper for headers.

Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 tools/intel_bios_reader.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index c7572bde8c7e..83fc819b6cdc 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1588,17 +1588,17 @@ struct dumper dumpers[] = {
 	},
 };
 
-static void hex_dump(const struct bdb_block *block)
+static void hex_dump(const void *data, uint32_t size)
 {
 	int i;
-	const uint8_t *p = block->data;
+	const uint8_t *p = data;
 
-	for (i = 0; i < block->size; i++) {
+	for (i = 0; i < size; i++) {
 		if (i % 16 == 0)
 			printf("\t%04x: ", i);
 		printf("%02x", p[i]);
 		if (i % 16 == 15) {
-			if (i + 1 < block->size)
+			if (i + 1 < size)
 				printf("\n");
 		} else if (i % 8 == 7) {
 			printf("  ");
@@ -1609,6 +1609,11 @@ static void hex_dump(const struct bdb_block *block)
 	printf("\n\n");
 }
 
+static void hex_dump_block(const struct bdb_block *block)
+{
+	hex_dump(block->data, block->size);
+}
+
 static bool dump_section(struct context *context, int section_id)
 {
 	struct dumper *dumper = NULL;
@@ -1632,7 +1637,7 @@ static bool dump_section(struct context *context, int section_id)
 		printf("BDB block %d:\n", block->id);
 
 	if (context->hexdump)
-		hex_dump(block);
+		hex_dump_block(block);
 	if (dumper && dumper->dump)
 		dumper->dump(context, block);
 	printf("\n");
-- 
2.1.4

_______________________________________________
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