[U-Boot] [PATCH 5/5] video/bus_vcxk: use bmp_layout API

Nikita Kiryanov nikita at compulab.co.il
Mon Feb 4 12:39:39 CET 2013


If the BMP headers are located in unaligned addresses, accessing them
directly may lead to a data abort on some architectures. Use the safer
bmp_layout API instead.

Signed-off-by: Nikita Kiryanov <nikita at compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg at compulab.co.il>
Cc: Anatolij Gustschin <agust at denx.de>
Cc: Wolfgang Denk <wd at denx.de>
Cc: Albert ARIBAUD <albert.u.boot at aribaud.net>
Cc: Jeroen Hofstee <jeroen at myspectrum.nl>
---
 drivers/video/bus_vcxk.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/video/bus_vcxk.c b/drivers/video/bus_vcxk.c
index a0607cf..d382ac1 100644
--- a/drivers/video/bus_vcxk.c
+++ b/drivers/video/bus_vcxk.c
@@ -401,14 +401,12 @@ int vcxk_display_bitmap(ulong addr, int x, int y)
 	unsigned char *dataptr;
 
 	bmp = (bmp_image_t *) addr;
-	if ((bmp->header.signature[0] == 'B') &&
-	    (bmp->header.signature[1] == 'M')) {
-		width        = le32_to_cpu(bmp->header.width);
-		height       = le32_to_cpu(bmp->header.height);
-		bpp          = le16_to_cpu(bmp->header.bit_count);
-
-		dataptr = (unsigned char *) bmp +
-				le32_to_cpu(bmp->header.data_offset);
+	if (bmp_signature_valid(bmp)) {
+		width = bmp_get_width(bmp);
+		height = bmp_get_height(bmp);
+		bpp = bmp_get_bit_count(bmp);
+
+		dataptr = (unsigned char *) bmp + bmp_get_data_offset(bmp);
 
 		if (display_width < (width + x))
 			c_width = display_width - x;
-- 
1.7.10.4



More information about the U-Boot mailing list