summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2009-06-10 11:37:01 +0800
committerZhenyu Wang <zhenyu.z.wang@intel.com>2009-06-15 14:56:56 +0800
commit6ba148bbd78783f59eed3d898638c39b950dcd89 (patch)
tree338fbf12e0a8cf8bf4e7d14f010142b0c2076286
parentcdbf84f20295c8a78624318aa6fdfff3f5c8ce27 (diff)
Dynamically get the number of child device in general definition block
The size of general definition block varies on different platform/machines. In such case the number of child device is also different. And it will be better to get the number of child device in general definition block dynamically. The number of child device can be calculated by the following formula: (block_size - block_header_size) / sizeof( struct child_device_config) http://bugs.freedesktop.org/show_bug.cgi?id=20429 Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
-rw-r--r--src/bios_reader/bios_reader.c4
-rw-r--r--src/i830_bios.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/bios_reader/bios_reader.c b/src/bios_reader/bios_reader.c
index 328cacf2..27ec7694 100644
--- a/src/bios_reader/bios_reader.c
+++ b/src/bios_reader/bios_reader.c
@@ -170,6 +170,7 @@ static void dump_general_definitions(void)
struct child_device_config *child;
int i;
char child_id[11];
+ int child_device_num;
block = find_section(BDB_GENERAL_DEFINITIONS);
@@ -188,7 +189,8 @@ static void dump_general_definitions(void)
printf("\tBoot display type: 0x%02x%02x\n", defs->boot_display[1],
defs->boot_display[0]);
printf("\tTV data block present: %s\n", YESNO(tv_present));
- for (i = 0; i < 4; i++) {
+ child_device_num = (block->size - sizeof(*defs)) / sizeof(*child);
+ for (i = 0; i < child_device_num; i++) {
child = &defs->devices[i];
if (!child->device_type) {
printf("\tChild device %d not present\n", i);
diff --git a/src/i830_bios.h b/src/i830_bios.h
index 1f1f1aa2..8a3025e7 100644
--- a/src/i830_bios.h
+++ b/src/i830_bios.h
@@ -228,7 +228,7 @@ struct bdb_general_definitions {
* TV and LVDS are missing, so be careful when interpreting
* [4] and [5].
*/
- struct child_device_config devices[6];
+ struct child_device_config devices[0];
/* may be another device block here on some platforms */
} __attribute__((packed));