[U-Boot] [PATCH 0/6] misc fixes / cleanups

The following set of patches performs a number of pretty localized, simple fixes and cleanups:
1/6 boards.cfg: fix board directory name for ML2 board 2/6 shannon/INFERNO: fix special handling of environment configuration 3/6 cmd_ide.c: fix unused variable warning for SC3 board 4/6 exports.c: fix warning: 'dummy' defined but not used 5/6 Make *printf() return "int" instead of "void" 6/6 Redundant environment: move flag definitions to header file

Signed-off-by: Wolfgang Denk wd@denx.de --- boards.cfg | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/boards.cfg b/boards.cfg index 1a5cfb1..f012d6c 100644 --- a/boards.cfg +++ b/boards.cfg @@ -180,7 +180,7 @@ G2000 powerpc ppc4xx g2000 JSE powerpc ppc4xx jse korat powerpc ppc4xx lwmon5 powerpc ppc4xx -ML2 powerpc ppc4xx +ML2 powerpc ppc4xx ml2 sbc405 powerpc ppc4xx sc3 powerpc ppc4xx zeus powerpc ppc4xx

Remove some INFERNO related #ifdef's from common environment code by fixing the board configuration settings (add CONFIG_ENV_SECT_SIZE).
While we are at it, fix comment which incorrectly talks about 4 KB environment size, while it's actually 0x4000 = 16 KiB.
Signed-off-by: Wolfgang Denk wd@denx.de Cc: Rolf Offermanns rof@sysgo.de --- common/env_flash.c | 12 ------------ common/env_nand.c | 4 ---- include/configs/shannon.h | 7 ++++--- 3 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/common/env_flash.c b/common/env_flash.c index b860c48..ef0582d 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -44,12 +44,6 @@ DECLARE_GLOBAL_DATA_PTR; #error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE #endif
-#ifdef CONFIG_INFERNO -# ifdef CONFIG_ENV_ADDR_REDUND -#error CONFIG_ENV_ADDR_REDUND is not implemented for CONFIG_INFERNO -# endif -#endif - char * env_name_spec = "Flash";
#ifdef ENV_IS_EMBEDDED @@ -294,13 +288,7 @@ int saveenv(void) len = CONFIG_ENV_SIZE; #endif /* CONFIG_ENV_SECT_SIZE */
-#ifndef CONFIG_INFERNO end_addr = flash_sect_addr + len - 1; -#else - /* this is the last sector, and the size is hardcoded here */ - /* otherwise we will get stack problems on loading 128 KB environment */ - end_addr = flash_sect_addr + 0x20000 - 1; -#endif
debug ("Protect off %08lX ... %08lX\n", (ulong)flash_sect_addr, end_addr); diff --git a/common/env_nand.c b/common/env_nand.c index a15a950..50bc111 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -49,10 +49,6 @@ #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE #endif
-#ifdef CONFIG_INFERNO -#error CONFIG_INFERNO not supported yet -#endif - #ifndef CONFIG_ENV_RANGE #define CONFIG_ENV_RANGE CONFIG_ENV_SIZE #endif diff --git a/include/configs/shannon.h b/include/configs/shannon.h index 13cc5ff..d848915 100644 --- a/include/configs/shannon.h +++ b/include/configs/shannon.h @@ -161,12 +161,13 @@
#define CONFIG_ENV_IS_IN_FLASH 1 #ifdef CONFIG_INFERNO -/* we take the last sector, 128 KB in size, but we only use 4 KB of it for stack reasons */ +/* we take the last sector, 128 KB in size, but we only use 16 KB of it for stack reasons */ #define CONFIG_ENV_ADDR (PHYS_FLASH_1 + 0x003E0000) /* Addr of Environment Sector */ -#define CONFIG_ENV_SIZE 0x4000 /* Total Size of Environment Sector */ +#define CONFIG_ENV_SIZE 0x4000 /* Total Size of Environment */ +#define CONFIG_ENV_SECT_SIZE (128 << 10) /* size of environment sector */ #else #define CONFIG_ENV_ADDR (PHYS_FLASH_1 + 0x1C000) /* Addr of Environment Sector */ -#define CONFIG_ENV_SIZE 0x4000 /* Total Size of Environment Sector */ +#define CONFIG_ENV_SIZE 0x4000 /* Total Size of Environment */ #endif
/*-----------------------------------------------------------------------

In message 1277330773-28395-3-git-send-email-wd@denx.de you wrote:
Remove some INFERNO related #ifdef's from common environment code by fixing the board configuration settings (add CONFIG_ENV_SECT_SIZE).
While we are at it, fix comment which incorrectly talks about 4 KB environment size, while it's actually 0x4000 = 16 KiB.
Signed-off-by: Wolfgang Denk wd@denx.de Cc: Rolf Offermanns rof@sysgo.de
common/env_flash.c | 12 ------------ common/env_nand.c | 4 ---- include/configs/shannon.h | 7 ++++--- 3 files changed, 4 insertions(+), 19 deletions(-)
Applied.
Best regards,
Wolfgang Denk

Signed-off-by: Wolfgang Denk wd@denx.de --- common/cmd_ide.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 8bd8920..2e9f834 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -555,7 +555,6 @@ void ide_init (void) int i, bus; #if defined(CONFIG_SC3) unsigned int ata_reset_time = ATA_RESET_TIME; - char *s; #endif #ifdef CONFIG_IDE_8xx_PCCARD extern int pcmcia_on (void);

In message 1277330773-28395-4-git-send-email-wd@denx.de you wrote:
Signed-off-by: Wolfgang Denk wd@denx.de
common/cmd_ide.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
Applied.
Best regards,
Wolfgang Denk

Signed-off-by: Wolfgang Denk wd@denx.de --- common/exports.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/common/exports.c b/common/exports.c index 60bba75..cbc0f49 100644 --- a/common/exports.c +++ b/common/exports.c @@ -3,9 +3,13 @@
DECLARE_GLOBAL_DATA_PTR;
+#if (!defined(CONFIG_I386) && !defined(CONFIG_PPC)) || \ + !defined(CONFIG_CMD_I2C) || \ + !defined(CONFIG_CMD_SPI) static void dummy(void) { } +#endif
unsigned long get_version(void) {

On Wednesday, June 23, 2010 18:06:11 Wolfgang Denk wrote:
--- a/common/exports.c +++ b/common/exports.c @@ -3,9 +3,13 @@
DECLARE_GLOBAL_DATA_PTR;
+#if (!defined(CONFIG_I386) && !defined(CONFIG_PPC)) || \
- !defined(CONFIG_CMD_I2C) || \
- !defined(CONFIG_CMD_SPI)
static void dummy(void) { } +#endif
would __attribute__((unused)) be better ? then we'd avoid the #ifdef mess. -mike

Signed-off-by: Wolfgang Denk wd@denx.de --- v2: fix compile problem for some boards.
common/exports.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/common/exports.c b/common/exports.c index 60bba75..36321e3 100644 --- a/common/exports.c +++ b/common/exports.c @@ -3,9 +3,14 @@
DECLARE_GLOBAL_DATA_PTR;
+#if (!defined(CONFIG_I386) && !defined(CONFIG_PPC)) || \ + !defined(CONFIG_CMD_I2C) || \ + !defined(CONFIG_HAS_UID) || \ + !defined(CONFIG_CMD_SPI) static void dummy(void) { } +#endif
unsigned long get_version(void) {

On Tuesday, June 29, 2010 05:52:32 Wolfgang Denk wrote:
Signed-off-by: Wolfgang Denk wd@denx.de
v2: fix compile problem for some boards.
an attribute should fix all compile errors since the func never gets hidden ;) -mike

Dear Mike Frysinger,
In message 201006291600.44029.vapier@gentoo.org you wrote:
On Tuesday, June 29, 2010 05:52:32 Wolfgang Denk wrote:
Signed-off-by: Wolfgang Denk wd@denx.de
v2: fix compile problem for some boards.
an attribute should fix all compile errors since the func never gets hidden ;)
Yes, I read your first message too, just too late. Thanks!
Will respin that patch.
Best regards,
Wolfgang Denk

Also get rid of the #ifdef's while doing this.
Suggested-by: Mike Frysinger vapier@gentoo.org Signed-off-by: Wolfgang Denk wd@denx.de --- v2: fix compile problem for some boards. v3: get rid of #ifdef mess and use attribute instead as suggested by Mike Frysinger
common/exports.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/common/exports.c b/common/exports.c index 60bba75..8525db7 100644 --- a/common/exports.c +++ b/common/exports.c @@ -3,6 +3,7 @@
DECLARE_GLOBAL_DATA_PTR;
+static void dummy(void) __attribute__((unused)); static void dummy(void) { }

On Wednesday, June 30, 2010 18:44:46 Wolfgang Denk wrote:
+static void dummy(void) __attribute__((unused)); static void dummy(void) { }
put the attribute before the "static" and you shouldnt need the duplicate prototype -mike

Dear Mike Frysinger,
In message 201006301904.42571.vapier@gentoo.org you wrote:
+static void dummy(void) __attribute__((unused)); static void dummy(void) { }
put the attribute before the "static" and you shouldnt need the duplicate prototype
Ah, that's the trick that does it.
Thanks.
Best regards,
Wolfgang Denk

Also get rid of the #ifdef's while doing this.
Suggested-by: Mike Frysinger vapier@gentoo.org Signed-off-by: Wolfgang Denk wd@denx.de --- v2: fix compile problem for some boards. v3: get rid of #ifdef mess and use attribute instead as suggested by Mike Frysinger v4: Avoid separate prototype declaration.
common/exports.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/exports.c b/common/exports.c index 60bba75..ceee73a 100644 --- a/common/exports.c +++ b/common/exports.c @@ -3,7 +3,7 @@
DECLARE_GLOBAL_DATA_PTR;
-static void dummy(void) +__attribute__((unused)) static void dummy(void) { }

In message 1277969498-19996-1-git-send-email-wd@denx.de you wrote:
Also get rid of the #ifdef's while doing this.
Suggested-by: Mike Frysinger vapier@gentoo.org Signed-off-by: Wolfgang Denk wd@denx.de
v2: fix compile problem for some boards. v3: get rid of #ifdef mess and use attribute instead as suggested by Mike Frysinger v4: Avoid separate prototype declaration.
common/exports.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Applied.
Best regards,
Wolfgang Denk

Change the return type of the *printf() functions to the standard "int"; no changes are needed but returning the already available length count.
This will save a few additional strlen() calls later...
Signed-off-by: Wolfgang Denk wd@denx.de --- common/console.c | 12 ++++++++---- examples/api/libgenwrap.c | 6 ++++-- include/common.h | 8 ++++---- include/exports.h | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/common/console.c b/common/console.c index b09b7d1..7e01886 100644 --- a/common/console.c +++ b/common/console.c @@ -201,7 +201,7 @@ static inline void console_doenv(int file, struct stdio_dev *dev)
/** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
-void serial_printf(const char *fmt, ...) +int serial_printf(const char *fmt, ...) { va_list args; uint i; @@ -216,6 +216,7 @@ void serial_printf(const char *fmt, ...) va_end(args);
serial_puts(printbuffer); + return i; }
int fgetc(int file) @@ -269,7 +270,7 @@ void fputs(int file, const char *s) console_puts(file, s); }
-void fprintf(int file, const char *fmt, ...) +int fprintf(int file, const char *fmt, ...) { va_list args; uint i; @@ -285,6 +286,7 @@ void fprintf(int file, const char *fmt, ...)
/* Send to desired file */ fputs(file, printbuffer); + return i; }
/** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/ @@ -363,7 +365,7 @@ void puts(const char *s) } }
-void printf(const char *fmt, ...) +int printf(const char *fmt, ...) { va_list args; uint i; @@ -379,9 +381,10 @@ void printf(const char *fmt, ...)
/* Print the string */ puts(printbuffer); + return i; }
-void vprintf(const char *fmt, va_list args) +int vprintf(const char *fmt, va_list args) { uint i; char printbuffer[CONFIG_SYS_PBSIZE]; @@ -393,6 +396,7 @@ void vprintf(const char *fmt, va_list args)
/* Print the string */ puts(printbuffer); + return i; }
/* test if ctrl-c was pressed */ diff --git a/examples/api/libgenwrap.c b/examples/api/libgenwrap.c index b435dde..9733bbc 100644 --- a/examples/api/libgenwrap.c +++ b/examples/api/libgenwrap.c @@ -37,7 +37,7 @@ /* * printf() and vprintf() are stolen from u-boot/common/console.c */ -void printf (const char *fmt, ...) +int printf (const char *fmt, ...) { va_list args; uint i; @@ -53,9 +53,10 @@ void printf (const char *fmt, ...)
/* Print the string */ ub_puts (printbuffer); + return i; }
-void vprintf (const char *fmt, va_list args) +int vprintf (const char *fmt, va_list args) { uint i; char printbuffer[256]; @@ -67,6 +68,7 @@ void vprintf (const char *fmt, va_list args)
/* Print the string */ ub_puts (printbuffer); + return i; }
void putc (const char c) diff --git a/include/common.h b/include/common.h index 8bca04f..48f6a1a 100644 --- a/include/common.h +++ b/include/common.h @@ -663,7 +663,7 @@ int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */ * STDIO based functions (can always be used) */ /* serial stuff */ -void serial_printf (const char *fmt, ...) +int serial_printf (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); /* stdin */ int getc(void); @@ -672,9 +672,9 @@ int tstc(void); /* stdout */ void putc(const char c); void puts(const char *s); -void printf(const char *fmt, ...) +int printf(const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); -void vprintf(const char *fmt, va_list args); +int vprintf(const char *fmt, va_list args);
/* stderr */ #define eputc(c) fputc(stderr, c) @@ -689,7 +689,7 @@ void vprintf(const char *fmt, va_list args); #define stderr 2 #define MAX_FILES 3
-void fprintf(int file, const char *fmt, ...) +int fprintf(int file, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); void fputs(int file, const char *s); void fputc(int file, const char c); diff --git a/include/exports.h b/include/exports.h index c3a5d2f..9588bc9 100644 --- a/include/exports.h +++ b/include/exports.h @@ -11,14 +11,14 @@ int getc(void); int tstc(void); void putc(const char); void puts(const char*); -void printf(const char* fmt, ...); +int printf(const char* fmt, ...); void install_hdlr(int, interrupt_handler_t*, void*); void free_hdlr(int); void *malloc(size_t); void free(void*); void __udelay(unsigned long); unsigned long get_timer(unsigned long); -void vprintf(const char *, va_list); +int vprintf(const char *, va_list); void do_reset (void); unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base); char *getenv (char *name);

