board/mbx8xx/mbx8xx.c: Fix GCC 4.6 build warnings
authorWolfgang Denk <wd@denx.de>
Fri, 4 Nov 2011 15:55:44 +0000 (15:55 +0000)
committerWolfgang Denk <wd@denx.de>
Mon, 7 Nov 2011 21:14:36 +0000 (22:14 +0100)
Fix:
mbx8xx.c: In function 'mbx_init':
mbx8xx.c:127:15: warning: variable 'refclock' set but not used
[-Wunused-but-set-variable]
mbx8xx.c: In function 'board_get_cpufreq':
mbx8xx.c:231:2: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]
mbx8xx.c: In function 'get_reffreq':
mbx8xx.c:242:2: warning: dereferencing type-punned pointer will break
strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Wolfgang Denk <wd@denx.de>
board/mbx8xx/mbx8xx.c

index 255796bd10c5ecf6f667411a5e9ffeae83683ad0..0f014e1ad4e1cfd651f2d81aa3d0d32f9d1fa57e 100644 (file)
@@ -117,14 +117,16 @@ static const uint sdram_table_50[] = {
 
 /* ------------------------------------------------------------------------- */
 
+#ifdef CONFIG_SYS_USE_OSCCLK
 static unsigned int get_reffreq(void);
+#endif
 static unsigned int board_get_cpufreq(void);
 
 void mbx_init (void)
 {
        volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
        volatile memctl8xx_t *memctl = &immr->im_memctl;
-       ulong speed, refclock, plprcr, sccr;
+       ulong speed, plprcr, sccr;
        ulong br0_32 = memctl->memc_br0 & 0x400;
 
        /* real-time clock status and control register */
@@ -152,7 +154,6 @@ void mbx_init (void)
        immr->im_clkrst.car_sccr = sccr;
 
        speed = board_get_cpufreq ();
-       refclock = get_reffreq ();
 
 #if ((CONFIG_SYS_PLPRCR & PLPRCR_MF_MSK) != 0)
        plprcr = CONFIG_SYS_PLPRCR;
@@ -163,7 +164,7 @@ void mbx_init (void)
 #endif
 
 #ifdef CONFIG_SYS_USE_OSCCLK                   /* See doc/README.MBX ! */
-       plprcr |= ((speed + refclock / 2) / refclock - 1) << 20;
+       plprcr |= ((speed + get_reffreq() / 2) / refclock - 1) << 20;
 #endif
 
        immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
@@ -226,21 +227,27 @@ static unsigned int board_get_cpufreq (void)
 {
 #ifndef CONFIG_8xx_GCLK_FREQ
        vpd_packet_t *packet;
+       ulong *p;
 
        packet = vpd_find_packet (VPD_PID_ICS);
-       return *((ulong *) packet->data);
+       p = (ulong *)packet->data;
+       return *p;
 #else
        return((unsigned int)CONFIG_8xx_GCLK_FREQ );
 #endif /* CONFIG_8xx_GCLK_FREQ */
 }
 
+#ifdef CONFIG_SYS_USE_OSCCLK
 static unsigned int get_reffreq (void)
 {
        vpd_packet_t *packet;
+       ulong *p;
 
        packet = vpd_find_packet (VPD_PID_RCS);
-       return *((ulong *) packet->data);
+       p = (ulong *)packet->data;
+       return *p;
 }
+#endif
 
 static void board_get_enetaddr(uchar *addr)
 {