From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QW5kcmVhcyBCaWXDn21hbm4=?= Date: Thu, 09 Jun 2011 13:26:31 +0200 Subject: [U-Boot] [PATCH] at91_emac: fix compile warning In-Reply-To: <4DF0A9B2.5050806@emk-elektronik.de> References: <1307614974-15516-1-git-send-email-andreas.devel@gmail.com> <4DF0A9B2.5050806@emk-elektronik.de> Message-ID: <4DF0ADE7.2080906@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Reinahrd Meyer, Am 09.06.2011 13:08, schrieb Reinhard Meyer: > Dear Andreas Bie?mann, >> This patch removes the warning >> >> ---8<--- >> at91_emac.c: In function 'at91emac_write_hwaddr': >> at91_emac.c:487:2: warning: dereferencing type-punned pointer will break strict-aliasing rules >> --->8--- >> >> Signed-off-by: Andreas Bie?mann >> --- >> BEWARE! This patch is only compile tested! >> >> It is possible, that there is an endianess problem. It would be great, if one >> could test it on real hardware! > > If you have the time, can you make the same patch for macb? I can test it later on our > hardware. will do .. >> >> Reinhard, you could adopt the macb driver also to get the warning there fixed. >> If it works on at91sam this way it would also work on at91rm9200 cause they have the >> same endianess. > > See above ;) great ... >> writel(1 << ATMEL_ID_EMAC, &pmc->pcer); >> - DEBUG_AT91EMAC("init MAC-ADDR %x%x \n", >> - cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), >> - cpu_to_le32(*((u32 *)netdev->enetaddr))); >> - writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l); >> - writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h); >> + DEBUG_AT91EMAC("init MAC-ADDR %02x:%02x:%02x:%02x:%02x:%02x\n", >> + netdev->enetaddr[5], netdev->enetaddr[4], netdev->enetaddr[3], >> + netdev->enetaddr[2], netdev->enetaddr[1], netdev->enetaddr[0]); >> + writel( (netdev->enetaddr[0] | netdev->enetaddr[1] << 8 | >> + netdev->enetaddr[2] << 16 | netdev->enetaddr[3] << 24), >> + &emac->sa2l); > > OUCH, I would think by precedence rules, | comes before << !?!?! You are wrong, try the following: ---8<--- # cat main.c #include int main(void) { unsigned int test1 = (1 << 8 | 1); unsigned int test2 = ((1 << 8) | 1); printf("test1 = %x\ntest2 = %x\n", test1, test2); } # gcc main.c # ./a.out test1 = 101 test2 = 101 --->8--- > Can you verify and supply a new patch if that holds true? Is the test ok? > Already applied to u-boot-atmel/master, But why do you apply the patch, if there are questions? regards Andreas Bie?mann