Cleanup environment related files
cover Cleanup environment related files
This patch series cleans up environment related files in terms of checkpatch and other coding style issues. It is based on Mon, 7 Nov 2011 Wolfgang's master.
There are several warnings/errors left, mostly because I don't think we need those solved or I can't choose the right solution.
Probably, there will be several conflict with the recent patches on the list, so once all issues are fixed,
I can rebase this patch set on top of the most recent master.
Thanks to all reviewers :-)
Igor Grinberg (17):
env: clean environment.h checkpatch and code style
common: move extern char console_buffer[] to common.h
env: move extern default_environment[] to environment.h
env: move extern environment[] to environment.h
env: clean cmd_nvedit.c checkpatch and code style
env: clean env_nowhere.c checkpatch and code style
env: clean env_mgdisk.c checkpatch and code style
env: clean env_dataflash.c checkpatch and code style
env: clean env_onenand.c checkpatch and code style
env: clean env_nvram.c checkpatch and code style
env: clean env_mmc.c checkpatch and code style
env: clean env_embedded.c checkpatch and code style
env: clean env_eeprom.c checkpatch and code style
env: clean env_sf.c checkpatch and code style
env: clean env_flash.c checkpatch and code style
env: clean env_nand.c checkpatch and code style
env: clean env_common.c checkpatch and code style
board/amcc/yucca/cmd_yucca.c | 1 - board/eltec/bab7xx/misc.c | 1 - board/eltec/elppc/misc.c | 1 - board/eltec/mhpc/mhpc.c | 3 - board/hymod/input.c | 3 - board/zeus/zeus.c | 1 - common/cmd_bedbug.c | 1 - common/cmd_dcr.c | 1 - common/cmd_i2c.c | 1 - common/cmd_mem.c | 1 - common/cmd_nvedit.c | 100 +++++++++++------------ common/cmd_pci.c | 1 - common/env_common.c | 52 ++++-------- common/env_dataflash.c | 34 +++----- common/env_eeprom.c | 104 +++++++++++------------- common/env_embedded.c | 47 ++++++------ common/env_flash.c | 181 ++++++++++++++++++++---------------------- common/env_mgdisk.c | 7 +- common/env_mmc.c | 78 ++++++------------- common/env_nand.c | 105 +++++++++++------------- common/env_nowhere.c | 12 +-- common/env_nvram.c | 26 +++--- common/env_onenand.c | 21 ++---- common/env_sf.c | 51 +++++------- common/hush.c | 1 - common/modem.c | 1 - include/command.h | 3 + include/common.h | 1 + include/dataflash.h | 2 + include/environment.h | 61 +++++++++----- tools/envcrc.c | 4 +- 31 files changed, 395 insertions(+), 511 deletions(-)
Signature · 1 line
1.7.3.4
PATCH 1/17 env: clean environment.h checkpatch and code style
Though one warning left:
WARNING: do not add new typedefs
#149: FILE: u-boot/include/environment.h:149:
+typedef struct environment_s {
total: 0 errors, 1 warnings, 181 lines checked
--- include/environment.h | 44 +++++++++++++++++++++++--------------------- 1 files changed, 23 insertions(+), 21 deletions(-)
include/environment.h +23 -21
@@ -38,21 +38,22 @@*/ #if defined(CONFIG_ENV_IS_IN_FLASH ) -# ifndef CONFIG_ENV_ADDR -# define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET) +# ifndef CONFIG_ENV_ADDR +# define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET)# endif -# ifndef CONFIG_ENV_OFFSET -# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE) +# ifndef CONFIG_ENV_OFFSET +# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE)# endif # if !defined(CONFIG_ENV_ADDR_REDUND ) && defined(CONFIG_ENV_OFFSET_REDUND ) -# define CONFIG_ENV_ADDR_REDUND (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND) +# define CONFIG_ENV_ADDR_REDUND \ + (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND)# endif # if defined(CONFIG_ENV_SECT_SIZE ) || defined(CONFIG_ENV_SIZE ) -# ifndef CONFIG_ENV_SECT_SIZE -# define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE +# ifndef CONFIG_ENV_SECT_SIZE +# define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE# endif -# ifndef CONFIG_ENV_SIZE -# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE +# ifndef CONFIG_ENV_SIZE +# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE# endif # else # error "Both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE undefined"
@@ -60,8 +61,9 @@# if defined(CONFIG_ENV_ADDR_REDUND ) && !defined(CONFIG_ENV_SIZE_REDUND )# define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE# endif -# if (CONFIG_ENV_ADDR >=CONFIG_SYS_MONITOR_BASE ) && \ - (CONFIG_ENV_ADDR +CONFIG_ENV_SIZE ) <= (CONFIG_SYS_MONITOR_BASE +CONFIG_SYS_MONITOR_LEN ) +# if (CONFIG_ENV_ADDR >=CONFIG_SYS_MONITOR_BASE ) && \ + (CONFIG_ENV_ADDR +CONFIG_ENV_SIZE ) <= \ + (CONFIG_SYS_MONITOR_BASE +CONFIG_SYS_MONITOR_LEN )# define ENV_IS_EMBEDDED 1# endif # if defined(CONFIG_ENV_ADDR_REDUND ) || defined(CONFIG_ENV_OFFSET_REDUND )
@@ -105,10 +107,10 @@ extern unsigned long nand_env_oob_offset;/* Embedded env is only supported for some flash types */ #ifdef CONFIG_ENV_IS_EMBEDDED -# if !defined(CONFIG_ENV_IS_IN_FLASH ) && \ - !defined(CONFIG_ENV_IS_IN_NAND ) && \ - !defined(CONFIG_ENV_IS_IN_ONENAND ) && \ - !defined(CONFIG_ENV_IS_IN_SPI_FLASH ) +# if !defined(CONFIG_ENV_IS_IN_FLASH ) && \ + !defined(CONFIG_ENV_IS_IN_NAND ) && \ + !defined(CONFIG_ENV_IS_IN_ONENAND ) && \ + !defined(CONFIG_ENV_IS_IN_SPI_FLASH )# error "CONFIG_ENV_IS_EMBEDDED not supported for your flash type"# endif #endif
@@ -144,7 +146,7 @@ extern unsigned long nand_env_oob_offset;#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) -typedef struct environment_s { +typedef struct environment_s { uint32_t crc; /* CRC32 over data bytes */ #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT unsigned char flags; /* active/obsolete flags */
@@ -159,14 +161,14 @@ typedef struct environment_s {extern struct hsearch_data env_htab;/* Function that returns a character from the environment */ -unsigned char env_get_char (int ); +unsigned char env_get_char (int );/* Function that returns a pointer to a value from the environment */ const unsigned char *env_get_addr (int ); -unsigned char env_get_char_memory (int index); +unsigned char env_get_char_memory (int index);/* Function that updates CRC of the enironment */ -void env_crc_update (void ); +void env_crc_update (void );/* [re]set to the default environment */ void set_default_env (const char *s);
@@ -174,6 +176,6 @@ void set_default_env(const char *s);/* Import from binary representation into hash table */ int env_import (const char *buf,int check); -#endif +#endif /* DO_DEPS_ONLY */ -#endif /* _ENVIRONMENT_H_ */ +#endif /* _ENVIRONMENT_H_ */
Signature · 1 line
1.7.3.4
PATCH 2/17 common: move extern char console_buffer[] to common.h
In reply to Igor GrinbergExtract all extern declarations for console_buffer[] out of c files into the common.h header.
--- board/amcc/yucca/cmd_yucca.c | 1 - board/eltec/bab7xx/misc.c | 1 - board/eltec/elppc/misc.c | 1 - board/eltec/mhpc/mhpc.c | 3 --- board/hymod/input.c | 3 --- common/cmd_bedbug.c | 1 - common/cmd_dcr.c | 1 - common/cmd_i2c.c | 1 - common/cmd_mem.c | 1 - common/cmd_nvedit.c | 1 - common/cmd_pci.c | 1 - common/hush.c | 1 - common/modem.c | 1 - include/common.h | 1 + 14 files changed, 1 insertions(+), 17 deletions(-)
board/amcc/yucca/cmd_yucca.c +0 -1
@@ -51,7 +51,6 @@ static int setBootStrapClock(cmd_tbl_t *cmdtp, int incrflag, int flag,uchar chip;ulong data;int nbytes; -extern char console_buffer[];char sysClock[4 ];char cpuClock[4 ];
board/eltec/bab7xx/misc.c +0 -1
@@ -31,7 +31,6 @@#include "srom.h" /* imports */ -extern char console_buffer[CONFIG_SYS_CBSIZE ];extern int l2_cache_enable (int l2control);extern void *nvram_read (void *dest,const short src,size_t count);extern void nvram_write (short dest,const void *src,size_t count);
board/eltec/elppc/misc.c +0 -1
@@ -29,7 +29,6 @@#include "srom.h" /* imports */ -extern char console_buffer[CONFIG_SYS_CBSIZE ];extern int l2_cache_enable (int l2control);extern int eepro100_write_eeprom (struct eth_device *dev,int location,int addr_len,unsigned short data);
board/eltec/mhpc/mhpc.c +0 -3
@@ -35,9 +35,6 @@#include "mpc8xx.h" #include <video_fb.h> -/* imports from common/main.c */ -extern char console_buffer[CONFIG_SYS_CBSIZE ]; -extern void eeprom_init (void );extern int eeprom_read (unsigned dev_addr,unsigned offset,unsigned char *buffer,unsigned cnt);
board/hymod/input.c +0 -3
@@ -23,9 +23,6 @@#include <common.h> -/* imports from common/main.c */ -extern char console_buffer[CONFIG_SYS_CBSIZE ]; -int hymod_get_serno (const char *prompt) {
common/cmd_bedbug.c +0 -1
@@ -15,7 +15,6 @@ DECLARE_GLOBAL_DATA_PTR; extern void show_regs __P ((struct pt_regs *)); extern int run_command __P ((const char *, int)); -extern char console_buffer[];ulong dis_last_addr =0 ;/* Last address disassembled */ ulong dis_last_len =20 ;/* Default disassembler length */
common/cmd_dcr.c +0 -1
@@ -68,7 +68,6 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])/* DCR's value */ int nbytes; -extern char console_buffer[];/* Validate arguments */ if (argc <2 )
common/cmd_i2c.c +0 -1
@@ -449,7 +449,6 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argulong data;int size =1 ;int nbytes; -extern char console_buffer[];if (argc !=3 )return cmd_usage (cmdtp);
common/cmd_mem.c +0 -1
@@ -982,7 +982,6 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) {ulong addr, i;int nbytes, size; -extern char console_buffer[];if (argc !=2 )return cmd_usage (cmdtp);
common/cmd_nvedit.c +0 -1
@@ -423,7 +423,6 @@ int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])#if defined(CONFIG_CMD_ASKENV )int do_env_ask (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -extern char console_buffer[CONFIG_SYS_CBSIZE ];char message[CONFIG_SYS_CBSIZE ];int size =CONFIG_SYS_CBSIZE -1 ;int i, len, pos;
common/cmd_pci.c +0 -1
@@ -341,7 +341,6 @@ pci_cfg_modify (pci_dev_t bdf, ulong addr, ulong size, ulong value, int incrflag {ulong i;int nbytes; -extern char console_buffer[];uint val4;ushort val2;u_char val1;
common/hush.c +0 -1
@@ -1000,7 +1000,6 @@ static void get_user_input(struct in_str *i)fflush (stdout); i->p = the_command;#else -extern char console_buffer[];int n;static char the_command[CONFIG_SYS_CBSIZE ];
common/modem.c +0 -1
@@ -62,7 +62,6 @@ int mdm_init (void)char env_str[16 ];char *init_str;int i; -extern char console_buffer[];extern void enable_putc (void );extern int hwflow_onoff (int );
include/common.h +1 -0
@@ -272,6 +272,7 @@ void reset_cmd_timeout(void);#ifdef CONFIG_MENU int abortboot (int bootdelay);#endif +extern char console_buffer[];/* arch/$(ARCH)/lib/board.c */ void board_init_f (ulong ) __attribute__ ((noreturn));
Signature · 1 line
1.7.3.4
PATCH 3/17 env: move extern default_environment[] to environment.h
In reply to Igor GrinbergExtract all extern declarations for default_environment[] out of c files into the environment.h header.
--- board/zeus/zeus.c | 1 - common/env_dataflash.c | 2 -- common/env_flash.c | 2 -- common/env_mgdisk.c | 3 --- common/env_mmc.c | 3 --- common/env_nand.c | 3 --- common/env_nowhere.c | 2 -- common/env_nvram.c | 2 -- common/env_onenand.c | 3 --- common/env_sf.c | 3 --- include/environment.h | 2 ++ 11 files changed, 2 insertions(+), 24 deletions(-)
board/zeus/zeus.c +0 -1
@@ -40,7 +40,6 @@ DECLARE_GLOBAL_DATA_PTR;extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS ];/* info for FLASH chips */ extern env_t *env_ptr; -extern uchar default_environment[];ulong flash_get_size (ulong base,int banknum);void env_crc_update (void );
common/env_dataflash.c +0 -2
@@ -37,8 +37,6 @@ extern int write_dataflash(unsigned long addr_dest, unsigned long addr_src, unsigned long size);extern int AT91F_DataflashInit (void ); -extern uchar default_environment[]; -uchar env_get_char_spec (int index) {uchar c;
common/env_flash.c +0 -2
@@ -74,8 +74,6 @@ static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;static ulong end_addr_new =CONFIG_ENV_ADDR_REDUND +CONFIG_ENV_SECT_SIZE -1 ;#endif /* CONFIG_ENV_ADDR_REDUND */ -extern const uchar default_environment[]; -uchar env_get_char_spec (int index) {
common/env_mgdisk.c +0 -3
@@ -27,9 +27,6 @@#include <linux/stddef.h> #include <mg_disk.h> -/* references to names in env_common.c */ -extern uchar default_environment[]; -char *env_name_spec ="MG_DISK" ;env_t *env_ptr =0 ;
common/env_mmc.c +0 -3
@@ -32,9 +32,6 @@#include <search.h> #include <errno.h> -/* references to names in env_common.c */ -extern uchar default_environment[]; -char *env_name_spec ="MMC" ;#ifdef ENV_IS_EMBEDDED
common/env_nand.c +0 -3
@@ -55,9 +55,6 @@#define CONFIG_ENV_RANGE CONFIG_ENV_SIZE#endif -/* references to names in env_common.c */ -extern uchar default_environment[]; -char *env_name_spec ="NAND" ;
common/env_nowhere.c +0 -2
@@ -33,8 +33,6 @@ DECLARE_GLOBAL_DATA_PTR;env_t *env_ptr =NULL ; -extern uchar default_environment[]; -void env_relocate_spec (void ) { }
common/env_nvram.c +0 -2
@@ -59,8 +59,6 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;char * env_name_spec ="NVRAM" ; -extern uchar default_environment[]; -uchar env_get_char_spec (int index) {#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
common/env_onenand.c +0 -3
@@ -39,9 +39,6 @@extern struct mtd_info onenand_mtd;extern struct onenand_chip onenand_chip; -/* References to names in env_common.c */ -extern uchar default_environment[]; -char *env_name_spec ="OneNAND" ;#define ONENAND_MAX_ENV_SIZE 4096
common/env_sf.c +0 -3
@@ -55,9 +55,6 @@ static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND;DECLARE_GLOBAL_DATA_PTR ; -/* references to names in env_common.c */ -extern uchar default_environment[]; -char * env_name_spec ="SPI Flash" ;static struct spi_flash *env_flash;
include/environment.h +2 -0
@@ -154,6 +154,8 @@ typedef struct environment_s {unsigned char data[ENV_SIZE ];/* Environment data */ } env_t; +extern const unsigned char default_environment[]; +#ifndef DO_DEPS_ONLY #include <search.h>
Signature · 1 line
1.7.3.4
PATCH 3/17 env: move extern default_environment[] to environment.h
Quoted 5 lines · On Monday 07 November 2011 12:13:57 Igor Grinberg wrote:
Extract all extern declarations for default_environment[] out of c files into the
environment.hheader.Signed-off-by Igor Grinberg <[email protected]>Cc Stefan Roese <[email protected]>
Thanks.
Best regards,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
PATCH 3/17 env: move extern default_environment[] to environment.h
In reply to Igor GrinbergQuoted 5 lines · Igor Grinberg
Extract all extern declarations for default_environment[] out of c files into the
environment.hheader.Signed-off-by Igor Grinberg <[email protected]>Cc Stefan Roese <[email protected]>
Quoted 14 lines
--- board/zeus/zeus.c | 1 - common/env_dataflash.c | 2 -- common/env_flash.c | 2 -- common/env_mgdisk.c | 3 --- common/env_mmc.c | 3 --- common/env_nand.c | 3 --- common/env_nowhere.c | 2 -- common/env_nvram.c | 2 -- common/env_onenand.c | 3 --- common/env_sf.c | 3 --- include/environment.h | 2 ++ 11 files changed, 2 insertions(+), 24 deletions(-)
Hi Igor,
this patch breaks several boards because "tools" cannot be compiled clean:
gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /home/stefano/Projects/u-boot-staging/include -idirafter /home/stefano/Projects/u-boot-staging/include2 -idirafter /home/stefano/Projects/u-boot-staging/include -I /home/stefano/Projects/u-boot-staging/lib/libfdt -I /home/stefano/Projects/u-boot-staging/tools -DCONFIG_SYS_TEXT_BASE=0x02000000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
-pedantic -o envcrc.o envcrc.c -c
envcrc.c:80:1: Fehler: unbekannter Typname: ?env_t? make[1]: *** [envcrc.o] Fehler 1
You can try with the cmi_mpc5xx board, but it is only an example - I get the same errors with several ARM boards, because at the end environment.h is not included. Can you take a look at it ?
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 3/17 env: move extern default_environment[] to environment.h
Hi Stefano,
Quoted 36 lines · Stefano Babic
Quoted 5 lines · Igor Grinberg
Extract all extern declarations for default_environment[] out of c files into the
environment.hheader.Signed-off-by Igor Grinberg <[email protected]>Cc Stefan Roese <[email protected]>Quoted 14 lines
--- board/zeus/zeus.c | 1 - common/env_dataflash.c | 2 -- common/env_flash.c | 2 -- common/env_mgdisk.c | 3 --- common/env_mmc.c | 3 --- common/env_nand.c | 3 --- common/env_nowhere.c | 2 -- common/env_nvram.c | 2 -- common/env_onenand.c | 3 --- common/env_sf.c | 3 --- include/environment.h | 2 ++ 11 files changed, 2 insertions(+), 24 deletions(-)Hi Igor,
this patch breaks several boards because "tools" cannot be compiled clean:
gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter
/home/stefano/Projects/u-boot-staging/include-idirafter/home/stefano/Projects/u-boot-staging/include2-idirafter/home/stefano/Projects/u-boot-staging/include-I/home/stefano/Projects/u-boot-staging/lib/libfdt-I/home/stefano/Projects/u-boot-staging/tools(quoted diff) +0
-2-DCONFIG_SYS_TEXT_BASE=0x02000000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -pedantic -o envcrc.o envcrc.c -cenvcrc.c:80:1: Fehler: unbekannter Typname: ?env_t? make[1]: *** [envcrc.o] Fehler 1
Quoted 3 lines
You can try with the
cmi_mpc5xxboard, but it is only an example - I get the same errors with several ARM boards, because at the endenvironment.his not included. Can you take a look at it ?
I don't have the ppc cross tool chain at hand, can you tell me which ARM board(s) get broken, so I can verify this?
Also, I think it is not that patch but the next one:
[PATCH 04/17] env: move extern environment[] to environment.h
Can you please check if the attached patch fixes the envcrc.c problem?
Thanks.
Signature · 9 lines
Regards, Igor. -------------- next part -------------- A non-text attachment was scrubbed... Name: envcrc.patch Type: text/x-patch Size: 306 bytes Desc: not available Url : http://lists.denx.de/pipermail/u-boot/attachments/20111117/a9ad4f87/attachment.bin
PATCH 3/17 env: move extern default_environment[] to environment.h
Quoted 6 lines · Igor Grinberg
I don't have the ppc cross tool chain at hand, can you tell me which ARM board(s) get broken, so I can verify this?
Also, I think it is not that patch but the next one:
[PATCH 04/17] env: move extern environment[] toenvironment.h
You're right, but that was the result bisecting the tree.
Quoted 2 lines
Can you please check if the attached patch fixes the
envcrc.cproblem?
Yes, it is fixed - it is the missing environment.h. The board is built, as well as the other powerpc boards (the ones I tested up now). Can you resend only the [PATCH 04/17] ?
Thanks,
Stefano
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v2 4/17 env: move extern environment[] to environment.h
Extract all extern declarations for environment out of c files into the environment.h header.
---
v2: fix compilation for envcrc.c by including environment.h
(Thanks Stefano)
common/env_flash.c | 4 +--- common/env_mmc.c | 3 +-- common/env_nand.c | 3 +-- common/env_onenand.c | 6 +----- include/environment.h | 4 ++++ tools/envcrc.c | 5 +++-- 6 files changed, 11 insertions(+), 14 deletions(-)
common/env_flash.c +1 -3
@@ -49,9 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;char * env_name_spec ="Flash" ;#ifdef ENV_IS_EMBEDDED - -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR ;
common/env_mmc.c +1 -2
@@ -35,8 +35,7 @@char *env_name_spec ="MMC" ;#ifdef ENV_IS_EMBEDDED -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;#else /* ! ENV_IS_EMBEDDED */ env_t *env_ptr =NULL ;#endif /* ENV_IS_EMBEDDED */
common/env_nand.c +1 -2
@@ -59,8 +59,7 @@ char *env_name_spec = "NAND";#if defined(ENV_IS_EMBEDDED ) -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;#elif defined(CONFIG_NAND_ENV_DST )env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST ;#else /* ! ENV_IS_EMBEDDED */
common/env_onenand.c +1 -5
@@ -44,10 +44,6 @@ char *env_name_spec = "OneNAND";#define ONENAND_MAX_ENV_SIZE 4096#define ONENAND_ENV_SIZE (mtd) (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE) -#ifdef ENV_IS_EMBEDDED -extern uchar environment[]; -#endif /* ENV_IS_EMBEDDED */ -DECLARE_GLOBAL_DATA_PTR ;uchar env_get_char_spec (int index)
@@ -64,7 +60,7 @@ void env_relocate_spec(void)int rc;size_t retlen;#ifdef ENV_IS_EMBEDDED -char *buf = (char *)&environment[0 ]; +char *buf = (char *)&environment;#else loff_t env_addr =CONFIG_ENV_ADDR ;char onenand_env[ONENAND_MAX_ENV_SIZE ];
include/environment.h +4 -0
@@ -154,6 +154,10 @@ typedef struct environment_s {unsigned char data[ENV_SIZE ];/* Environment data */ } env_t; +#ifdef ENV_IS_EMBEDDED +extern env_t environment; +#endif /* ENV_IS_EMBEDDED */ +extern const unsigned char default_environment[];#ifndef DO_DEPS_ONLY
tools/envcrc.c +3 -2
@@ -61,6 +61,7 @@#endif /* CONFIG_ENV_IS_IN_FLASH */ #if defined(ENV_IS_EMBEDDED ) && !defined(CONFIG_BUILD_ENVCRC ) +# include <environment.h> # define CONFIG_BUILD_ENVCRC 1#endif
@@ -77,7 +78,7 @@ extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int);#ifdef CONFIG_BUILD_ENVCRC extern unsigned int env_size; -extern unsigned char environment; +extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */ int main (int argc,char **argv)
@@ -85,7 +86,7 @@ int main (int argc, char **argv)#ifdef CONFIG_BUILD_ENVCRC unsigned char pad =0x00 ;uint32_t crc; -unsigned char *envptr = &environment, +unsigned char *envptr = (unsigned char *)&environment, *dataptr = envptr +ENV_HEADER_SIZE ;unsigned int datasize =ENV_SIZE ;unsigned int eoe;
Signature · 1 line
1.7.3.4
PATCH v2 4/17 env: move extern environment[] to environment.h
tools/envcrc.c extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int); · line 82
Quoted 13 lines · On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
tools/envcrc.c +2
-1#if defined(ENV_IS_EMBEDDED ) && !defined(CONFIG_BUILD_ENVCRC ) +# include <environment.h> # define CONFIG_BUILD_ENVCRC 1#endif #ifdef CONFIG_BUILD_ENVCRC extern unsigned int env_size; -extern unsigned char environment; +extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */
this breaks when CONFIG_BUILD_ENVCRC is defined. you include environment.h when it isn't defined, but then use env_t when it is defined.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111125/c8901de6/attachment.pgp>
PATCH v2 4/17 env: move extern environment[] to environment.h
Hi Mike,
Quoted 4 lines · Mike Frysinger
Quoted 3 lines · On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
tools/envcrc.c +0
-0
Quoted 13 lines
tools/envcrc.c extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int); · line 82
Quoted 10 lines
#if
defined(ENV_IS_EMBEDDED)&& !defined(CONFIG_BUILD_ENVCRC)tools/envcrc.c +2
-1+# include <environment.h> # define CONFIG_BUILD_ENVCRC 1#endif #ifdef CONFIG_BUILD_ENVCRC extern unsigned int env_size; -extern unsigned char environment; +extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */ this breaks when
CONFIG_BUILD_ENVCRCis defined. you includeenvironment.hwhen it isn't defined, but then useenv_twhen it is defined.
Good... eh.. I mean Bad! Thanks for testing/reporting.
Can you, please, supply the error log, so I can include it in the fix commit message?
Thanks
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
In reply to Mike FrysingerWhen ENV_IS_EMBEDDED is not set, but CONFIG_BUILD_ENVCRC is set, the environment.h file does not get included resulting in unrecognized env_t type.
Fix this by moving the include directive.
--- tools/envcrc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
tools/envcrc.c +3 -3
@@ -61,7 +61,6 @@#endif /* CONFIG_ENV_IS_IN_FLASH */ #if defined(ENV_IS_EMBEDDED ) && !defined(CONFIG_BUILD_ENVCRC ) -# include <environment.h> # define CONFIG_BUILD_ENVCRC 1#endif
@@ -74,13 +73,14 @@#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) -extern uint32_t crc32 (uint32_t ,const unsigned char *,unsigned int ); -#ifdef CONFIG_BUILD_ENVCRC +# include <environment.h> extern unsigned int env_size;extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */ +extern uint32_t crc32 (uint32_t ,const unsigned char *,unsigned int ); +int main (int argc,char **argv) {#ifdef CONFIG_BUILD_ENVCRC
Signature · 1 line
1.7.3.4
PATCH 1/1 tools/envcrc: fix compile breakage
Dear Igor Grinberg,
Quoted 4 lines · In message <[email protected]> you…
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.
Hm... the fix seems wrong to me. What happens now if ENV_IS_EMBEDDED is set, but CONFIG_BUILD_ENVCRC is _not_ set?
Did this change pass a MAKEALL for example for ppc?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The thing is, as you progress in the Craft, you'll learn there is
another rule... When you break rules, break 'em good and hard.
- Terry Pratchett, _Wyrd Sisters_PATCH 1/1 tools/envcrc: fix compile breakage
Hi Wolfgang,
Quoted 10 lines · Wolfgang Denk
Dear Igor Grinberg,
Quoted 4 lines · In message <[email protected]> you…
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.Hm... the fix seems wrong to me. What happens now if
ENV_IS_EMBEDDEDis set, butCONFIG_BUILD_ENVCRCis _not_ set?
Well, you should look into that file...
it says:
#if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
# define CONFIG_BUILD_ENVCRC 1 #endif
So this will not be a problem.
As for the logic of it... I don't know what was the original intend.
Quoted 2 lines
Did this change pass a MAKEALL for example for ppc?
I don't have the tool chain for ppc.
I think the original fix has been tested by Stefano. Is there a requirement to have all the supported architectures tool chains, for submitting patches?
Stefano, Mike, can you, please, test it on PPC and Blackfin?
Thanks
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
Dear Igor Grinberg,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Hm... the fix seems wrong to me. What happens now if
ENV_IS_EMBEDDEDis set, butCONFIG_BUILD_ENVCRCis _not_ set?Well, you should look into that file...
It's faster for me to ask you to do that :-)
Quoted 6 lines
Quoted 1 line
Did this change pass a MAKEALL for example for ppc?
I don't have the tool chain for ppc.
I think the original fix has been tested by Stefano. Is there a requirement to have all the supported architectures tool chains, for submitting patches?
Not for all, but http://www.denx.de/wiki/U-Boot/Patches says "Please also run MAKEALL for _at_least_one_other_architecture_ than the one you made your modifications in."
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "They that can give up essential liberty to obtain a little temporary saftey deserve neither liberty not saftey." - Benjamin Franklin, 1759
PATCH 1/1 tools/envcrc: fix compile breakage
Quoted 10 lines · Wolfgang Denk
Dear Igor Grinberg,
Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Hm... the fix seems wrong to me. What happens now if
ENV_IS_EMBEDDEDis set, butCONFIG_BUILD_ENVCRCis _not_ set?Well, you should look into that file...
It's faster for me to ask you to do that :-)
I have already done that (before sending the patch) as soon as I saw the email from Mike, reporting the problem.
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
Did this change pass a MAKEALL for example for ppc?
I don't have the tool chain for ppc.
I think the original fix has been tested by Stefano. Is there a requirement to have all the supported architectures tool chains, for submitting patches?Not for all, but http://www.denx.de/wiki/U-Boot/Patches says "Please also run MAKEALL for _at_least_one_other_architecture_ than the one you made your modifications in."
10x for looking into that for me ;-)
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
In reply to Igor GrinbergQuoted 1 line · Igor Grinberg
I don't have the tool chain for ppc.
PATCH 1/1 tools/envcrc: fix compile breakage
Quoted 4 lines · Mike Frysinger
Quoted 1 line · Igor Grinberg
I don't have the tool chain for ppc.
10x Mike
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
In reply to Igor GrinbergDear Igor Grinberg,
Quoted 4 lines · In message <[email protected]> you…
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.
...
Quoted 1 line
-extern
uint32_tcrc32 (uint32_t, const unsigned char *, unsigned int);
...
Quoted 1 line
+extern
uint32_tcrc32 (uint32_t, const unsigned char *, unsigned int);
Also, instead of moving this line, you should rather insert something like "#include <u-boot/crc.h>" ...
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Too much of anything, even love, isn't necessarily a good thing. -- Kirk, "The Trouble with Tribbles", stardate 4525.6
PATCH 1/1 tools/envcrc: fix compile breakage
Hi Wolfgang,
Quoted 8 lines · Wolfgang Denk
Dear Igor Grinberg,
Quoted 4 lines · In message <[email protected]> you…
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.
Quoted 7 lines
...
Quoted 1 line
-extern
uint32_tcrc32 (uint32_t, const unsigned char *, unsigned int);...
Quoted 1 line
+extern
uint32_tcrc32 (uint32_t, const unsigned char *, unsigned int);Also, instead of moving this line, you should rather insert something like "#include <
u-boot/crc.h>" ...
I had no intend to clean this file,
but I can do this change in a separate patch.
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
In reply to Igor GrinbergQuoted 4 lines · On Monday 28 November 2011 02:57:38 Igor Grinberg wrote:
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.
seems to work for me now; thanks!
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111128/68f4334e/attachment.pgp>
PATCH 1/1 tools/envcrc: fix compile breakage
Quoted 8 lines · Mike Frysinger
Quoted 4 lines · On Monday 28 November 2011 02:57:38 Igor Grinberg wrote:
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.seems to work for me now; thanks!
Tested-by Mike Frysinger <[email protected]>
10x Mike - it is for Blackfin, right?
Wolfgang, can you apply the fix now?
Signature · 2 lines
Regards, Igor.
PATCH 1/1 tools/envcrc: fix compile breakage
In reply to Igor Grinbergping!
This fixes a compile breakage and
IMO should be applied before 2011.12 is out.
Can someone, please apply it?
Quoted 40 lines · Igor Grinberg
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.Reported-by Mike Frysinger <[email protected]>Signed-off-by Igor Grinberg <[email protected]>--- tools/envcrc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)tools/envcrc.c +3
-3@@ -61,7 +61,6 @@#endif /* CONFIG_ENV_IS_IN_FLASH */ #if defined(ENV_IS_EMBEDDED ) && !defined(CONFIG_BUILD_ENVCRC ) -# include <environment.h> # define CONFIG_BUILD_ENVCRC 1#endif @@ -74,13 +73,14 @@#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE) -extern uint32_t crc32 (uint32_t ,const unsigned char *,unsigned int ); -#ifdef CONFIG_BUILD_ENVCRC +# include <environment.h> extern unsigned int env_size;extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */ +extern uint32_t crc32 (uint32_t ,const unsigned char *,unsigned int ); +int main (int argc,char **argv) {#ifdef CONFIG_BUILD_ENVCRC
Signature · 2 lines
Regards, Igor.
Wolfgang Denk
AppliedPATCH 1/1 tools/envcrc: fix compile breakage
In reply to Igor GrinbergDear Igor Grinberg,
Quoted 10 lines · In message <[email protected]> you…
When
ENV_IS_EMBEDDEDis not set, butCONFIG_BUILD_ENVCRCis set, theenvironment.hfile does not get included resulting in unrecognizedenv_ttype.
Fix this by moving the include directive.Reported-by Mike Frysinger <[email protected]>Signed-off-by Igor Grinberg <[email protected]>--- tools/envcrc.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de All men should freely use those seven words which have the power to make any marriage run smoothly: You know dear, you may be right.
PATCH 4/17 env: move extern environment[] to environment.h
In reply to Igor GrinbergExtract all extern declarations for environment out of c files into the environment.h header.
--- common/env_flash.c | 4 +--- common/env_mmc.c | 3 +-- common/env_nand.c | 3 +-- common/env_onenand.c | 6 +----- include/environment.h | 4 ++++ tools/envcrc.c | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-)
common/env_flash.c +1 -3
@@ -49,9 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;char * env_name_spec ="Flash" ;#ifdef ENV_IS_EMBEDDED - -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR ;
common/env_mmc.c +1 -2
@@ -35,8 +35,7 @@char *env_name_spec ="MMC" ;#ifdef ENV_IS_EMBEDDED -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;#else /* ! ENV_IS_EMBEDDED */ env_t *env_ptr =NULL ;#endif /* ENV_IS_EMBEDDED */
common/env_nand.c +1 -2
@@ -59,8 +59,7 @@ char *env_name_spec = "NAND";#if defined(ENV_IS_EMBEDDED ) -extern uchar environment[]; -env_t *env_ptr = (env_t *)(&environment[0 ]); +env_t *env_ptr = &environment;#elif defined(CONFIG_NAND_ENV_DST )env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST ;#else /* ! ENV_IS_EMBEDDED */
common/env_onenand.c +1 -5
@@ -44,10 +44,6 @@ char *env_name_spec = "OneNAND";#define ONENAND_MAX_ENV_SIZE 4096#define ONENAND_ENV_SIZE (mtd) (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE) -#ifdef ENV_IS_EMBEDDED -extern uchar environment[]; -#endif /* ENV_IS_EMBEDDED */ -DECLARE_GLOBAL_DATA_PTR ;uchar env_get_char_spec (int index)
@@ -64,7 +60,7 @@ void env_relocate_spec(void)int rc;size_t retlen;#ifdef ENV_IS_EMBEDDED -char *buf = (char *)&environment[0 ]; +char *buf = (char *)&environment;#else loff_t env_addr =CONFIG_ENV_ADDR ;char onenand_env[ONENAND_MAX_ENV_SIZE ];
include/environment.h +4 -0
@@ -154,6 +154,10 @@ typedef struct environment_s {unsigned char data[ENV_SIZE ];/* Environment data */ } env_t; +#ifdef ENV_IS_EMBEDDED +extern env_t environment; +#endif /* ENV_IS_EMBEDDED */ +extern const unsigned char default_environment[];#ifndef DO_DEPS_ONLY
tools/envcrc.c +2 -2
@@ -77,7 +77,7 @@ extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int);#ifdef CONFIG_BUILD_ENVCRC extern unsigned int env_size; -extern unsigned char environment; +extern env_t environment;#endif /* CONFIG_BUILD_ENVCRC */ int main (int argc,char **argv)
@@ -85,7 +85,7 @@ int main (int argc, char **argv)#ifdef CONFIG_BUILD_ENVCRC unsigned char pad =0x00 ;uint32_t crc; -unsigned char *envptr = &environment, +unsigned char *envptr = (unsigned char *)&environment, *dataptr = envptr +ENV_HEADER_SIZE ;unsigned int datasize =ENV_SIZE ;unsigned int eoe;
Signature · 1 line
1.7.3.4
PATCH 5/17 env: clean cmd_nvedit.c checkpatch and code style
In reply to Igor GrinbergCleanup the cmd_nvedit.c checkpatch warnings, errors and coding style. There are 10 wanrings left about the simple_strtoul() function:
WARNING: simple_strtoul is obsolete, use kstrtoul instead #359: FILE: cmd_nvedit.c:359:
+ load_addr = simple_strtoul(argv[2], NULL, 16);
...
total: 0 errors, 10 warnings, 1043 lines checked
--- common/cmd_nvedit.c | 99 +++++++++++++++++++++++------------------------- include/command.h | 3 + include/environment.h | 3 + 3 files changed, 53 insertions(+), 52 deletions(-)
common/cmd_nvedit.c +47 -52
@@ -165,7 +165,8 @@ int do_env_print (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }#ifdef CONFIG_CMD_GREPENV -static int do_env_grep (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_env_grep (cmd_tbl_t *cmdtp,int flag, +int argc,char *const argv[]) {ENTRY *match;unsigned char matched[env_htab.size /8 ];
@@ -178,7 +179,7 @@ static int do_env_grep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[while (arg <= argc) { idx =0 ; -while ((idx =hstrstr_r (argv[arg], idx, &match, &env_htab))) { +while (idx =hstrstr_r (argv[arg], idx, &match, &env_htab)) {if (!(matched[idx /8 ] & (1 << (idx &7 )))) {puts (match->key);puts ("=" );
@@ -199,8 +200,7 @@ static int do_env_grep (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[* Set a new environment variable, * or replace or delete an existing one. */ - -int _do_env_set (int flag,int argc,char *const argv[]) +int _do_env_set (int flag,int argc,char *const argv[]) {bd_t *bd = gd->bd;int i, len;
@@ -211,7 +211,8 @@ int _do_env_set (int flag, int argc, char * const argv[]) name = argv[1 ];if (strchr (name,'=' )) { -printf ("## Error: illegal character '=' in variable name \"%s\"\n" , name); +printf ("## Error: illegal character '=' in variable name" +"\"%s\"\n" , name);return 1 ; }
@@ -259,12 +260,12 @@ int _do_env_set (int flag, int argc, char * const argv[])*/ if (ep) {/* variable exists */ #ifndef CONFIG_ENV_OVERWRITE -if ((strcmp (name,"serial#" ) ==0 ) || - ((strcmp (name,"ethaddr" ) ==0 ) +if (strcmp (name,"serial#" ) ==0 || + (strcmp (name,"ethaddr" ) ==0 #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) - && (strcmp (ep->data,MK_STR (CONFIG_ETHADDR )) !=0 ) + &&strcmp (ep->data,MK_STR (CONFIG_ETHADDR )) !=0 #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ - ) ) { + )) {printf ("Can't overwrite \"%s\"\n" , name);return 1 ; }
@@ -284,8 +285,8 @@ int _do_env_set (int flag, int argc, char * const argv[]) baudrate);return 1 ; } -printf ("## Switch baudrate to %d bps and press ENTER ...\n" , - baudrate); +printf ("## Switch baudrate to %d bps and" +"press ENTER ...\n" , baudrate);udelay (50000 ); gd->baudrate = baudrate;#if defined(CONFIG_PPC ) || defined(CONFIG_MCF52x2)
@@ -294,15 +295,13 @@ int _do_env_set (int flag, int argc, char * const argv[])serial_setbrg ();udelay (50000 ); -for (;;) { -if (getc () =='\r' ) -break ; - } +while (getc () !='\r' ) + ; } }/* Delete only ? */ -if ((argc <3 ) || argv[2 ] ==NULL ) { +if (argc <3 || argv[2 ] ==NULL ) {int rc =hdelete_r (name, &env_htab);return !rc; }
@@ -323,13 +322,13 @@ int _do_env_set (int flag, int argc, char * const argv[])while ((*s++ = *v++) !='\0' ) ; - *(s-1 ) =' ' ; + *(s -1 ) =' ' ; }if (s != value) *--s ='\0' ; - e.key = name; - e.data = value; + e.key = name; + e.data = value;hsearch_r (e,ENTER , &ep, &env_htab);free (value);if (!ep) {
@@ -342,7 +341,6 @@ int _do_env_set (int flag, int argc, char * const argv[])* Some variables should be updated when the corresponding * entry in the environment is changed */ -if (strcmp (name,"ipaddr" ) ==0 ) {char *s = argv[2 ];/* always use only one arg */ char *e;
@@ -351,8 +349,9 @@ int _do_env_set (int flag, int argc, char * const argv[])for (addr =0 , i =0 ; i <4 ; ++i) {ulong val = s ?simple_strtoul (s, &e,10 ) :0 ; addr <<=8 ; - addr |= (val &0xFF ); -if (s) s = (*e) ? e+1 : e; + addr |= val &0xFF ; +if (s) + s = *e ? e +1 : e; } bd->bi_ip_addr =htonl (addr);return 0 ;
@@ -373,7 +372,7 @@ int setenv(const char *varname, const char *varvalue) {const char *const argv[4 ] = {"setenv" , varname, varvalue,NULL }; -if ((varvalue ==NULL ) || (varvalue[0 ] =='\0' )) +if (varvalue ==NULL || varvalue[0 ] =='\0' )return _do_env_set (0 ,2 , (char *const *)argv);else return _do_env_set (0 ,3 , (char *const *)argv);
@@ -452,9 +451,10 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (pos) message[pos++] =' ' ; -strcpy (message+pos, argv[i]); +strcpy (message + pos, argv[i]); pos +=strlen (argv[i]); } + message[pos] ='\0' ; size =simple_strtoul (argv[argc -1 ],NULL ,10 );break ;
@@ -515,20 +515,19 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])*/ char *getenv (const char *name) { -if (gd->flags &GD_FLG_ENV_READY ) {/* after import into hashtable */ +if (gd->flags &GD_FLG_ENV_READY ) {/* after import into hashtable */ ENTRY e, *ep;WATCHDOG_RESET (); - e.key = name; - e.data =NULL ; + e.key = name; + e.data =NULL ;hsearch_r (e,FIND , &ep, &env_htab);return ep ? ep->data :NULL ; }/* restricted capabilities before import */ -if (getenv_f (name, (char *)(gd->env_buf),sizeof (gd->env_buf)) >0 )return (char *)(gd->env_buf);
@@ -542,7 +541,7 @@ int getenv_f(const char *name, char *buf, unsigned len) {int i, nxt; -for (i =0 ;env_get_char (i) !='\0' ; i = nxt+1 ) { +for (i =0 ;env_get_char (i) !='\0' ; i = nxt +1 ) {int val, n;for (nxt = i;env_get_char (nxt) !='\0' ; ++nxt) {
@@ -556,7 +555,8 @@ int getenv_f(const char *name, char *buf, unsigned len)/* found; copy out */ for (n =0 ; n < len; ++n, ++buf) { -if ((*buf =env_get_char (val++)) =='\0' ) + *buf =env_get_char (val++); +if (*buf =='\0' )return n; }
@@ -568,6 +568,7 @@ int getenv_f(const char *name, char *buf, unsigned len)return n; } +return -1 ; }
@@ -592,11 +593,8 @@ ulong getenv_ulong(const char *name, int base, ulong default_val) }#if defined(CONFIG_CMD_SAVEENV ) && !defined(CONFIG_ENV_IS_NOWHERE ) -int do_env_save (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) { -extern char *env_name_spec; -printf ("Saving Environment to %s...\n" , env_name_spec);return saveenv () ?1 :0 ;
@@ -607,7 +605,6 @@ U_BOOT_CMD("save environment variables to persistent storage" ,"" ); -#endif
@@ -616,29 +613,32 @@ U_BOOT_CMD(* * s1 is either a simple 'name', or a 'name=value' pair. * i2 is the environment index for a 'name2=value2' pair. -* If the names match, return the index for the value2, else NULL. +* If the names match, return the index for the value2, else -1. */ -int envmatch (uchar *s1,int i2) {while (*s1 ==env_get_char (i2++))if (*s1++ =='=' )return i2; +if (*s1 =='\0' &&env_get_char (i2-1 ) =='=' )return i2; +return -1 ; } -static int do_env_default (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_env_default (cmd_tbl_t *cmdtp,int flag, +int argc,char *const argv[]) { -if ((argc !=2 ) || (strcmp (argv[1 ],"-f" ) !=0 )) +if (argc !=2 ||strcmp (argv[1 ],"-f" ) !=0 )return cmd_usage (cmdtp);set_default_env ("## Resetting to default environment\n" );return 0 ; } -static int do_env_delete (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_env_delete (cmd_tbl_t *cmdtp,int flag, +int argc,char *const argv[]) {printf ("Not implemented yet\n" );return 0 ;
@@ -686,7 +686,8 @@ static int do_env_delete(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv* * => env import -d -t ${backup_addr} */ -static int do_env_export (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_env_export (cmd_tbl_t *cmdtp,int flag, +int argc,char *const argv[]) {char buf[32 ];char *addr, *cmd, *res;
@@ -740,8 +741,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argvif (sep) {/* export as text file */ len =hexport_r (&env_htab, sep, &addr, size);if (len <0 ) { -error ("Cannot export environment: errno = %d\n" , - errno); +error ("Cannot export environment: errno = %d\n" , errno);return 1 ; }sprintf (buf,"%zX" , (size_t )len);
@@ -759,13 +759,12 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv len =hexport_r (&env_htab,'\0' , &res,ENV_SIZE );if (len <0 ) { -error ("Cannot export environment: errno = %d\n" , - errno); +error ("Cannot export environment: errno = %d\n" , errno);return 1 ; }if (chk) { - envp->crc =crc32 (0 , envp->data,ENV_SIZE ); + envp->crc =crc32 (0 , envp->data,ENV_SIZE );#ifdef CONFIG_ENV_ADDR_REDUND envp->flags =ACTIVE_FLAG ;#endif
@@ -776,8 +775,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argvreturn 0 ; sep_err: -printf ("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n" , - cmd); +printf ("## %s: only one of \"-b\", \"-c\" or \"-t\" allowed\n" , cmd); return 1; }#endif
@@ -795,7 +793,8 @@ sep_err:* size: length of input data; if missing, proper '\0' * termination is mandatory */ -static int do_env_import (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +static int do_env_import (cmd_tbl_t *cmdtp,int flag, +int argc,char *const argv[]) {char *cmd, *addr;char sep ='\n' ;
@@ -893,10 +892,6 @@ sep_err: }#endif -#if defined(CONFIG_CMD_RUN ) -extern int do_run (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); -#endif -/* * New command line interface: "env" command with subcommands */
include/command.h +3 -0
@@ -64,6 +64,9 @@ typedef struct cmd_tbl_s cmd_tbl_t;extern cmd_tbl_t __u_boot_cmd_start;extern cmd_tbl_t __u_boot_cmd_end; +#if defined(CONFIG_CMD_RUN ) +extern int do_run (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +#endif /* common/command.c */ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
include/environment.h +3 -0
@@ -143,6 +143,9 @@ extern unsigned long nand_env_oob_offset;# define ENV_HEADER_SIZE (sizeof(uint32_t))#endif +#if defined(CONFIG_CMD_SAVEENV ) && !defined(CONFIG_ENV_IS_NOWHERE ) +extern char *env_name_spec; +#endif #define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE)
Signature · 1 line
1.7.3.4
PATCH 6/17 env: clean env_nowhere.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_nowhere.c checkpatch warnings, errors and coding style.
--- common/env_nowhere.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
common/env_nowhere.c +5 -5
@@ -31,7 +31,7 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; +env_t *env_ptr;void env_relocate_spec (void ) {
@@ -39,7 +39,7 @@ void env_relocate_spec(void)uchar env_get_char_spec (int index) { -return ( *((uchar *)(gd->env_addr + index)) ); +return *((uchar *)(gd->env_addr + index)); }/*
@@ -49,8 +49,8 @@ uchar env_get_char_spec(int index)*/ int env_init (void ) { - gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_addr = (ulong)&default_environment[0 ]; + gd->env_valid =0 ; -return (0 ); +return 0 ; }
Signature · 1 line
1.7.3.4
PATCH 7/17 env: clean env_mgdisk.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_mgdisk.c checkpatch warnings, errors and coding style.
--- common/env_mgdisk.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
common/env_mgdisk.c +2 -2
@@ -29,13 +29,13 @@char *env_name_spec ="MG_DISK" ; -env_t *env_ptr =0 ; +env_t *env_ptr;DECLARE_GLOBAL_DATA_PTR ;uchar env_get_char_spec (int index) { -return (*((uchar *)(gd->env_addr + index))); +return *((uchar *)(gd->env_addr + index)); }void env_relocate_spec (void )
Signature · 1 line
1.7.3.4
PATCH 8/17 env: clean env_dataflash.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_dataflash.c checkpatch warnings, errors and coding style.
--- common/env_dataflash.c | 32 ++++++++++++-------------------- include/dataflash.h | 2 ++ 2 files changed, 14 insertions(+), 20 deletions(-)
common/env_dataflash.c +12 -20
@@ -27,23 +27,17 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; +env_t *env_ptr; -char * env_name_spec ="dataflash" ; - -extern int read_dataflash (unsigned long addr,unsigned long size, -char *result); -extern int write_dataflash (unsigned long addr_dest, -unsigned long addr_src,unsigned long size); -extern int AT91F_DataflashInit (void ); +char *env_name_spec ="dataflash" ;uchar env_get_char_spec (int index) {uchar c; -read_dataflash (CONFIG_ENV_ADDR + index + offsetof(env_t ,data), +read_dataflash (CONFIG_ENV_ADDR + index + offsetof(env_t , data),1 , (char *)&c); -return (c); +return c; }void env_relocate_spec (void )
@@ -71,7 +65,7 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno);return 1 ; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); return write_dataflash(CONFIG_ENV_ADDR, (unsigned long)&env_new,
@@ -86,7 +80,7 @@ int saveenv(void)*/ int env_init (void ) { -ulong crc, len, new; +ulong crc, len =ENV_SIZE , new =0 ;unsigned off;uchar buf[64 ];
@@ -99,25 +93,23 @@ int env_init(void)read_dataflash (CONFIG_ENV_ADDR + offsetof(env_t , crc),sizeof (ulong), (char *)&crc); - new =0 ; - len =ENV_SIZE ; - off = offsetof(env_t ,data); + off = offsetof(env_t , data);while (len >0 ) {int n = (len >sizeof (buf)) ?sizeof (buf) : len;read_dataflash (CONFIG_ENV_ADDR + off, n, (char *)buf); - new =crc32 (new, buf, n); + new =crc32 (new, buf, n); len -= n; off += n; }if (crc == new) { - gd->env_addr = offsetof(env_t ,data); - gd->env_valid =1 ; + gd->env_addr = offsetof(env_t , data); + gd->env_valid =1 ; }else { - gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_addr = (ulong)&default_environment[0 ]; + gd->env_valid =0 ; }return 0 ;
include/dataflash.h +2 -0
@@ -208,6 +208,8 @@ extern int dataflash_real_protect (int flag, unsigned long start_addr, unsignedextern int addr_dataflash (unsigned long addr);extern int read_dataflash (unsigned long addr,unsigned long size,char *result);extern int write_dataflash (unsigned long addr,unsigned long dest,unsigned long size); +extern int AT91F_DataflashInit (void ); +extern void dataflash_print_info (void );extern void dataflash_perror (int err);extern void AT91F_DataflashSetEnv (void );
Signature · 1 line
1.7.3.4
PATCH 9/17 env: clean env_onenand.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_onenand.c checkpatch warnings, errors and coding style.
--- common/env_onenand.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
common/env_onenand.c +5 -7
@@ -31,14 +31,12 @@#include <malloc.h> #include <search.h> #include <errno.h> +#include <onenand_uboot.h> #include <linux/mtd/compat.h> #include <linux/mtd/mtd.h> #include <linux/mtd/onenand.h> -extern struct mtd_info onenand_mtd; -extern struct onenand_chip onenand_chip; -char *env_name_spec ="OneNAND" ;#define ONENAND_MAX_ENV_SIZE 4096
@@ -48,7 +46,7 @@ DECLARE_GLOBAL_DATA_PTR;uchar env_get_char_spec (int index) { -return (*((uchar *)(gd->env_addr + index))); +return *((uchar *)(gd->env_addr + index)); }void env_relocate_spec (void )
@@ -76,7 +74,7 @@ void env_relocate_spec(void)if (mtd->writesize)/* Ignore read fail */ mtd->read (mtd, env_addr,ONENAND_MAX_ENV_SIZE , - &retlen, (u_char *)buf); + &retlen, (u_char *)buf);else mtd->writesize =MAX_ONENAND_PAGESIZE ;#endif /* !ENV_IS_EMBEDDED */
@@ -126,7 +124,7 @@ int saveenv(void) }if (mtd->write (mtd, env_addr,ONENAND_MAX_ENV_SIZE , &retlen, - (u_char *)&env_new)) { + (u_char *)&env_new)) {printf ("OneNAND: write failed at 0x%llx\n" , instr.addr);return 2 ; }
@@ -137,7 +135,7 @@ int saveenv(void)int env_init (void ) {/* use default */ - gd->env_addr = (ulong) & default_environment[0 ]; + gd->env_addr = (ulong)&default_environment[0 ]; gd->env_valid =1 ;return 0 ;
Signature · 1 line
1.7.3.4
PATCH 10/17 env: clean env_nvram.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_nvram.c checkpatch warnings, errors and coding style. There are 2 wanring left about the extern used in c file:
WARNING: externs should be avoided in .c files
#53: FILE: env_nvram.c:53:
+extern void *nvram_read(void *dest, const long src, size_t count);
WARNING: externs should be avoided in .c files
#54: FILE: env_nvram.c:54:
+extern void nvram_write(long dest, const void *src, size_t count);
total: 0 errors, 2 warnings, 138 lines checked
There is no common nvram header file to use instead of the externs.
--- common/env_nvram.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
common/env_nvram.c +12 -12
@@ -52,19 +52,19 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE extern void *nvram_read (void *dest,const long src,size_t count);extern void nvram_write (long dest,const void *src,size_t count); -env_t *env_ptr =NULL ; +env_t *env_ptr;#else env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR ;#endif -char * env_name_spec ="NVRAM" ; +char *env_name_spec ="NVRAM" ;uchar env_get_char_spec (int index) {#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE uchar c; -nvram_read (&c,CONFIG_ENV_ADDR +index,1 ); +nvram_read (&c,CONFIG_ENV_ADDR + index,1 );return c;#else
@@ -79,7 +79,7 @@ void env_relocate_spec(void)#if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE )nvram_read (buf,CONFIG_ENV_ADDR ,CONFIG_ENV_SIZE );#else -memcpy (buf, (void *)CONFIG_ENV_ADDR ,CONFIG_ENV_SIZE ); +memcpy (buf, (void *)CONFIG_ENV_ADDR ,CONFIG_ENV_SIZE );#endif env_import (buf,1 ); }
@@ -108,7 +108,6 @@ int saveenv(void)return rcode; } -/* * Initialize Environment use *
@@ -121,18 +120,19 @@ int env_init(void)uchar data[ENV_SIZE ];nvram_read (&crc,CONFIG_ENV_ADDR ,sizeof (ulong)); -nvram_read (data,CONFIG_ENV_ADDR +sizeof (ulong),ENV_SIZE ); +nvram_read (data,CONFIG_ENV_ADDR +sizeof (ulong),ENV_SIZE );if (crc32 (0 , data,ENV_SIZE ) == crc) { - gd->env_addr = (ulong )CONFIG_ENV_ADDR +sizeof (long ); + gd->env_addr = (ulong )CONFIG_ENV_ADDR +sizeof (long );#else if (crc32 (0 , env_ptr->data,ENV_SIZE ) == env_ptr->crc) { - gd->env_addr = (ulong)&(env_ptr->data); + gd->env_addr = (ulong)&env_ptr->data;#endif - gd->env_valid =1 ; + gd->env_valid =1 ; }else { - gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =0 ; + gd->env_addr = (ulong)&default_environment[0 ]; + gd->env_valid =0 ; } -return (0 ); + +return 0 ; }
Signature · 1 line
1.7.3.4
PATCH 11/17 env: clean env_mmc.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_mmc.c checkpatch warnings, errors and coding style. Simplify env_relocate_spec() function implementation. Also mark internal functions as static.
--- common/env_mmc.c | 72 +++++++++++++++++------------------------------------ 1 files changed, 23 insertions(+), 49 deletions(-)
common/env_mmc.c +23 -49
@@ -37,14 +37,9 @@ char *env_name_spec = "MMC";#ifdef ENV_IS_EMBEDDED env_t *env_ptr = &environment;#else /* ! ENV_IS_EMBEDDED */ -env_t *env_ptr =NULL ; +env_t *env_ptr;#endif /* ENV_IS_EMBEDDED */ -/* local functions */ -#if !defined(ENV_IS_EMBEDDED ) -static void use_default (void ); -#endif -DECLARE_GLOBAL_DATA_PTR ;#if !defined(CONFIG_ENV_OFFSET )
@@ -56,9 +51,8 @@ static int __mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) *env_addr =CONFIG_ENV_OFFSET ;return 0 ; } -__attribute__((weak,alias ("__mmc_get_env_addr" ))) -int mmc_get_env_addr (struct mmc *mmc,u32 *env_addr); - +int mmc_get_env_addr (struct mmc *mmc,u32 *env_addr) + __attribute__((weak,alias ("__mmc_get_env_addr" )));uchar env_get_char_spec (int index) {
@@ -68,13 +62,13 @@ uchar env_get_char_spec(int index)int env_init (void ) {/* use default */ - gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =1 ; + gd->env_addr = (ulong)&default_environment[0 ]; + gd->env_valid =1 ;return 0 ; } -int init_mmc_for_env (struct mmc *mmc) +static int init_mmc_for_env (struct mmc *mmc) {if (!mmc) {puts ("No MMC card found\n" );
@@ -83,21 +77,20 @@ int init_mmc_for_env(struct mmc *mmc)if (mmc_init (mmc)) {puts ("MMC init failed\n" ); -return -1 ; +return -1 ; }return 0 ; }#ifdef CONFIG_CMD_SAVEENV - -inline int write_env (struct mmc *mmc,unsigned long size, -unsigned long offset,const void *buffer) +static inline int write_env (struct mmc *mmc,unsigned long size, +unsigned long offset,const void *buffer) {uint blk_start, blk_cnt, n; - blk_start =ALIGN (offset, mmc->write_bl_len) / mmc->write_bl_len; - blk_cnt =ALIGN (size, mmc->write_bl_len) / mmc->write_bl_len; + blk_start =ALIGN (offset, mmc->write_bl_len) / mmc->write_bl_len; + blk_cnt =ALIGN (size, mmc->write_bl_len) / mmc->write_bl_len; n = mmc->block_dev.block_write (CONFIG_SYS_MMC_ENV_DEV , blk_start, blk_cnt, (u_char *)buffer);
@@ -111,12 +104,9 @@ int saveenv(void)ssize_t len;char *res;struct mmc *mmc =find_mmc_device (CONFIG_SYS_MMC_ENV_DEV ); -u32 offset; +u32 offset; -if (init_mmc_for_env (mmc)) -return 1 ; - -if (mmc_get_env_addr (mmc, &offset)) +if (init_mmc_for_env (mmc) ||mmc_get_env_addr (mmc, &offset))return 1 ; res = (char *)&env_new.data;
@@ -125,7 +115,8 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno);return 1 ; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE );printf ("Writing to MMC(%d)... " ,CONFIG_SYS_MMC_ENV_DEV );if (write_env (mmc,CONFIG_ENV_SIZE , offset, (u_char *)&env_new)) {puts ("failed\n" );
@@ -137,13 +128,13 @@ int saveenv(void) }#endif /* CONFIG_CMD_SAVEENV */ -inline int read_env (struct mmc *mmc,unsigned long size, -unsigned long offset,const void *buffer) +static inline int read_env (struct mmc *mmc,unsigned long size, +unsigned long offset,const void *buffer) {uint blk_start, blk_cnt, n; - blk_start =ALIGN (offset, mmc->read_bl_len) / mmc->read_bl_len; - blk_cnt =ALIGN (size, mmc->read_bl_len) / mmc->read_bl_len; + blk_start =ALIGN (offset, mmc->read_bl_len) / mmc->read_bl_len; + blk_cnt =ALIGN (size, mmc->read_bl_len) / mmc->read_bl_len; n = mmc->block_dev.block_read (CONFIG_SYS_MMC_ENV_DEV , blk_start, blk_cnt, (uchar *)buffer);
@@ -155,32 +146,15 @@ void env_relocate_spec(void) {#if !defined(ENV_IS_EMBEDDED )char buf[CONFIG_ENV_SIZE ]; -struct mmc *mmc =find_mmc_device (CONFIG_SYS_MMC_ENV_DEV );u32 offset; -if (init_mmc_for_env (mmc)) { -use_default (); -return ; - } +if (init_mmc_for_env (mmc) ||mmc_get_env_addr (mmc, &offset)) +return set_default_env (NULL ); -if (mmc_get_env_addr (mmc, &offset)) { -use_default (); -return ; - } - -if (read_env (mmc,CONFIG_ENV_SIZE , offset, buf)) { -use_default (); -return ; - } +if (read_env (mmc,CONFIG_ENV_SIZE , offset, buf)) +return set_default_env (NULL );env_import (buf,1 );#endif } - -#if !defined(ENV_IS_EMBEDDED ) -static void use_default () -{ -set_default_env (NULL ); -} -#endif
Signature · 1 line
1.7.3.4
PATCH 12/17 env: clean env_embedded.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_embedded.c checkpatch warnings, errors and coding style. There is one error left though:
ERROR: Macros with multiple statements should be enclosed in a do - while loop #79: FILE: u-boot/common/env_embedded.c:79:
+#define GEN_ABS(name, value) \
+ asm(".globl " GEN_SYMNAME(name)); \
+ GEN_SET_VALUE(name, value)
total: 1 errors, 0 warnings, 213 lines checked
We cannot enclose that statement in a do - while loop, because these are a global assembly declarations.
--- common/env_embedded.c | 47 +++++++++++++++++++++++------------------------ 1 files changed, 23 insertions(+), 24 deletions(-)
common/env_embedded.c +23 -24
@@ -22,17 +22,14 @@*/ #ifndef __ASSEMBLY__ -#define __ASSEMBLY__/* Dirty trick to get only #defines */ +#define __ASSEMBLY__/* Dirty trick to get only #defines */ #endif -#define __ASM_STUB_PROCESSOR_H__/* don't include asm/processor. */ +#define __ASM_STUB_PROCESSOR_H__/* don't include asm/processor. */ #include <config.h> #undef __ASSEMBLY__#include <environment.h> -/* -* Handle HOSTS that have prepended -* crap on symbol names, not TARGETS. -*/ +/* Handle HOSTS that have prepended crap on symbol names, not TARGETS. */ #if defined(__APPLE__)/* Leading underscore on symbols */ # define SYM_CHAR "_"
@@ -52,34 +49,36 @@* U-Boot itself. */ #if (defined(CONFIG_SYS_USE_PPCENV ) || defined(CONFIG_NAND_U_BOOT )) && \ - defined(ENV_CRC )/* Environment embedded in U-Boot .ppcenv section */ + defined(ENV_CRC )/* Environment embedded in U-Boot .ppcenv section */ /* XXX - This only works with GNU C */ -# define __PPCENV__ __attribute__ ((section(".ppcenv"))) -# define __PPCTEXT__ __attribute__ ((section(".text"))) +# define __PPCENV__ __attribute__ ((section(".ppcenv"))) +# define __PPCTEXT__ __attribute__ ((section(".text")))#elif defined(USE_HOSTCC )/* Native for 'tools/envcrc' */ -# define __PPCENV__/*XXX DO_NOT_DEL_THIS_COMMENT*/ -# define __PPCTEXT__/*XXX DO_NOT_DEL_THIS_COMMENT*/ +# define __PPCENV__/*XXX DO_NOT_DEL_THIS_COMMENT*/ +# define __PPCTEXT__/*XXX DO_NOT_DEL_THIS_COMMENT*/ #else /* Environment is embedded in U-Boot's .text section */ /* XXX - This only works with GNU C */ -# define __PPCENV__ __attribute__ ((section(".text"))) -# define __PPCTEXT__ __attribute__ ((section(".text"))) +# define __PPCENV__ __attribute__ ((section(".text"))) +# define __PPCTEXT__ __attribute__ ((section(".text")))#endif /* * Macros to generate global absolutes. */ #if defined(__bfin__) -# define GEN_SET_VALUE (name, value) asm (".set " GEN_SYMNAME(name) ", " GEN_VALUE(value)) +# define GEN_SET_VALUE (name, value) \ + asm(".set " GEN_SYMNAME(name) ", " GEN_VALUE(value))#else -# define GEN_SET_VALUE (name, value) asm (GEN_SYMNAME(name) " = " GEN_VALUE(value)) -#endif -#define GEN_SYMNAME (str) SYM_CHAR #str -#define GEN_VALUE (str) #str -#define GEN_ABS (name, value) \ - asm (".globl " GEN_SYMNAME(name)); \ - GEN_SET_VALUE(name, value) +# define GEN_SET_VALUE (name, value) \ + asm(GEN_SYMNAME(name) " = " GEN_VALUE(value)) +#endif +#define GEN_SYMNAME (str) SYM_CHAR #str +#define GEN_VALUE (str) #str +#define GEN_ABS (name, value) \ + asm(".globl " GEN_SYMNAME(name)); \ + GEN_SET_VALUE(name, value)/* * Macros to transform values
@@ -93,7 +92,7 @@* computed CRC. Otherwise define it as ~0. */ #if !defined(ENV_CRC ) -# define ENV_CRC ~0 +# define ENV_CRC (~0)#endif env_t environment __PPCENV__ = {
@@ -151,7 +150,7 @@ env_t environment __PPCENV__ = { "serverip=" MK_STR(CONFIG_SERVERIP) "\0"#endif #ifdef CONFIG_SYS_AUTOLOAD - "autoload=" CONFIG_SYS_AUTOLOAD "\0" + "autoload=" CONFIG_SYS_AUTOLOAD "\0"#endif #ifdef CONFIG_ROOTPATH "rootpath=" CONFIG_ROOTPATH "\0"
@@ -180,7 +179,7 @@ env_t environment __PPCENV__ = {#if defined(CONFIG_PCI_BOOTDELAY ) && (CONFIG_PCI_BOOTDELAY >0 ) "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0"#endif -#ifdef CONFIG_EXTRA_ENV_SETTINGS +#ifdef CONFIG_EXTRA_ENV_SETTINGS CONFIG_EXTRA_ENV_SETTINGS#endif "\0" /* Term. env_t.data with 2 NULs */
Signature · 1 line
1.7.3.4
PATCH 13/17 env: clean env_eeprom.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_eeprom.c checkpatch warnings, errors and coding style.
--- common/env_eeprom.c | 104 ++++++++++++++++++++++---------------------------- 1 files changed, 46 insertions(+), 58 deletions(-)
common/env_eeprom.c +46 -58
@@ -37,13 +37,13 @@DECLARE_GLOBAL_DATA_PTR ; -env_t *env_ptr =NULL ; +env_t *env_ptr;char *env_name_spec ="EEPROM" ;int env_eeprom_bus =-1 ;static int eeprom_bus_read (unsigned dev_addr,unsigned offset, -uchar *buffer,unsigned cnt) +uchar *buffer,unsigned cnt) {int rcode;#if defined(CONFIG_I2C_ENV_EEPROM_BUS )
@@ -57,7 +57,7 @@ static int eeprom_bus_read(unsigned dev_addr, unsigned offset,if (dev !=NULL ) env_eeprom_bus = dev->busid;else -printf ("error adding env eeprom bus.\n" ); +printf ("error adding env eeprom bus.\n" ); }if (old_bus != env_eeprom_bus) {i2c_set_bus_num (env_eeprom_bus);
@@ -69,7 +69,7 @@ static int eeprom_bus_read(unsigned dev_addr, unsigned offset, }#endif - rcode =eeprom_read (dev_addr, offset, buffer, cnt); + rcode =eeprom_read (dev_addr, offset, buffer, cnt);#if defined(CONFIG_I2C_ENV_EEPROM_BUS )if (old_bus != env_eeprom_bus)
@@ -79,7 +79,7 @@ static int eeprom_bus_read(unsigned dev_addr, unsigned offset, }static int eeprom_bus_write (unsigned dev_addr,unsigned offset, -uchar *buffer,unsigned cnt) +uchar *buffer,unsigned cnt) {int rcode;#if defined(CONFIG_I2C_ENV_EEPROM_BUS )
@@ -94,24 +94,22 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,return rcode; } -uchar env_get_char_spec (int index) +uchar env_get_char_spec (int index) {uchar c; -unsigned int off; - off =CONFIG_ENV_OFFSET ; +unsigned int off =CONFIG_ENV_OFFSET ;#ifdef CONFIG_ENV_OFFSET_REDUND if (gd->env_valid ==2 ) off =CONFIG_ENV_OFFSET_REDUND ;#endif eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , - off + index + offsetof(env_t ,data), - &c,1 ); + off + index + offsetof(env_t , data), &c,1 ); -return (c); +return c; } -void env_relocate_spec (void ) +void env_relocate_spec (void ) {char buf[CONFIG_ENV_SIZE ];unsigned int off =CONFIG_ENV_OFFSET ;
@@ -121,9 +119,7 @@ void env_relocate_spec (void) off =CONFIG_ENV_OFFSET_REDUND ;#endif eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , - off, - (uchar *)buf, -CONFIG_ENV_SIZE ); + off, (uchar *)buf,CONFIG_ENV_SIZE );env_import (buf,1 ); }
@@ -133,11 +129,11 @@ int saveenv(void)env_t env_new;ssize_t len;char *res; -int rc; -unsigned int off =CONFIG_ENV_OFFSET ; +int rc; +unsigned int off =CONFIG_ENV_OFFSET ;#ifdef CONFIG_ENV_OFFSET_REDUND -unsigned int off_red =CONFIG_ENV_OFFSET_REDUND ; -char flag_obsolete =OBSOLETE_FLAG ; +unsigned int off_red =CONFIG_ENV_OFFSET_REDUND ; +char flag_obsolete =OBSOLETE_FLAG ;#endif BUG_ON (env_ptr !=NULL );
@@ -152,32 +148,28 @@ int saveenv(void)#ifdef CONFIG_ENV_OFFSET_REDUND if (gd->env_valid ==1 ) { - off =CONFIG_ENV_OFFSET_REDUND ; - off_red =CONFIG_ENV_OFFSET ; + off =CONFIG_ENV_OFFSET_REDUND ; + off_red =CONFIG_ENV_OFFSET ; } env_new.flags =ACTIVE_FLAG ;#endif rc =eeprom_bus_write (CONFIG_SYS_DEF_EEPROM_ADDR , - off, - (uchar *)&env_new, -CONFIG_ENV_SIZE ); + off, (uchar *)&env_new,CONFIG_ENV_SIZE );#ifdef CONFIG_ENV_OFFSET_REDUND if (rc ==0 ) {eeprom_bus_write (CONFIG_SYS_DEF_EEPROM_ADDR , - off_red + offsetof(env_t ,flags), - (uchar *)&flag_obsolete, -1 ); + off_red + offsetof(env_t , flags), + (uchar *)&flag_obsolete,1 ); +if (gd->env_valid ==1 ) gd->env_valid =2 ;else gd->env_valid =1 ; - }#endif -return rc; }
@@ -187,17 +179,13 @@ int saveenv(void)* We are still running from ROM, so data use is limited. * Use a (moderately small) buffer on the stack */ -#ifdef CONFIG_ENV_OFFSET_REDUND int env_init (void ) { -ulong len; -ulong crc[2 ], crc_tmp; +ulong len, crc[2 ], crc_tmp;unsigned int off, off_env[2 ]; -uchar buf[64 ]; -int crc_ok[2 ] = {0 ,0 }; -unsigned char flags[2 ]; -int i; +uchar buf[64 ], flags[2 ]; +int i, crc_ok[2 ] = {0 ,0 };eeprom_init ();/* prepare for EEPROM read/write */
@@ -207,39 +195,39 @@ int env_init(void)for (i =0 ; i <2 ; i++) {/* read CRC */ eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , - off_env[i] + offsetof(env_t ,crc), - (uchar *)&crc[i],sizeof (ulong)); + off_env[i] + offsetof(env_t , crc), + (uchar *)&crc[i],sizeof (ulong));/* read FLAGS */ eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , - off_env[i] + offsetof(env_t ,flags), - (uchar *)&flags[i],sizeof (uchar)); + off_env[i] + offsetof(env_t , flags), + (uchar *)&flags[i],sizeof (uchar)); crc_tmp =0 ; len =ENV_SIZE ; - off = off_env[i] + offsetof(env_t ,data); + off = off_env[i] + offsetof(env_t , data);while (len >0 ) {int n = (len >sizeof (buf)) ?sizeof (buf) : len;eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , off, - buf, n); + buf, n); crc_tmp =crc32 (crc_tmp, buf, n); len -= n; off += n; } +if (crc_tmp == crc[i]) crc_ok[i] =1 ; }if (!crc_ok[0 ] && !crc_ok[1 ]) { - gd->env_addr =0 ; - gd->env_valid =0 ; + gd->env_addr =0 ; + gd->env_valid =0 ;return 0 ; }else if (crc_ok[0 ] && !crc_ok[1 ]) { gd->env_valid =1 ; - } -else if (!crc_ok[0 ] && crc_ok[1 ]) { + }else if (!crc_ok[0 ] && crc_ok[1 ]) { gd->env_valid =2 ; }else {/* both ok - check serial */
@@ -249,18 +237,18 @@ int env_init(void) gd->env_valid =2 ; else if (flags[0] == 0xFF && flags[1] == 0) gd->env_valid =2 ; - else if(flags[1] == 0xFF && flags[0] == 0) + else if (flags[1] == 0xFF && flags[0] == 0) gd->env_valid =1 ; else /* flags are equal - almost impossible */ gd->env_valid = 1; }if (gd->env_valid ==2 ) - gd->env_addr = off_env[1 ] + offsetof(env_t ,data); + gd->env_addr = off_env[1 ] + offsetof(env_t , data);else if (gd->env_valid ==1 ) - gd->env_addr = off_env[0 ] + offsetof(env_t ,data); + gd->env_addr = off_env[0 ] + offsetof(env_t , data); -return (0 ); +return 0 ; }#else int env_init (void )
@@ -273,12 +261,12 @@ int env_init(void)/* read old CRC */ eeprom_bus_read (CONFIG_SYS_DEF_EEPROM_ADDR , -CONFIG_ENV_OFFSET +offsetof(env_t ,crc), - (uchar *)&crc,sizeof (ulong)); +CONFIG_ENV_OFFSET + offsetof(env_t , crc), + (uchar *)&crc,sizeof (ulong)); new =0 ; len =ENV_SIZE ; - off = offsetof(env_t ,data); + off = offsetof(env_t , data);while (len >0 ) {int n = (len >sizeof (buf)) ?sizeof (buf) : len;
@@ -291,13 +279,13 @@ int env_init(void) }if (crc == new) { - gd->env_addr = offsetof(env_t ,data); - gd->env_valid =1 ; + gd->env_addr = offsetof(env_t , data); + gd->env_valid =1 ; }else { - gd->env_addr =0 ; - gd->env_valid =0 ; + gd->env_addr =0 ; + gd->env_valid =0 ; } -return (0 ); +return 0 ; }#endif
Signature · 1 line
1.7.3.4
PATCH 14/17 env: clean env_sf.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_sf.c checkpatch warnings, errors and coding style.
--- common/env_sf.c | 48 ++++++++++++++++++++---------------------------- 1 files changed, 20 insertions(+), 28 deletions(-)
common/env_sf.c +20 -28
@@ -36,7 +36,7 @@# define CONFIG_ENV_SPI_BUS 0#endif #ifndef CONFIG_ENV_SPI_CS -# define CONFIG_ENV_SPI_CS 0 +# define CONFIG_ENV_SPI_CS 0#endif #ifndef CONFIG_ENV_SPI_MAX_HZ # define CONFIG_ENV_SPI_MAX_HZ 1000000
@@ -46,16 +46,16 @@#endif #ifdef CONFIG_ENV_OFFSET_REDUND -static ulong env_offset =CONFIG_ENV_OFFSET ; -static ulong env_new_offset =CONFIG_ENV_OFFSET_REDUND ; +static ulong env_offset =CONFIG_ENV_OFFSET ; +static ulong env_new_offset =CONFIG_ENV_OFFSET_REDUND ; -#define ACTIVE_FLAG 1 -#define OBSOLETE_FLAG 0 +#define ACTIVE_FLAG 1 +#define OBSOLETE_FLAG 0#endif /* CONFIG_ENV_OFFSET_REDUND */ DECLARE_GLOBAL_DATA_PTR ; -char * env_name_spec ="SPI Flash" ; +char *env_name_spec ="SPI Flash" ;static struct spi_flash *env_flash;
@@ -65,17 +65,13 @@ uchar env_get_char_spec(int index) }#if defined(CONFIG_ENV_OFFSET_REDUND ) -int saveenv (void ) {env_t env_new;ssize_t len; -char *res; -u32 saved_size, saved_offset; -char *saved_buffer =NULL ; -u32 sector =1 ; +char *res, *saved_buffer =NULL , flag =OBSOLETE_FLAG ; +u32 saved_size, saved_offset, sector =1 ;int ret; -char flag =OBSOLETE_FLAG ;if (!env_flash) { env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
@@ -93,8 +89,8 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno);return 1 ; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); - env_new.flags =ACTIVE_FLAG ; + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + env_new.flags =ACTIVE_FLAG ;if (gd->env_valid ==1 ) { env_new_offset =CONFIG_ENV_OFFSET_REDUND ;
@@ -145,21 +141,21 @@ int saveenv(void) goto done; } - ret =spi_flash_write (env_flash, - env_offset + offsetof(env_t , flags), -sizeof (env_new.flags), &flag); + ret =spi_flash_write (env_flash, env_offset + offsetof(env_t , flags), +sizeof (env_new.flags), &flag);if (ret) goto done;puts ("done\n" ); - gd->env_valid = (gd->env_valid ==2 ?1 :2 ); + gd->env_valid = gd->env_valid ==2 ?1 :2 ;printf ("Valid environment: %d\n" , (int )gd->env_valid); done:if (saved_buffer)free (saved_buffer); +return ret; }
@@ -245,18 +241,14 @@ err_read: out:free (tmp_env1); free(tmp_env2); - - return; }#else int saveenv (void ) { -u32 saved_size, saved_offset; -char *saved_buffer =NULL ; -u32 sector =1 ; -int ret =1 ; +u32 saved_size, saved_offset, sector =1 ; +char *res, *saved_buffer =NULL ; +int ret =1 ;env_t env_new; -char *res;ssize_t len;if (!env_flash) {
@@ -274,9 +266,9 @@ int saveenv(void) saved_size =CONFIG_ENV_SECT_SIZE -CONFIG_ENV_SIZE ; saved_offset =CONFIG_ENV_OFFSET +CONFIG_ENV_SIZE ; saved_buffer =malloc (saved_size); -if (!saved_buffer) { +if (!saved_buffer) goto done; - } + ret =spi_flash_read (env_flash, saved_offset, saved_size, saved_buffer);if (ret)
@@ -322,6 +314,7 @@ int saveenv(void) done:if (saved_buffer)free (saved_buffer); +return ret; }
@@ -345,7 +338,6 @@ void env_relocate_spec(void) } ret =env_import (buf,1 ); -if (ret) gd->env_valid =1 ; out:
Signature · 1 line
1.7.3.4
PATCH 15/17 env: clean env_flash.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_flash.c checkpatch warnings, errors and coding style.
--- common/env_flash.c | 175 +++++++++++++++++++++++++--------------------------- 1 files changed, 84 insertions(+), 91 deletions(-)
common/env_flash.c +84 -91
@@ -39,14 +39,15 @@ DECLARE_GLOBAL_DATA_PTR;#if defined(CONFIG_CMD_SAVEENV ) && defined(CONFIG_CMD_FLASH )#define CMD_SAVEENV #elif defined(CONFIG_ENV_ADDR_REDUND ) -#error Cannot use CONFIG_ENV_ADDR_REDUND without CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH +#error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH#endif -#if defined(CONFIG_ENV_SIZE_REDUND ) && (CONFIG_ENV_SIZE_REDUND <CONFIG_ENV_SIZE ) +#if defined(CONFIG_ENV_SIZE_REDUND ) && \ + (CONFIG_ENV_SIZE_REDUND <CONFIG_ENV_SIZE )#error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE#endif -char * env_name_spec ="Flash" ; +char *env_name_spec ="Flash" ;#ifdef ENV_IS_EMBEDDED env_t *env_ptr = &environment;
@@ -57,7 +58,6 @@ static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR ;static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR ; -#endif /* ENV_IS_EMBEDDED */ #if defined(CMD_SAVEENV ) || defined(CONFIG_ENV_ADDR_REDUND )
@@ -75,12 +75,11 @@ static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;uchar env_get_char_spec (int index) { -return (*((uchar *)(gd->env_addr + index))); +return *((uchar *)(gd->env_addr + index)); }#ifdef CONFIG_ENV_ADDR_REDUND - -int env_init (void ) +int env_init (void ) {int crc1_ok =0 , crc2_ok =0 ;
@@ -91,33 +90,34 @@ int env_init(void)ulong addr1 = (ulong)&(flash_addr->data);ulong addr2 = (ulong)&(flash_addr_new->data); - crc1_ok = (crc32 (0 , flash_addr->data,ENV_SIZE ) == flash_addr->crc); - crc2_ok = (crc32 (0 , flash_addr_new->data,ENV_SIZE ) == flash_addr_new->crc); - -if (crc1_ok && ! crc2_ok) { - gd->env_addr = addr1; - gd->env_valid =1 ; - }else if (! crc1_ok && crc2_ok) { - gd->env_addr = addr2; - gd->env_valid =1 ; - }else if (! crc1_ok && ! crc2_ok) { - gd->env_addr = addr_default; - gd->env_valid =0 ; + crc1_ok =crc32 (0 , flash_addr->data,ENV_SIZE ) == flash_addr->crc; + crc2_ok = +crc32 (0 , flash_addr_new->data,ENV_SIZE ) == flash_addr_new->crc; + +if (crc1_ok && !crc2_ok) { + gd->env_addr = addr1; + gd->env_valid =1 ; + }else if (!crc1_ok && crc2_ok) { + gd->env_addr = addr2; + gd->env_valid =1 ; + }else if (!crc1_ok && !crc2_ok) { + gd->env_addr = addr_default; + gd->env_valid =0 ; }else if (flag1 ==ACTIVE_FLAG && flag2 ==OBSOLETE_FLAG ) { - gd->env_addr = addr1; - gd->env_valid =1 ; + gd->env_addr = addr1; + gd->env_valid =1 ; }else if (flag1 ==OBSOLETE_FLAG && flag2 ==ACTIVE_FLAG ) { - gd->env_addr = addr2; - gd->env_valid =1 ; + gd->env_addr = addr2; + gd->env_valid =1 ; }else if (flag1 == flag2) { - gd->env_addr = addr1; - gd->env_valid =2 ; + gd->env_addr = addr1; + gd->env_valid =2 ; }else if (flag1 ==0xFF ) { - gd->env_addr = addr1; - gd->env_valid =2 ; + gd->env_addr = addr1; + gd->env_valid =2 ; }else if (flag2 ==0xFF ) { - gd->env_addr = addr2; - gd->env_valid =2 ; + gd->env_addr = addr2; + gd->env_valid =2 ; }return 0 ;
@@ -128,27 +128,23 @@ int saveenv(void) {env_t env_new;ssize_t len; -char *saved_data =NULL ; -char *res; -int rc =1 ; +char *res, *saved_data =NULL ;char flag =OBSOLETE_FLAG , new_flag =ACTIVE_FLAG ; +int rc =1 ;#if CONFIG_ENV_SECT_SIZE >CONFIG_ENV_SIZE ulong up_data =0 ;#endif -debug ("Protect off %08lX ... %08lX\n" , - (ulong )flash_addr, end_addr); +debug ("Protect off %08lX ... %08lX\n" , (ulong )flash_addr, end_addr); -if (flash_sect_protect (0 , (ulong )flash_addr, end_addr)) { +if (flash_sect_protect (0 , (ulong )flash_addr, end_addr)) goto done; - }debug ("Protect off %08lX ... %08lX\n" , (ulong )flash_addr_new, end_addr_new); -if (flash_sect_protect (0 , (ulong )flash_addr_new, end_addr_new)) { +if (flash_sect_protect (0 , (ulong )flash_addr_new, end_addr_new)) goto done; - } res = (char *)&env_new.data; len =hexport_r (&env_htab,'\0' , &res,ENV_SIZE );
@@ -156,46 +152,46 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno); goto done; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); - env_new.flags = new_flag; + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + env_new.flags = new_flag;#if CONFIG_ENV_SECT_SIZE >CONFIG_ENV_SIZE - up_data = (end_addr_new +1 - ((long )flash_addr_new +CONFIG_ENV_SIZE )); + up_data = end_addr_new +1 - ((long )flash_addr_new +CONFIG_ENV_SIZE );debug ("Data to save 0x%lX\n" , up_data);if (up_data) { -if ((saved_data =malloc (up_data)) ==NULL ) { + saved_data =malloc (up_data); +if (saved_data ==NULL ) {printf ("Unable to save the rest of sector (%ld)\n" , up_data); goto done; }memcpy (saved_data, - (void *)((long )flash_addr_new +CONFIG_ENV_SIZE ), up_data); + (void *)((long )flash_addr_new +CONFIG_ENV_SIZE ), + up_data);debug ("Data (start 0x%lX, len 0x%lX) saved at 0x%p\n" , (long )flash_addr_new +CONFIG_ENV_SIZE , up_data, saved_data); }#endif puts ("Erasing Flash..." ); -debug (" %08lX ... %08lX ..." , - (ulong )flash_addr_new, end_addr_new); +debug (" %08lX ... %08lX ..." , (ulong )flash_addr_new, end_addr_new); -if (flash_sect_erase ((ulong )flash_addr_new, end_addr_new)) { +if (flash_sect_erase ((ulong )flash_addr_new, end_addr_new)) goto done; - }puts ("Writing to Flash... " );debug (" %08lX ... %08lX ..." , (ulong)&(flash_addr_new->data), -sizeof (env_ptr->data)+(ulong)&(flash_addr_new->data)); -if ((rc =flash_write ((char *)&env_new, - (ulong )flash_addr_new, -sizeof (env_new))) || - (rc =flash_write (&flag, - (ulong)&(flash_addr->flags), -sizeof (flash_addr->flags))) ) { -flash_perror (rc); - goto done; - } +sizeof (env_ptr->data) + (ulong)&(flash_addr_new->data)); + rc =flash_write ((char *)&env_new, (ulong )flash_addr_new, +sizeof (env_new)); +if (rc) + goto perror; + + rc =flash_write (&flag, (ulong)&(flash_addr->flags), +sizeof (flash_addr->flags)); +if (rc) + goto perror;#if CONFIG_ENV_SECT_SIZE >CONFIG_ENV_SIZE if (up_data) {/* restore the rest of sector */
@@ -203,16 +199,14 @@ int saveenv(void) (long)flash_addr_new + CONFIG_ENV_SIZE, up_data);if (flash_write (saved_data, (long )flash_addr_new +CONFIG_ENV_SIZE , - up_data)) { -flash_perror (rc); - goto done; - } + up_data)) + goto perror; }#endif puts ("done\n" ); { -env_t * etmp = flash_addr; +env_t *etmp = flash_addr;ulong ltmp = end_addr; flash_addr = flash_addr_new;
@@ -223,12 +217,15 @@ int saveenv(void) } rc =0 ; + goto done; +perror: +flash_perror (rc); done:if (saved_data)free (saved_data);/* try to re-protect */ - (void )flash_sect_protect (1 , (ulong )flash_addr, end_addr); - (void )flash_sect_protect (1 , (ulong )flash_addr_new, end_addr_new); +flash_sect_protect (1 , (ulong )flash_addr, end_addr); +flash_sect_protect (1 , (ulong )flash_addr_new, end_addr_new);return rc; }
@@ -236,35 +233,34 @@ done: #else /* ! CONFIG_ENV_ADDR_REDUND */ -int env_init(void) +int env_init(void) { if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) { - gd->env_addr = (ulong)&(env_ptr->data); - gd->env_valid = 1; - return(0); + gd->env_addr = (ulong)&(env_ptr->data); + gd->env_valid = 1; + return 0; } - gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = 0; + gd->env_addr = (ulong)&default_environment[0]; + gd->env_valid = 0; return 0; } #ifdef CMD_SAVEENV - int saveenv(void) { env_t env_new; ssize_t len; int rc = 1; - char *res; - char *saved_data = NULL; + char *res, *saved_data = NULL; #if CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE ulong up_data = 0; - up_data = (end_addr + 1 - ((long)flash_addr + CONFIG_ENV_SIZE)); + up_data = end_addr + 1 - ((long)flash_addr + CONFIG_ENV_SIZE); debug("Data to save 0x%lx\n", up_data); if (up_data) { - if ((saved_data = malloc(up_data)) == NULL) { + saved_data = malloc(up_data); + if (saved_data == NULL) { printf("Unable to save the rest of sector (%ld)\n", up_data); goto done;
@@ -278,8 +274,7 @@ int saveenv(void) }#endif /* CONFIG_ENV_SECT_SIZE */ -debug ("Protect off %08lX ... %08lX\n" , - (ulong )flash_addr, end_addr); +debug ("Protect off %08lX ... %08lX\n" , (ulong )flash_addr, end_addr);if (flash_sect_protect (0 , (long )flash_addr, end_addr)) goto done;
@@ -298,32 +293,31 @@ int saveenv(void)puts ("Writing to Flash... " ); rc =flash_write ((char *)&env_new, (long )flash_addr,CONFIG_ENV_SIZE ); -if (rc !=0 ) { -flash_perror (rc); - goto done; - } +if (rc !=0 ) + goto perror; +#if CONFIG_ENV_SECT_SIZE >CONFIG_ENV_SIZE if (up_data) {/* restore the rest of sector */ debug ("Restoring the rest of data to 0x%lx len 0x%lx\n" , (ulong )flash_addr +CONFIG_ENV_SIZE , up_data);if (flash_write (saved_data, (long )flash_addr +CONFIG_ENV_SIZE , - up_data)) { -flash_perror (rc); - goto done; - } + up_data)) + goto perror; }#endif puts ("done\n" ); rc =0 ; + goto done; +perror: +flash_perror (rc); done:if (saved_data)free (saved_data);/* try to re-protect */ - (void )flash_sect_protect (1 , (long )flash_addr, end_addr); +flash_sect_protect (1 , (long )flash_addr, end_addr);return rc; } -#endif /* CMD_SAVEENV */ #endif /* CONFIG_ENV_ADDR_REDUND */
@@ -343,8 +337,7 @@ void env_relocate_spec(void) }if (flash_addr_new->flags !=OBSOLETE_FLAG && -crc32 (0 , flash_addr_new->data,ENV_SIZE ) == - flash_addr_new->crc) { +crc32 (0 , flash_addr_new->data,ENV_SIZE ) == flash_addr_new->crc) {char flag =OBSOLETE_FLAG ; gd->env_valid =2 ;
@@ -368,8 +361,8 @@ void env_relocate_spec(void) }if (gd->env_valid ==2 ) -puts ("*** Warning - some problems detected " -"reading environment; recovered successfully\n\n" ); +puts ("*** Warning - some problems detected " +"reading environment; recovered successfully\n\n" );#endif /* CONFIG_ENV_ADDR_REDUND */ env_import ((char *)flash_addr,1 );
Signature · 1 line
1.7.3.4
PATCH 16/17 env: clean env_nand.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_nand.c checkpatch warnings, errors and coding style.
--- common/env_nand.c | 99 ++++++++++++++++++++++++---------------------------- 1 files changed, 46 insertions(+), 53 deletions(-)
common/env_nand.c +46 -53
@@ -44,10 +44,11 @@#if defined(CONFIG_CMD_SAVEENV ) && defined(CONFIG_CMD_NAND )#define CMD_SAVEENV #elif defined(CONFIG_ENV_OFFSET_REDUND ) -#error Cannot use CONFIG_ENV_OFFSET_REDUND without CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND +#error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND#endif -#if defined(CONFIG_ENV_SIZE_REDUND ) && (CONFIG_ENV_SIZE_REDUND !=CONFIG_ENV_SIZE ) +#if defined(CONFIG_ENV_SIZE_REDUND ) && \ + (CONFIG_ENV_SIZE_REDUND !=CONFIG_ENV_SIZE )#error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE#endif
@@ -57,20 +58,19 @@char *env_name_spec ="NAND" ; -#if defined(ENV_IS_EMBEDDED )env_t *env_ptr = &environment;#elif defined(CONFIG_NAND_ENV_DST )env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST ;#else /* ! ENV_IS_EMBEDDED */ -env_t *env_ptr =0 ; +env_t *env_ptr;#endif /* ENV_IS_EMBEDDED */ DECLARE_GLOBAL_DATA_PTR ; -uchar env_get_char_spec (int index) +uchar env_get_char_spec (int index) { -return ( *((uchar *)(gd->env_addr + index)) ); +return *((uchar *)(gd->env_addr + index)); }/*
@@ -95,16 +95,14 @@ int env_init(void)env_t *tmp_env2; tmp_env2 = (env_t *)((ulong )env_ptr +CONFIG_ENV_SIZE ); - crc2_ok = (crc32 (0 , tmp_env2->data,ENV_SIZE ) == tmp_env2->crc); + crc2_ok =crc32 (0 , tmp_env2->data,ENV_SIZE ) == tmp_env2->crc;#endif - tmp_env1 = env_ptr; - - crc1_ok = (crc32 (0 , tmp_env1->data,ENV_SIZE ) == tmp_env1->crc); + crc1_ok =crc32 (0 , tmp_env1->data,ENV_SIZE ) == tmp_env1->crc;if (!crc1_ok && !crc2_ok) { - gd->env_addr =0 ; - gd->env_valid =0 ; + gd->env_addr =0 ; + gd->env_valid =0 ;return 0 ; }else if (crc1_ok && !crc2_ok) {
@@ -115,13 +113,13 @@ int env_init(void) gd->env_valid =2 ; }else {/* both ok - check serial */ -if (tmp_env1->flags ==255 && tmp_env2->flags ==0 ) +if (tmp_env1->flags ==255 && tmp_env2->flags ==0 ) gd->env_valid =2 ; -else if (tmp_env2->flags ==255 && tmp_env1->flags ==0 ) +else if (tmp_env2->flags ==255 && tmp_env1->flags ==0 ) gd->env_valid =1 ; -else if (tmp_env1->flags > tmp_env2->flags) +else if (tmp_env1->flags > tmp_env2->flags) gd->env_valid =1 ; -else if (tmp_env2->flags > tmp_env1->flags) +else if (tmp_env2->flags > tmp_env1->flags) gd->env_valid =2 ;else /* flags are equal - almost impossible */ gd->env_valid =1 ;
@@ -137,11 +135,11 @@ int env_init(void) gd->env_addr = (ulong )env_ptr->data;#else /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */ - gd->env_addr = (ulong)&default_environment[0 ]; - gd->env_valid =1 ; + gd->env_addr = (ulong)&default_environment[0 ]; + gd->env_valid =1 ;#endif /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */ -return (0 ); +return 0 ; }#ifdef CMD_SAVEENV
@@ -154,7 +152,6 @@ int writeenv(size_t offset, u_char *buf)size_t end = offset +CONFIG_ENV_RANGE ;size_t amount_saved =0 ;size_t blocksize, len; -u_char *char_ptr; blocksize = nand_info[0 ].erasesize;
@@ -165,9 +162,9 @@ int writeenv(size_t offset, u_char *buf) offset += blocksize; }else { char_ptr = &buf[amount_saved]; -if (nand_write (&nand_info[0 ], offset, &len, - char_ptr)) +if (nand_write (&nand_info[0 ], offset, &len, char_ptr))return 1 ; + offset += blocksize; amount_saved += len; }
@@ -201,18 +198,17 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno);return 1 ; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); - env_new.flags = ++env_flags;/* increase the serial */ + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + env_new.flags = ++env_flags;/* increase the serial */ -if (gd->env_valid ==1 ) { +if (gd->env_valid ==1 ) {puts ("Erasing redundant NAND...\n" ); nand_erase_options.offset =CONFIG_ENV_OFFSET_REDUND ;if (nand_erase_opts (&nand_info[0 ], &nand_erase_options))return 1 ;puts ("Writing to redundant NAND... " ); - ret =writeenv (CONFIG_ENV_OFFSET_REDUND , - (u_char *)&env_new); + ret =writeenv (CONFIG_ENV_OFFSET_REDUND , (u_char *)&env_new); }else {puts ("Erasing NAND...\n" ); nand_erase_options.offset =CONFIG_ENV_OFFSET ;
@@ -220,8 +216,7 @@ int saveenv(void)return 1 ;puts ("Writing to NAND... " ); - ret =writeenv (CONFIG_ENV_OFFSET , - (u_char *)&env_new); + ret =writeenv (CONFIG_ENV_OFFSET , (u_char *)&env_new); }if (ret) {puts ("FAILED!\n" );
@@ -230,14 +225,14 @@ int saveenv(void)puts ("done\n" ); - gd->env_valid = (gd->env_valid ==2 ?1 :2 ); + gd->env_valid = gd->env_valid ==2 ?1 :2 ; return ret; }#else /* ! CONFIG_ENV_OFFSET_REDUND */ int saveenv (void ) { -int ret =0 ; +int ret =0 ;env_t env_new;ssize_t len;char *res;
@@ -256,7 +251,7 @@ int saveenv(void)error ("Cannot export environment: errno = %d\n" , errno);return 1 ; } - env_new.crc =crc32 (0 , env_new.data,ENV_SIZE ); + env_new.crc =crc32 (0 , env_new.data,ENV_SIZE );puts ("Erasing Nand...\n" );if (nand_erase_opts (&nand_info[0 ], &nand_erase_options))
@@ -274,17 +269,17 @@ int saveenv(void)#endif /* CONFIG_ENV_OFFSET_REDUND */ #endif /* CMD_SAVEENV */ -int readenv (size_t offset,u_char * buf) +int readenv (size_t offset,u_char *buf) {size_t end = offset +CONFIG_ENV_RANGE ;size_t amount_loaded =0 ;size_t blocksize, len; -u_char *char_ptr; blocksize = nand_info[0 ].erasesize;if (!blocksize)return 1 ; + len =min (blocksize,CONFIG_ENV_SIZE );while (amount_loaded <CONFIG_ENV_SIZE && offset < end) {
@@ -292,12 +287,15 @@ int readenv(size_t offset, u_char * buf) offset += blocksize; }else { char_ptr = &buf[amount_loaded]; -if (nand_read_skip_bad (&nand_info[0 ], offset, &len, char_ptr)) +if (nand_read_skip_bad (&nand_info[0 ], offset, + &len, char_ptr))return 1 ; + offset += blocksize; amount_loaded += len; } } +if (amount_loaded !=CONFIG_ENV_SIZE )return 1 ;
@@ -308,14 +306,14 @@ int readenv(size_t offset, u_char * buf)int get_nand_env_oob (nand_info_t *nand,unsigned long *result) {struct mtd_oob_ops ops; -uint32_t oob_buf[ENV_OFFSET_SIZE /sizeof (uint32_t )]; +uint32_t oob_buf[ENV_OFFSET_SIZE /sizeof (uint32_t )];int ret; - ops.datbuf =NULL ; - ops.mode =MTD_OOB_AUTO ; - ops.ooboffs =0 ; - ops.ooblen =ENV_OFFSET_SIZE ; - ops.oobbuf = (void *) oob_buf; + ops.datbuf =NULL ; + ops.mode =MTD_OOB_AUTO ; + ops.ooboffs =0 ; + ops.ooblen =ENV_OFFSET_SIZE ; + ops.oobbuf = (void *)oob_buf; ret = nand->read_oob (nand,ENV_OFFSET_SIZE , &ops);if (ret) {
@@ -345,13 +343,10 @@ 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 )) { +if (tmp_env1 ==NULL || tmp_env2 ==NULL ) {puts ("Can't allocate buffers for environment\n" ); -free (tmp_env1); -free (tmp_env2);set_default_env ("!malloc() failed" ); -return ; + goto done; }if (readenv (CONFIG_ENV_OFFSET , (u_char *) tmp_env1))
@@ -360,14 +355,12 @@ void env_relocate_spec(void)if (readenv (CONFIG_ENV_OFFSET_REDUND , (u_char *) tmp_env2))puts ("No Valid Redundant Environment Area found\n" ); - crc1_ok = (crc32 (0 , tmp_env1->data,ENV_SIZE ) == tmp_env1->crc); - crc2_ok = (crc32 (0 , tmp_env2->data,ENV_SIZE ) == tmp_env2->crc); + crc1_ok =crc32 (0 , tmp_env1->data,ENV_SIZE ) == tmp_env1->crc; + crc2_ok =crc32 (0 , tmp_env2->data,ENV_SIZE ) == tmp_env2->crc;if (!crc1_ok && !crc2_ok) { -free (tmp_env1); -free (tmp_env2);set_default_env ("!bad CRC" ); -return ; + goto done; }else if (crc1_ok && !crc2_ok) { gd->env_valid =1 ; }else if (!crc1_ok && crc2_ok) {
@@ -384,7 +377,6 @@ void env_relocate_spec(void) gd->env_valid =2 ; else /* flags are equal - almost impossible */ gd->env_valid = 1; - }free (env_ptr);
@@ -397,6 +389,7 @@ void env_relocate_spec(void) env_flags = ep->flags;env_import ((char *)ep,0 ); +done:free (tmp_env1);free (tmp_env2);
@@ -408,7 +401,7 @@ void env_relocate_spec(void)* device i.e., nand_dev_desc + 0. This is also the behaviour using * the new NAND code. */ -void env_relocate_spec (void ) +void env_relocate_spec (void ) {#if !defined(ENV_IS_EMBEDDED )int ret;
Signature · 1 line
1.7.3.4
PATCH 17/17 env: clean env_common.c checkpatch and code style
In reply to Igor GrinbergCleanup the env_common.c checkpatch warnings, errors and coding style.
--- common/env_common.c | 52 +++++++++++++++++-------------------------------- include/environment.h | 8 +++++++ 2 files changed, 26 insertions(+), 34 deletions(-)
common/env_common.c +18 -34
@@ -34,13 +34,6 @@DECLARE_GLOBAL_DATA_PTR ; -extern env_t *env_ptr; - -extern void env_relocate_spec (void ); -extern uchar env_get_char_spec (int ); - -static uchar env_get_char_init (int index); -/************************************************************************ * Default settings to be used when no valid environment is found */
@@ -94,7 +87,7 @@ const uchar default_environment[] = { "serverip=" MK_STR(CONFIG_SERVERIP) "\0"#endif #ifdef CONFIG_SYS_AUTOLOAD - "autoload=" CONFIG_SYS_AUTOLOAD "\0" + "autoload=" CONFIG_SYS_AUTOLOAD "\0"#endif #ifdef CONFIG_PREBOOT "preboot=" CONFIG_PREBOOT "\0"
@@ -117,13 +110,13 @@ const uchar default_environment[] = {#ifdef CONFIG_LOADADDR "loadaddr=" MK_STR(CONFIG_LOADADDR) "\0"#endif -#ifdef CONFIG_CLOCKS_IN_MHZ +#ifdef CONFIG_CLOCKS_IN_MHZ "clocks_in_mhz=1\0"#endif #if defined(CONFIG_PCI_BOOTDELAY ) && (CONFIG_PCI_BOOTDELAY >0 ) "pcidelay=" MK_STR(CONFIG_PCI_BOOTDELAY) "\0"#endif -#ifdef CONFIG_EXTRA_ENV_SETTINGS +#ifdef CONFIG_EXTRA_ENV_SETTINGS CONFIG_EXTRA_ENV_SETTINGS#endif "\0"
@@ -131,38 +124,30 @@ const uchar default_environment[] = {struct hsearch_data env_htab; -static uchar env_get_char_init (int index) +static uchar env_get_char_init (int index) { -uchar c; -/* if crc was bad, use the default environment */ if (gd->env_valid) - c =env_get_char_spec (index); +return env_get_char_spec (index);else - c = default_environment[index]; - -return (c); +return default_environment[index]; } -uchar env_get_char_memory (int index) +uchar env_get_char_memory (int index) {return *env_get_addr (index); } -uchar env_get_char (int index) +uchar env_get_char (int index) { -uchar c; -/* if relocated to RAM */ if (gd->flags &GD_FLG_RELOC ) - c =env_get_char_memory (index); +return env_get_char_memory (index);else - c =env_get_char_init (index); - -return (c); +return env_get_char_init (index); } -const uchar *env_get_addr (int index) +const uchar *env_get_addr (int index) {if (gd->env_valid)return (uchar *)(gd->env_addr + index);
@@ -181,7 +166,7 @@ void set_default_env(const char *s)if (*s =='!' ) {printf ("*** Warning - %s, " "using default environment\n\n" , - s+1 ); + s +1 ); }else {puts (s); }
@@ -190,9 +175,9 @@ void set_default_env(const char *s) }if (himport_r (&env_htab, (char *)default_environment, -sizeof (default_environment),'\0' ,0 ) ==0 ) { +sizeof (default_environment),'\0' ,0 ) ==0 )error ("Environment import failed: errno = %d\n" , errno); - } + gd->flags |=GD_FLG_ENV_READY ; }
@@ -227,22 +212,20 @@ int env_import(const char *buf, int check)return 0 ; } -void env_relocate (void ) +void env_relocate (void ) {#if defined(CONFIG_NEEDS_MANUAL_RELOC ) -extern void env_reloc (void ); -env_reloc ();#endif if (gd->env_valid ==0 ) {#if defined(CONFIG_ENV_IS_NOWHERE )/* Environment not changable */ set_default_env (NULL );#else -show_boot_progress (-60 ); +show_boot_progress (-60 );set_default_env ("!bad CRC" );#endif }else { -env_relocate_spec (); +env_relocate_spec (); } }
@@ -272,6 +255,7 @@ int env_complete(char *var, int maxv, char *cmdv[], int bufsz, char *buf)if (idx) cmdv[found++] ="..." ; + cmdv[found] =NULL ;return found; }
include/environment.h +8 -0
@@ -162,6 +162,14 @@ extern env_t environment;#endif /* ENV_IS_EMBEDDED */ extern const unsigned char default_environment[]; +extern env_t *env_ptr; + +extern void env_relocate_spec (void ); +extern unsigned char env_get_char_spec (int ); + +#if defined(CONFIG_NEEDS_MANUAL_RELOC ) +extern void env_reloc (void ); +#endif #ifndef DO_DEPS_ONLY
Signature · 1 line
1.7.3.4
cover Cleanup environment related files
In reply to Igor Grinbergping
Quoted 66 lines · Igor Grinberg
This patch series cleans up environment related files in terms of checkpatch and other coding style issues. It is based on Mon, 7 Nov 2011 Wolfgang's master.
There are several warnings/errors left, mostly because I don't think we need those solved or I can't choose the right solution.
Probably, there will be several conflict with the recent patches on the list, so once all issues are fixed,
I can rebase this patch set on top of the most recent master.Thanks to all reviewers :-)
Igor Grinberg (17):
env: cleanenvironment.hcheckpatch and code style
common: move extern char console_buffer[] tocommon.h
env: move extern default_environment[] toenvironment.h
env: move extern environment[] toenvironment.h
env: cleancmd_nvedit.ccheckpatch and code style
env: cleanenv_nowhere.ccheckpatch and code style
env: cleanenv_mgdisk.ccheckpatch and code style
env: cleanenv_dataflash.ccheckpatch and code style
env: cleanenv_onenand.ccheckpatch and code style
env: cleanenv_nvram.ccheckpatch and code style
env: cleanenv_mmc.ccheckpatch and code style
env: cleanenv_embedded.ccheckpatch and code style
env: cleanenv_eeprom.ccheckpatch and code style
env: cleanenv_sf.ccheckpatch and code style
env: cleanenv_flash.ccheckpatch and code style
env: cleanenv_nand.ccheckpatch and code style
env: cleanenv_common.ccheckpatch and code styleboard/amcc/yucca/cmd_yucca.c | 1 - board/eltec/bab7xx/misc.c | 1 - board/eltec/elppc/misc.c | 1 - board/eltec/mhpc/mhpc.c | 3 - board/hymod/input.c | 3 - board/zeus/zeus.c | 1 - common/cmd_bedbug.c | 1 - common/cmd_dcr.c | 1 - common/cmd_i2c.c | 1 - common/cmd_mem.c | 1 - common/cmd_nvedit.c | 100 +++++++++++------------ common/cmd_pci.c | 1 - common/env_common.c | 52 ++++-------- common/env_dataflash.c | 34 +++----- common/env_eeprom.c | 104 +++++++++++------------- common/env_embedded.c | 47 ++++++------ common/env_flash.c | 181 ++++++++++++++++++++---------------------- common/env_mgdisk.c | 7 +- common/env_mmc.c | 78 ++++++------------- common/env_nand.c | 105 +++++++++++------------- common/env_nowhere.c | 12 +-- common/env_nvram.c | 26 +++--- common/env_onenand.c | 21 ++---- common/env_sf.c | 51 +++++------- common/hush.c | 1 - common/modem.c | 1 - include/command.h | 3 + include/common.h | 1 + include/dataflash.h | 2 + include/environment.h | 61 +++++++++----- tools/envcrc.c | 4 +- 31 files changed, 395 insertions(+), 511 deletions(-)
Signature · 2 lines
Regards, Igor.
cover Cleanup environment related files
In reply to Igor GrinbergQuoted 24 lines · Igor Grinberg
This patch series cleans up environment related files in terms of checkpatch and other coding style issues. It is based on Mon, 7 Nov 2011 Wolfgang's master.
There are several warnings/errors left, mostly because I don't think we need those solved or I can't choose the right solution.
Probably, there will be several conflict with the recent patches on the list, so once all issues are fixed,
I can rebase this patch set on top of the most recent master.Thanks to all reviewers :-)
Igor Grinberg (17):
env: cleanenvironment.hcheckpatch and code style
common: move extern char console_buffer[] tocommon.h
env: move extern default_environment[] toenvironment.h
env: move extern environment[] toenvironment.h
env: cleancmd_nvedit.ccheckpatch and code style
env: cleanenv_nowhere.ccheckpatch and code style
env: cleanenv_mgdisk.ccheckpatch and code style
env: cleanenv_dataflash.ccheckpatch and code style
env: cleanenv_onenand.ccheckpatch and code style
Quoted 9 lines
env: clean
env_nvram.ccheckpatch and code style
env: cleanenv_mmc.ccheckpatch and code style
env: cleanenv_embedded.ccheckpatch and code style
env: cleanenv_eeprom.ccheckpatch and code style
env: cleanenv_sf.ccheckpatch and code style
env: cleanenv_flash.ccheckpatch and code style
env: cleanenv_nand.ccheckpatch and code style
env: cleanenv_common.ccheckpatch and code style
Applied to u-boot-staging, sbabic at denx.de, thanks.
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================