In message 1277330773-28395-6-git-send-email-wd@denx.de you wrote:
Change the return type of the *printf() functions to the standard "int"; no changes are needed but returning the already available length count.
This will save a few additional strlen() calls later...
Signed-off-by: Wolfgang Denk wd@denx.de
common/console.c | 12 ++++++++---- examples/api/libgenwrap.c | 6 ++++-- include/common.h | 8 ++++---- include/exports.h | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-)
Applied.
Best regards,
Wolfgang Denk

Instead of defining the flags sevaral times in different source files (which is error prone), move them to a central place in a header file.
Signed-off-by: Wolfgang Denk wd@denx.de --- common/env_eeprom.c | 5 ----- common/env_flash.c | 3 --- include/environment.h | 3 +++ 3 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/common/env_eeprom.c b/common/env_eeprom.c index 4f7f0db..8fe59f8 100644 --- a/common/env_eeprom.c +++ b/common/env_eeprom.c @@ -32,11 +32,6 @@ #include <i2c.h> #endif
-#ifdef CONFIG_ENV_OFFSET_REDUND -#define ACTIVE_FLAG 1 -#define OBSOLETE_FLAG 0 -#endif - DECLARE_GLOBAL_DATA_PTR;
env_t *env_ptr = NULL; diff --git a/common/env_flash.c b/common/env_flash.c index ef0582d..925c5a0 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -71,9 +71,6 @@ static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND; /* CONFIG_ENV_ADDR is supposed to be on sector boundary */ static ulong end_addr = CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1; static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1; - -#define ACTIVE_FLAG 1 -#define OBSOLETE_FLAG 0 #endif /* CONFIG_ENV_ADDR_REDUND */
extern uchar default_environment[]; diff --git a/include/environment.h b/include/environment.h index b9924fd..203f731 100644 --- a/include/environment.h +++ b/include/environment.h @@ -122,6 +122,9 @@
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT # define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) + +# define ACTIVE_FLAG 1 +# define OBSOLETE_FLAG 0 #else # define ENV_HEADER_SIZE (sizeof(uint32_t)) #endif

In message 1277330773-28395-7-git-send-email-wd@denx.de you wrote:
Instead of defining the flags sevaral times in different source files (which is error prone), move them to a central place in a header file.
Signed-off-by: Wolfgang Denk wd@denx.de
common/env_eeprom.c | 5 ----- common/env_flash.c | 3 --- include/environment.h | 3 +++ 3 files changed, 3 insertions(+), 8 deletions(-)
Applied.
Best regards,
Wolfgang Denk
participants (2)
-
Mike Frysinger
-
Wolfgang Denk