Unify the common code for current and legacy blocks. Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> --- tools/intel_vbt_decode.c | 70 +++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c index ebc65b82bbde..04f733c8cb06 100644 --- a/tools/intel_vbt_decode.c +++ b/tools/intel_vbt_decode.c @@ -483,25 +483,12 @@ static void dump_child_device(struct context *context, } } -static void dump_general_definitions(struct context *context, - const struct bdb_block *block) + +static void dump_child_devices(struct context *context, const uint8_t *devices, + uint8_t child_dev_num, uint8_t child_dev_size) { - const struct bdb_general_definitions *defs = block->data; struct child_device_config *child; int i; - int child_device_num; - - printf("\tCRT DDC GMBUS addr: 0x%02x\n", defs->crt_ddc_gmbus_pin); - printf("\tUse ACPI DPMS CRT power states: %s\n", - YESNO(defs->dpms_acpi)); - printf("\tSkip CRT detect at boot: %s\n", - YESNO(defs->skip_boot_crt_detect)); - printf("\tUse DPMS on AIM devices: %s\n", YESNO(defs->dpms_aim)); - printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1], - defs->boot_display[0]); - printf("\tChild device size: %d\n", defs->child_dev_size); - child_device_num = (block->size - sizeof(*defs)) / - defs->child_dev_size; /* * Use a temp buffer so dump_child_device() doesn't have to worry about @@ -510,9 +497,9 @@ static void dump_general_definitions(struct context *context, */ child = calloc(1, sizeof(*child)); - for (i = 0; i < child_device_num; i++) { - memcpy(child, &defs->devices[i * defs->child_dev_size], - min(sizeof(*child), defs->child_dev_size)); + for (i = 0; i < child_dev_num; i++) { + memcpy(child, devices + i * child_dev_size, + min(sizeof(*child), child_dev_size)); dump_child_device(context, child); } @@ -520,33 +507,38 @@ static void dump_general_definitions(struct context *context, free(child); } -static void dump_legacy_child_devices(struct context *context, - const struct bdb_block *block) +static void dump_general_definitions(struct context *context, + const struct bdb_block *block) { - const struct bdb_legacy_child_devices *defs = block->data; - struct child_device_config *child; - int i; - int child_device_num; + const struct bdb_general_definitions *defs = block->data; + int child_dev_num; + printf("\tCRT DDC GMBUS addr: 0x%02x\n", defs->crt_ddc_gmbus_pin); + printf("\tUse ACPI DPMS CRT power states: %s\n", + YESNO(defs->dpms_acpi)); + printf("\tSkip CRT detect at boot: %s\n", + YESNO(defs->skip_boot_crt_detect)); + printf("\tUse DPMS on AIM devices: %s\n", YESNO(defs->dpms_aim)); + printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1], + defs->boot_display[0]); printf("\tChild device size: %d\n", defs->child_dev_size); - child_device_num = (block->size - sizeof(*defs)) / - defs->child_dev_size; - /* - * Use a temp buffer so dump_child_device() doesn't have to worry about - * accessing the struct beyond child_dev_size. The tail, if any, remains - * initialized to zero. - */ - child = calloc(1, sizeof(*child)); + child_dev_num = (block->size - sizeof(*defs)) / defs->child_dev_size; + dump_child_devices(context, defs->devices, + child_dev_num, defs->child_dev_size); +} - for (i = 0; i < child_device_num; i++) { - memcpy(child, &defs->devices[i * defs->child_dev_size], - min(sizeof(*child), defs->child_dev_size)); +static void dump_legacy_child_devices(struct context *context, + const struct bdb_block *block) +{ + const struct bdb_legacy_child_devices *defs = block->data; + int child_dev_num; - dump_child_device(context, child); - } + printf("\tChild device size: %d\n", defs->child_dev_size); - free(child); + child_dev_num = (block->size - sizeof(*defs)) / defs->child_dev_size; + dump_child_devices(context, defs->devices, + child_dev_num, defs->child_dev_size); } static void dump_lvds_options(struct context *context, -- 2.11.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx