]> git.sur5r.net Git - u-boot/commitdiff
board/flagadm/flash.c: fix compile warning
authorWolfgang Denk <wd@denx.de>
Mon, 14 Sep 2009 22:09:21 +0000 (00:09 +0200)
committerTom Rix <Tom.Rix@windriver.com>
Sat, 3 Oct 2009 14:04:30 +0000 (09:04 -0500)
Fix warning: flash.c:531: warning: dereferencing type-punned pointer
will break strict-aliasing rules

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Kári Davíðsson <kd@flaga.is>
board/flagadm/flash.c

index bbefbacea95fed867b3e0f01b79ac75ad649d73a..a69b1a4e975c38b96c2139632d8c9377c6fc7299 100644 (file)
@@ -528,11 +528,17 @@ int write_word (flash_info_t *info, ulong dest, ulong da)
        ulong start;
        char csr;
        int flag;
-       ushort * d = (ushort*)&da;
        int i;
+       union {
+               u32 data32;
+               u16 data16[2];
+       } data;
+
+       data.data32 = da;
 
        /* Check if Flash is (sufficiently) erased */
-       if (((*addr & d[0]) != d[0]) || ((*(addr+1) & d[1]) != d[1])) {
+       if (((*addr & data.data16[0]) != data.data16[0]) ||
+           ((*(addr+1) & data.data16[1]) != data.data16[1])) {
                return (2);
        }
        /* Disable interrupts which might cause a timeout here */
@@ -544,7 +550,7 @@ int write_word (flash_info_t *info, ulong dest, ulong da)
                *addr = 0x0010;
 
                /* Write Data */
-               *addr = d[i];
+               *addr = data.data16[i];
 
                /* re-enable interrupts if necessary */
                if (flag)