From mboxrd@z Thu Jan 1 00:00:00 1970 From: Piotr Wilczek Date: Fri, 17 May 2013 14:55:52 +0200 Subject: [U-Boot] [PATCH v3 09/12] drivers:lcd: fix unaligned access on lcd In-Reply-To: <1368795355-6717-1-git-send-email-p.wilczek@samsung.com> References: <1368795355-6717-1-git-send-email-p.wilczek@samsung.com> Message-ID: <1368795355-6717-10-git-send-email-p.wilczek@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de This patch replace 'le32_to_cpu' function with 'get_unaligend_le32' to avoid unaligned access exception on some ARM platforms (ex Trats2). Signed-off-by: Piotr Wilczek Signed-off-by: Kyungmin Park CC: Anatolij Gustschin --- Changes in v3: None Changes in v2: - new patch common/lcd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/lcd.c b/common/lcd.c index edae835..577a452 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -42,6 +42,7 @@ #endif #include #include +#include #if defined(CONFIG_CPU_PXA25X) || defined(CONFIG_CPU_PXA27X) || \ defined(CONFIG_CPU_MONAHANS) @@ -907,9 +908,9 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) return 1; } - width = le32_to_cpu(bmp->header.width); - height = le32_to_cpu(bmp->header.height); - bmp_bpix = le16_to_cpu(bmp->header.bit_count); + width = get_unaligned_le32(&bmp->header.width); + height = get_unaligned_le32(&bmp->header.height); + bmp_bpix = get_unaligned_le32(&bmp->header.bit_count); colors = 1 << bmp_bpix; bpix = NBITS(panel_info.vl_bpix); @@ -994,7 +995,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) if ((y + height) > panel_info.vl_row) height = panel_info.vl_row - y; - bmap = (uchar *) bmp + le32_to_cpu(bmp->header.data_offset); + bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset); fb = (uchar *) (lcd_base + (y + height - 1) * lcd_line_length + x * bpix / 8); @@ -1002,7 +1003,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) case 1: /* pass through */ case 8: #ifdef CONFIG_LCD_BMP_RLE8 - if (le32_to_cpu(bmp->header.compression) == BMP_BI_RLE8) { + if (get_unaligned_le32(&bmp->header.compression) == + BMP_BI_RLE8) { if (bpix != 16) { /* TODO implement render code for bpix != 16 */ printf("Error: only support 16 bpix"); -- 1.7.9.5