From 15b86c3d6c9a5a2e917b73d758a556568430021a Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sat, 16 Jan 2010 21:50:26 -0700 Subject: env_nand.c: print error message and fail gracefully env_nand.c would crash silently if a malloc() for the environment buffers failed; make it print an error message and fail gracefully, i. e. use the default environment then. Signed-off-by: Wolfgang Denk Acked-by: John Rigby --- common/env_nand.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/env_nand.c b/common/env_nand.c index ca631af..a15a950 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -298,6 +298,13 @@ void env_relocate_spec (void) tmp_env1 = (env_t *) malloc(CONFIG_ENV_SIZE); tmp_env2 = (env_t *) malloc(CONFIG_ENV_SIZE); + if ((tmp_env1 == NULL) || (tmp_env2 == NULL)) { + puts("Can't allocate buffers for environment\n"); + free (tmp_env1); + free (tmp_env2); + return use_default(); + } + if (readenv(CONFIG_ENV_OFFSET, (u_char *) tmp_env1)) puts("No Valid Environment Area Found\n"); if (readenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) tmp_env2)) -- cgit v1.1 From a6e42ed097220a82870a32f4e60ac8863a8b05ab Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Sat, 12 Dec 2009 21:20:57 +0100 Subject: lcd: remove CONFIG_ATMEL_LCD ifdefs from lcd_setfgcolor Not all boards defining LCD_COLOR16 are able to set lcd_color_fg/lcd_color_bg correctly. The issue seems to be caused by CONFIG_ATMEL_LCD ifdefs in lcd_setfgcolor() and lcd_setbgcolor(). Actually, the color values passed to these functions are already correct, we don't need to fix them. So remove ifdefs here. Reported-by: Alessandro Rubini Signed-off-by: Anatolij Gustschin --- common/lcd.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'common') diff --git a/common/lcd.c b/common/lcd.c index 4e31618..db799db 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -456,22 +456,14 @@ ulong lcd_setmem (ulong addr) static void lcd_setfgcolor (int color) { -#ifdef CONFIG_ATMEL_LCD lcd_color_fg = color; -#else - lcd_color_fg = color & 0x0F; -#endif } /*----------------------------------------------------------------------*/ static void lcd_setbgcolor (int color) { -#ifdef CONFIG_ATMEL_LCD lcd_color_bg = color; -#else - lcd_color_bg = color & 0x0F; -#endif } /*----------------------------------------------------------------------*/ -- cgit v1.1 From 5f566f454750be4f2f83288ef382afcb9c4aa8a4 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Sun, 31 Jan 2010 21:51:43 +0100 Subject: cmd_ximg.c: fix error: 'i' undeclared Fix compile error: cmd_ximg.c: In function 'do_imgextract': cmd_ximg.c:234: error: 'i' undeclared (first use in this function) cmd_ximg.c:234: error: (Each undeclared identifier is reported only once cmd_ximg.c:234: error: for each function it appears in.) Signed-off-by: Wolfgang Denk --- common/cmd_ximg.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'common') diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index 3e5fb44..b34c4d0 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -225,20 +225,25 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) break; #if defined(CONFIG_BZIP2) case IH_COMP_BZIP2: - printf (" Uncompressing part %d ... ", part); - /* - * If we've got less than 4 MB of malloc() space, - * use slower decompression algorithm which requires - * at most 2300 KB of memory. - */ - i = BZ2_bzBuffToBuffDecompress - ((char*)ntohl(hdr->ih_load), - &unc_len, (char *)data, len, - CONFIG_SYS_MALLOC_LEN < (4096 * 1024), 0); - if (i != BZ_OK) { - printf ("BUNZIP2 ERROR %d - " - "image not loaded\n", i); - return 1; + { + int i; + + printf (" Uncompressing part %d ... ", part); + /* + * If we've got less than 4 MB of malloc() + * space, use slower decompression algorithm + * which requires at most 2300 KB of memory. + */ + i = BZ2_bzBuffToBuffDecompress( + (char*)ntohl(hdr->ih_load), + &unc_len, (char *)data, len, + CONFIG_SYS_MALLOC_LEN < (4096 * 1024), + 0); + if (i != BZ_OK) { + printf ("BUNZIP2 ERROR %d - " + "image not loaded\n", i); + return 1; + } } break; #endif /* CONFIG_BZIP2 */ -- cgit v1.1 From 84d36b30181acfb72f22d1105c15574b30ea2fa1 Mon Sep 17 00:00:00 2001 From: Remy Bohmer Date: Mon, 1 Feb 2010 19:40:47 +0100 Subject: USB: usb_control_msg wait for driver ISR to set status. This patch changes usb_control_msg back to the state prior to commit 48867208444cb2a82e2af9c3249e90b7ed4a1751. The USB driver ISR routine may update the status. Signed-off-by: Daniel Hellstrom --- common/usb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'common') diff --git a/common/usb.c b/common/usb.c index eef4b34..10e23de 100644 --- a/common/usb.c +++ b/common/usb.c @@ -197,16 +197,21 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, if (timeout == 0) return (int)size; - if (dev->status != 0) { - /* - * Let's wait a while for the timeout to elapse. - * It has no real use, but it keeps the interface happy. - */ - wait_ms(timeout); - return -1; + /* + * Wait for status to update until timeout expires, USB driver + * interrupt handler may set the status when the USB operation has + * been completed. + */ + while (timeout--) { + if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC)) + break; + wait_ms(1); } + if (dev->status) + return -1; return dev->act_len; + } /*------------------------------------------------------------------- -- cgit v1.1 From ab5a0dcb9c8f19e351fc33c5db91469bfb1d9438 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 2 Feb 2010 13:43:48 +0100 Subject: net: Use 0.5 sec timeout in miiphy_reset() instead of counting loop This patch fixes a problem I've notived on a buggy PPC4xx system. This system has problems with the PHY MDIO communication and seemed to be stuck/crashed in miiphy_reset(). But degugging revealed, that the CPU didn't crash, but "only" hung in this counting loop for about 2 minutes. This patch now uses a real timeout of 0.5 seconds (as mentioned in the comment in miiphy_reset). Signed-off-by: Stefan Roese Signed-off-by: Ben Warren --- common/miiphyutil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/miiphyutil.c b/common/miiphyutil.c index 196ef4a..856fbc7 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -293,7 +293,7 @@ int miiphy_info (char *devname, unsigned char addr, unsigned int *oui, int miiphy_reset (char *devname, unsigned char addr) { unsigned short reg; - int loop_cnt; + int timeout = 500; if (miiphy_read (devname, addr, PHY_BMCR, ®) != 0) { debug ("PHY status read failed\n"); @@ -311,13 +311,13 @@ int miiphy_reset (char *devname, unsigned char addr) * auto-clearing). This should happen within 0.5 seconds per the * IEEE spec. */ - loop_cnt = 0; reg = 0x8000; - while (((reg & 0x8000) != 0) && (loop_cnt++ < 1000000)) { - if (miiphy_read (devname, addr, PHY_BMCR, ®) != 0) { - debug ("PHY status read failed\n"); - return (-1); + while (((reg & 0x8000) != 0) && timeout--) { + if (miiphy_read(devname, addr, PHY_BMCR, ®) != 0) { + debug("PHY status read failed\n"); + return -1; } + udelay(1000); } if ((reg & 0x8000) == 0) { return (0); -- cgit v1.1 From f3651764e57e353251695691677bd95ba5a420bc Mon Sep 17 00:00:00 2001 From: Frans Meulenbroeks Date: Mon, 22 Feb 2010 22:49:06 +0100 Subject: cmd_itest.c: fix pointer dereferencing fix pointer dereferencing if the size is .b and .w an 8 or 16 bit access is done. Signed-off-by: Frans Meulenbroeks Acked-by: Detlev Zundel --- common/cmd_itest.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/cmd_itest.c b/common/cmd_itest.c index 5b301bf..58c5e7b 100644 --- a/common/cmd_itest.c +++ b/common/cmd_itest.c @@ -66,12 +66,17 @@ op_tbl_t op_table [] = { static long evalexp(char *s, int w) { - long l, *p; + long l = 0; + long *p; /* if the parameter starts with a * then assume is a pointer to the value we want */ if (s[0] == '*') { p = (long *)simple_strtoul(&s[1], NULL, 16); - l = *p; + switch (w) { + case 1: return((long)(*(unsigned char *)p)); + case 2: return((long)(*(unsigned short *)p)); + case 4: return(*p); + } } else { l = simple_strtoul(s, NULL, 16); } -- cgit v1.1