* [U-Boot] [PATCH 00/17] Cleanup environment related files
@ 2011-11-07 11:13 Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 01/17] env: clean environment.h checkpatch and code style Igor Grinberg
` (18 more replies)
0 siblings, 19 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
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(-)
--
1.7.3.4
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 01/17] env: clean environment.h checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
@ 2011-11-07 11:13 ` Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 02/17] common: move extern char console_buffer[] to common.h Igor Grinberg
` (17 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
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
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
include/environment.h | 44 +++++++++++++++++++++++---------------------
1 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/include/environment.h b/include/environment.h
index 6394a96..2c8c4f1 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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_ */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 02/17] common: move extern char console_buffer[] to common.h
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 01/17] env: clean environment.h checkpatch and code style Igor Grinberg
@ 2011-11-07 11:13 ` Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h Igor Grinberg
` (16 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
Extract all extern declarations for console_buffer[] out of c files into
the common.h header.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Cc: Frank Gottschling <fgottschling@eltec.de>
Cc: Murray Jensen <Murray.Jensen@csiro.au>
---
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(-)
diff --git a/board/amcc/yucca/cmd_yucca.c b/board/amcc/yucca/cmd_yucca.c
index e9cd333..f45325e 100644
--- a/board/amcc/yucca/cmd_yucca.c
+++ b/board/amcc/yucca/cmd_yucca.c
@@ -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];
diff --git a/board/eltec/bab7xx/misc.c b/board/eltec/bab7xx/misc.c
index bc6eb40..d05e226 100644
--- a/board/eltec/bab7xx/misc.c
+++ b/board/eltec/bab7xx/misc.c
@@ -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);
diff --git a/board/eltec/elppc/misc.c b/board/eltec/elppc/misc.c
index cbaf10b..d476cd5 100644
--- a/board/eltec/elppc/misc.c
+++ b/board/eltec/elppc/misc.c
@@ -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);
diff --git a/board/eltec/mhpc/mhpc.c b/board/eltec/mhpc/mhpc.c
index 7cca6b2..e806b3e 100644
--- a/board/eltec/mhpc/mhpc.c
+++ b/board/eltec/mhpc/mhpc.c
@@ -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);
diff --git a/board/hymod/input.c b/board/hymod/input.c
index 998132d..075076d 100644
--- a/board/hymod/input.c
+++ b/board/hymod/input.c
@@ -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)
{
diff --git a/common/cmd_bedbug.c b/common/cmd_bedbug.c
index 2bd62e2..87b108f 100644
--- a/common/cmd_bedbug.c
+++ b/common/cmd_bedbug.c
@@ -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 */
diff --git a/common/cmd_dcr.c b/common/cmd_dcr.c
index 45fe66a..568e226 100644
--- a/common/cmd_dcr.c
+++ b/common/cmd_dcr.c
@@ -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)
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index 3ea75f7..bb69f63 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -449,7 +449,6 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const arg
ulong data;
int size = 1;
int nbytes;
- extern char console_buffer[];
if (argc != 3)
return cmd_usage(cmdtp);
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 461ee19..9ad932c 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -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);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 396a171..85b1750 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -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;
diff --git a/common/cmd_pci.c b/common/cmd_pci.c
index 92631ea..1e477bc 100644
--- a/common/cmd_pci.c
+++ b/common/cmd_pci.c
@@ -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;
diff --git a/common/hush.c b/common/hush.c
index 2495a6d..e8e24d7 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -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];
diff --git a/common/modem.c b/common/modem.c
index a017b29..e37e1ea 100644
--- a/common/modem.c
+++ b/common/modem.c
@@ -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);
diff --git a/include/common.h b/include/common.h
index 5ca8820..05a658c 100644
--- a/include/common.h
+++ b/include/common.h
@@ -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));
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 01/17] env: clean environment.h checkpatch and code style Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 02/17] common: move extern char console_buffer[] to common.h Igor Grinberg
@ 2011-11-07 11:13 ` Igor Grinberg
2011-11-07 11:17 ` Stefan Roese
2011-11-17 14:12 ` Stefano Babic
2011-11-07 11:13 ` [U-Boot] [PATCH 04/17] env: move extern environment[] to environment.h Igor Grinberg
` (15 subsequent siblings)
18 siblings, 2 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
Extract all extern declarations for default_environment[] out of c files
into the environment.h header.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefan Roese <sr@denx.de>
---
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(-)
diff --git a/board/zeus/zeus.c b/board/zeus/zeus.c
index 18cb85f..272e59b 100644
--- a/board/zeus/zeus.c
+++ b/board/zeus/zeus.c
@@ -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);
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 1d57079..7970ffa 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -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;
diff --git a/common/env_flash.c b/common/env_flash.c
index 50ca4ffa..1383f3c 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -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)
{
diff --git a/common/env_mgdisk.c b/common/env_mgdisk.c
index a69923b..b95d85e 100644
--- a/common/env_mgdisk.c
+++ b/common/env_mgdisk.c
@@ -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;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 83f40f4..a0c0ece 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -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
diff --git a/common/env_nand.c b/common/env_nand.c
index 14446a6..94d4417 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -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";
diff --git a/common/env_nowhere.c b/common/env_nowhere.c
index 75ef78d..a6890db 100644
--- a/common/env_nowhere.c
+++ b/common/env_nowhere.c
@@ -33,8 +33,6 @@ DECLARE_GLOBAL_DATA_PTR;
env_t *env_ptr = NULL;
-extern uchar default_environment[];
-
void env_relocate_spec(void)
{
}
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 544ce47..5357e1a 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -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
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 5e04a06..b1f266b 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -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
diff --git a/common/env_sf.c b/common/env_sf.c
index d3b36d0..2ff10dd 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -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;
diff --git a/include/environment.h b/include/environment.h
index 2c8c4f1..20775da 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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>
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 04/17] env: move extern environment[] to environment.h
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (2 preceding siblings ...)
2011-11-07 11:13 ` [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h Igor Grinberg
@ 2011-11-07 11:13 ` Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 05/17] env: clean cmd_nvedit.c checkpatch and code style Igor Grinberg
` (14 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
Extract all extern declarations for environment out of c files
into the environment.h header.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
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(-)
diff --git a/common/env_flash.c b/common/env_flash.c
index 1383f3c..a32bfcf 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -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;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index a0c0ece..cb75887 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -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 */
diff --git a/common/env_nand.c b/common/env_nand.c
index 94d4417..d975322 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -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 */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index b1f266b..c09fdf3 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -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];
diff --git a/include/environment.h b/include/environment.h
index 20775da..951803f 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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
diff --git a/tools/envcrc.c b/tools/envcrc.c
index feebbab..12913c2 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 05/17] env: clean cmd_nvedit.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (3 preceding siblings ...)
2011-11-07 11:13 ` [U-Boot] [PATCH 04/17] env: move extern environment[] to environment.h Igor Grinberg
@ 2011-11-07 11:13 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 06/17] env: clean env_nowhere.c " Igor Grinberg
` (13 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:13 UTC (permalink / raw)
To: u-boot
Cleanup 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
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/cmd_nvedit.c | 99 +++++++++++++++++++++++-------------------------
include/command.h | 3 +
include/environment.h | 3 +
3 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 85b1750..aab03af 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -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 argv
if (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 argv
return 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
*/
diff --git a/include/command.h b/include/command.h
index c270110..3912b80 100644
--- a/include/command.h
+++ b/include/command.h
@@ -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
diff --git a/include/environment.h b/include/environment.h
index 951803f..3c8c24b 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 06/17] env: clean env_nowhere.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (4 preceding siblings ...)
2011-11-07 11:13 ` [U-Boot] [PATCH 05/17] env: clean cmd_nvedit.c checkpatch and code style Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 07/17] env: clean env_mgdisk.c " Igor Grinberg
` (12 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_nowhere.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_nowhere.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/common/env_nowhere.c b/common/env_nowhere.c
index a6890db..8a3ca19 100644
--- a/common/env_nowhere.c
+++ b/common/env_nowhere.c
@@ -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;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 07/17] env: clean env_mgdisk.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (5 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 06/17] env: clean env_nowhere.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 08/17] env: clean env_dataflash.c " Igor Grinberg
` (11 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_mgdisk.c checkpatch warnings, errors
and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_mgdisk.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/env_mgdisk.c b/common/env_mgdisk.c
index b95d85e..5dd92e7 100644
--- a/common/env_mgdisk.c
+++ b/common/env_mgdisk.c
@@ -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)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 08/17] env: clean env_dataflash.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (6 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 07/17] env: clean env_mgdisk.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 09/17] env: clean env_onenand.c " Igor Grinberg
` (10 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_dataflash.c checkpatch warnings, errors
and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_dataflash.c | 32 ++++++++++++--------------------
include/dataflash.h | 2 ++
2 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 7970ffa..f9674d2 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -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;
diff --git a/include/dataflash.h b/include/dataflash.h
index 96ac097..056e18b 100644
--- a/include/dataflash.h
+++ b/include/dataflash.h
@@ -208,6 +208,8 @@ extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned
extern 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);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 09/17] env: clean env_onenand.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (7 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 08/17] env: clean env_dataflash.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 10/17] env: clean env_nvram.c " Igor Grinberg
` (9 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_onenand.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_onenand.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/common/env_onenand.c b/common/env_onenand.c
index c09fdf3..f356056 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 10/17] env: clean env_nvram.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (8 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 09/17] env: clean env_onenand.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 11/17] env: clean env_mmc.c " Igor Grinberg
` (8 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup 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.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_nvram.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 5357e1a..f7c2f51 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -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;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 11/17] env: clean env_mmc.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (9 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 10/17] env: clean env_nvram.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 12/17] env: clean env_embedded.c " Igor Grinberg
` (7 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_mmc.c checkpatch warnings, errors and coding style.
Simplify env_relocate_spec() function implementation.
Also mark internal functions as static.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_mmc.c | 72 +++++++++++++++++------------------------------------
1 files changed, 23 insertions(+), 49 deletions(-)
diff --git a/common/env_mmc.c b/common/env_mmc.c
index cb75887..e6f626b 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -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
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 12/17] env: clean env_embedded.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (10 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 11/17] env: clean env_mmc.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 13/17] env: clean env_eeprom.c " Igor Grinberg
` (6 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup 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.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_embedded.c | 47 +++++++++++++++++++++++------------------------
1 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/common/env_embedded.c b/common/env_embedded.c
index 6ce1307..80fb29d 100644
--- a/common/env_embedded.c
+++ b/common/env_embedded.c
@@ -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 */
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 13/17] env: clean env_eeprom.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (11 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 12/17] env: clean env_embedded.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 14/17] env: clean env_sf.c " Igor Grinberg
` (5 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_eeprom.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_eeprom.c | 104 ++++++++++++++++++++++----------------------------
1 files changed, 46 insertions(+), 58 deletions(-)
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 0a179ad..b5c0635 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -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
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 14/17] env: clean env_sf.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (12 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 13/17] env: clean env_eeprom.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 15/17] env: clean env_flash.c " Igor Grinberg
` (4 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_sf.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_sf.c | 48 ++++++++++++++++++++----------------------------
1 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/common/env_sf.c b/common/env_sf.c
index 2ff10dd..a798fbe 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -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:
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 15/17] env: clean env_flash.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (13 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 14/17] env: clean env_sf.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 16/17] env: clean env_nand.c " Igor Grinberg
` (3 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_flash.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_flash.c | 175 +++++++++++++++++++++++++---------------------------
1 files changed, 84 insertions(+), 91 deletions(-)
diff --git a/common/env_flash.c b/common/env_flash.c
index a32bfcf..0671473 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -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);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 16/17] env: clean env_nand.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (14 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 15/17] env: clean env_flash.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 17/17] env: clean env_common.c " Igor Grinberg
` (2 subsequent siblings)
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_nand.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_nand.c | 99 ++++++++++++++++++++++++----------------------------
1 files changed, 46 insertions(+), 53 deletions(-)
diff --git a/common/env_nand.c b/common/env_nand.c
index d975322..42d32eb 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 17/17] env: clean env_common.c checkpatch and code style
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (15 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 16/17] env: clean env_nand.c " Igor Grinberg
@ 2011-11-07 11:14 ` Igor Grinberg
2011-11-13 8:29 ` [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
2011-11-22 8:52 ` Stefano Babic
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-07 11:14 UTC (permalink / raw)
To: u-boot
Cleanup the env_common.c checkpatch warnings, errors and coding style.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
common/env_common.c | 52 +++++++++++++++++--------------------------------
include/environment.h | 8 +++++++
2 files changed, 26 insertions(+), 34 deletions(-)
diff --git a/common/env_common.c b/common/env_common.c
index c7e9bea..8a71096 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -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;
}
diff --git a/include/environment.h b/include/environment.h
index 3c8c24b..3c145af 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h
2011-11-07 11:13 ` [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h Igor Grinberg
@ 2011-11-07 11:17 ` Stefan Roese
2011-11-17 14:12 ` Stefano Babic
1 sibling, 0 replies; 40+ messages in thread
From: Stefan Roese @ 2011-11-07 11:17 UTC (permalink / raw)
To: u-boot
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.h header.
>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Stefan Roese <sr@denx.de>
Acked-by: Stefan Roese <sr@denx.de>
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
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 00/17] Cleanup environment related files
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (16 preceding siblings ...)
2011-11-07 11:14 ` [U-Boot] [PATCH 17/17] env: clean env_common.c " Igor Grinberg
@ 2011-11-13 8:29 ` Igor Grinberg
2011-11-22 8:52 ` Stefano Babic
18 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-13 8:29 UTC (permalink / raw)
To: u-boot
ping
On 11/07/11 13:13, Igor Grinberg wrote:
> 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(-)
>
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h
2011-11-07 11:13 ` [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h Igor Grinberg
2011-11-07 11:17 ` Stefan Roese
@ 2011-11-17 14:12 ` Stefano Babic
2011-11-17 15:14 ` Igor Grinberg
1 sibling, 1 reply; 40+ messages in thread
From: Stefano Babic @ 2011-11-17 14:12 UTC (permalink / raw)
To: u-boot
On 11/07/2011 12:13 PM, Igor Grinberg wrote:
> Extract all extern declarations for default_environment[] out of c files
> into the environment.h header.
>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Stefan Roese <sr@denx.de>
> ---
> 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
--
=====================================================================
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
=====================================================================
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h
2011-11-17 14:12 ` Stefano Babic
@ 2011-11-17 15:14 ` Igor Grinberg
2011-11-17 15:30 ` Stefano Babic
0 siblings, 1 reply; 40+ messages in thread
From: Igor Grinberg @ 2011-11-17 15:14 UTC (permalink / raw)
To: u-boot
Hi Stefano,
On 11/17/11 16:12, Stefano Babic wrote:
> On 11/07/2011 12:13 PM, Igor Grinberg wrote:
>> Extract all extern declarations for default_environment[] out of c files
>> into the environment.h header.
>>
>> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
>> Cc: Stefan Roese <sr@denx.de>
>> ---
>> 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 ?
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.
--
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
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h
2011-11-17 15:14 ` Igor Grinberg
@ 2011-11-17 15:30 ` Stefano Babic
2011-11-17 16:07 ` [U-Boot] [PATCH v2 04/17] env: move extern environment[] " Igor Grinberg
0 siblings, 1 reply; 40+ messages in thread
From: Stefano Babic @ 2011-11-17 15:30 UTC (permalink / raw)
To: u-boot
On 11/17/2011 04:14 PM, Igor Grinberg wrote:
>
> 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
You're right, but that was the result bisecting the tree.
>
> Can you please check if the attached patch fixes the envcrc.c problem?
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
--
=====================================================================
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
=====================================================================
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h
2011-11-17 15:30 ` Stefano Babic
@ 2011-11-17 16:07 ` Igor Grinberg
2011-11-25 21:12 ` Mike Frysinger
0 siblings, 1 reply; 40+ messages in thread
From: Igor Grinberg @ 2011-11-17 16:07 UTC (permalink / raw)
To: u-boot
Extract all extern declarations for environment out of c files
into the environment.h header.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
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(-)
diff --git a/common/env_flash.c b/common/env_flash.c
index 1383f3c..a32bfcf 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -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;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index a0c0ece..cb75887 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -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 */
diff --git a/common/env_nand.c b/common/env_nand.c
index 94d4417..d975322 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -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 */
diff --git a/common/env_onenand.c b/common/env_onenand.c
index b1f266b..c09fdf3 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -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];
diff --git a/include/environment.h b/include/environment.h
index 20775da..951803f 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -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
diff --git a/tools/envcrc.c b/tools/envcrc.c
index feebbab..111d9f6 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -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;
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH 00/17] Cleanup environment related files
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
` (17 preceding siblings ...)
2011-11-13 8:29 ` [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
@ 2011-11-22 8:52 ` Stefano Babic
18 siblings, 0 replies; 40+ messages in thread
From: Stefano Babic @ 2011-11-22 8:52 UTC (permalink / raw)
To: u-boot
On 07/11/2011 12:13, Igor Grinberg wrote:
> 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
>
Applied to u-boot-staging, sbabic at denx.de, thanks.
Best regards,
Stefano Babic
--
=====================================================================
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
=====================================================================
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h
2011-11-17 16:07 ` [U-Boot] [PATCH v2 04/17] env: move extern environment[] " Igor Grinberg
@ 2011-11-25 21:12 ` Mike Frysinger
2011-11-27 8:31 ` Igor Grinberg
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
0 siblings, 2 replies; 40+ messages in thread
From: Mike Frysinger @ 2011-11-25 21:12 UTC (permalink / raw)
To: u-boot
On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
> --- a/tools/envcrc.c
> +++ b/tools/envcrc.c
>
> #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>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH v2 04/17] env: move extern environment[] to environment.h
2011-11-25 21:12 ` Mike Frysinger
@ 2011-11-27 8:31 ` Igor Grinberg
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
1 sibling, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-27 8:31 UTC (permalink / raw)
To: u-boot
Hi Mike,
On 11/25/11 23:12, Mike Frysinger wrote:
> On Thursday 17 November 2011 11:07:23 Igor Grinberg wrote:
>> --- a/tools/envcrc.c
>> +++ b/tools/envcrc.c
>>
>> #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.
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
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-25 21:12 ` Mike Frysinger
2011-11-27 8:31 ` Igor Grinberg
@ 2011-11-28 7:57 ` Igor Grinberg
2011-11-28 8:07 ` Wolfgang Denk
` (4 more replies)
1 sibling, 5 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-28 7:57 UTC (permalink / raw)
To: u-boot
When 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.
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
---
tools/envcrc.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/envcrc.c b/tools/envcrc.c
index 111d9f6..51e3f54 100644
--- a/tools/envcrc.c
+++ b/tools/envcrc.c
@@ -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
--
1.7.3.4
^ permalink raw reply related [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
@ 2011-11-28 8:07 ` Wolfgang Denk
2011-11-28 9:04 ` Igor Grinberg
2011-11-28 8:18 ` Wolfgang Denk
` (3 subsequent siblings)
4 siblings, 1 reply; 40+ messages in thread
From: Wolfgang Denk @ 2011-11-28 8:07 UTC (permalink / raw)
To: u-boot
Dear Igor Grinberg,
In message <1322467058-30532-1-git-send-email-grinberg@compulab.co.il> you wrote:
> When 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.
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
--
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_
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
2011-11-28 8:07 ` Wolfgang Denk
@ 2011-11-28 8:18 ` Wolfgang Denk
2011-11-28 8:53 ` Igor Grinberg
2011-11-29 4:25 ` Mike Frysinger
` (2 subsequent siblings)
4 siblings, 1 reply; 40+ messages in thread
From: Wolfgang Denk @ 2011-11-28 8:18 UTC (permalink / raw)
To: u-boot
Dear Igor Grinberg,
In message <1322467058-30532-1-git-send-email-grinberg@compulab.co.il> you wrote:
> When 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.
...
> -extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int);
...
> +extern uint32_t crc32 (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
--
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
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 8:18 ` Wolfgang Denk
@ 2011-11-28 8:53 ` Igor Grinberg
0 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-28 8:53 UTC (permalink / raw)
To: u-boot
Hi Wolfgang,
On 11/28/11 10:18, Wolfgang Denk wrote:
> Dear Igor Grinberg,
>
> In message <1322467058-30532-1-git-send-email-grinberg@compulab.co.il> you wrote:
>> When 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.
>
> ...
>> -extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int);
> ...
>> +extern uint32_t crc32 (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.
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 8:07 ` Wolfgang Denk
@ 2011-11-28 9:04 ` Igor Grinberg
2011-11-28 15:15 ` Wolfgang Denk
2011-11-28 18:52 ` Mike Frysinger
0 siblings, 2 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-28 9:04 UTC (permalink / raw)
To: u-boot
Hi Wolfgang,
On 11/28/11 10:07, Wolfgang Denk wrote:
> Dear Igor Grinberg,
>
> In message <1322467058-30532-1-git-send-email-grinberg@compulab.co.il> you wrote:
>> When 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.
>
> Hm... the fix seems wrong to me. What happens now if ENV_IS_EMBEDDED
> is set, but CONFIG_BUILD_ENVCRC is _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.
>
> 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
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 9:04 ` Igor Grinberg
@ 2011-11-28 15:15 ` Wolfgang Denk
2011-11-29 6:38 ` Igor Grinberg
2011-11-28 18:52 ` Mike Frysinger
1 sibling, 1 reply; 40+ messages in thread
From: Wolfgang Denk @ 2011-11-28 15:15 UTC (permalink / raw)
To: u-boot
Dear Igor Grinberg,
In message <4ED34E9B.7040200@compulab.co.il> you wrote:
>
> > Hm... the fix seems wrong to me. What happens now if ENV_IS_EMBEDDED
> > is set, but CONFIG_BUILD_ENVCRC is _not_ set?
>
> Well, you should look into that file...
It's faster for me to ask you to do that :-)
> > 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
--
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
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 9:04 ` Igor Grinberg
2011-11-28 15:15 ` Wolfgang Denk
@ 2011-11-28 18:52 ` Mike Frysinger
2011-11-29 6:35 ` Igor Grinberg
1 sibling, 1 reply; 40+ messages in thread
From: Mike Frysinger @ 2011-11-28 18:52 UTC (permalink / raw)
To: u-boot
On Mon, Nov 28, 2011 at 04:04, Igor Grinberg wrote:
> I don't have the tool chain for ppc.
http://dev.gentoo.org/~vapier/u-boot/
-mike
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
2011-11-28 8:07 ` Wolfgang Denk
2011-11-28 8:18 ` Wolfgang Denk
@ 2011-11-29 4:25 ` Mike Frysinger
2011-11-29 6:41 ` Igor Grinberg
2011-12-05 10:48 ` Igor Grinberg
2011-12-06 21:11 ` Wolfgang Denk
4 siblings, 1 reply; 40+ messages in thread
From: Mike Frysinger @ 2011-11-29 4:25 UTC (permalink / raw)
To: u-boot
On Monday 28 November 2011 02:57:38 Igor Grinberg wrote:
> When 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.
seems to work for me now; thanks!
Tested-by: Mike Frysinger <vapier@gentoo.org>
-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>
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 18:52 ` Mike Frysinger
@ 2011-11-29 6:35 ` Igor Grinberg
0 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-29 6:35 UTC (permalink / raw)
To: u-boot
On 11/28/11 20:52, Mike Frysinger wrote:
> On Mon, Nov 28, 2011 at 04:04, Igor Grinberg wrote:
>> I don't have the tool chain for ppc.
>
> http://dev.gentoo.org/~vapier/u-boot/
10x Mike
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 15:15 ` Wolfgang Denk
@ 2011-11-29 6:38 ` Igor Grinberg
0 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-29 6:38 UTC (permalink / raw)
To: u-boot
On 11/28/11 17:15, Wolfgang Denk wrote:
> Dear Igor Grinberg,
>
> In message <4ED34E9B.7040200@compulab.co.il> you wrote:
>>
>>> Hm... the fix seems wrong to me. What happens now if ENV_IS_EMBEDDED
>>> is set, but CONFIG_BUILD_ENVCRC is _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.
>
>>> 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 ;-)
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-29 4:25 ` Mike Frysinger
@ 2011-11-29 6:41 ` Igor Grinberg
0 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-11-29 6:41 UTC (permalink / raw)
To: u-boot
On 11/29/11 06:25, Mike Frysinger wrote:
> On Monday 28 November 2011 02:57:38 Igor Grinberg wrote:
>> When 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.
>
> seems to work for me now; thanks!
> Tested-by: Mike Frysinger <vapier@gentoo.org>
10x Mike - it is for Blackfin, right?
Wolfgang, can you apply the fix now?
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
` (2 preceding siblings ...)
2011-11-29 4:25 ` Mike Frysinger
@ 2011-12-05 10:48 ` Igor Grinberg
2011-12-06 21:11 ` Wolfgang Denk
4 siblings, 0 replies; 40+ messages in thread
From: Igor Grinberg @ 2011-12-05 10:48 UTC (permalink / raw)
To: u-boot
ping!
This fixes a compile breakage and
IMO should be applied before 2011.12 is out.
Can someone, please apply it?
On 11/28/11 09:57, Igor Grinberg wrote:
> When 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.
>
> Reported-by: Mike Frysinger <vapier@gentoo.org>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
> tools/envcrc.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/envcrc.c b/tools/envcrc.c
> index 111d9f6..51e3f54 100644
> --- a/tools/envcrc.c
> +++ b/tools/envcrc.c
> @@ -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
--
Regards,
Igor.
^ permalink raw reply [flat|nested] 40+ messages in thread
* [U-Boot] [PATCH] tools/envcrc: fix compile breakage
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
` (3 preceding siblings ...)
2011-12-05 10:48 ` Igor Grinberg
@ 2011-12-06 21:11 ` Wolfgang Denk
4 siblings, 0 replies; 40+ messages in thread
From: Wolfgang Denk @ 2011-12-06 21:11 UTC (permalink / raw)
To: u-boot
Dear Igor Grinberg,
In message <1322467058-30532-1-git-send-email-grinberg@compulab.co.il> you wrote:
> When 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.
>
> Reported-by: Mike Frysinger <vapier@gentoo.org>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
> tools/envcrc.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
--
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.
^ permalink raw reply [flat|nested] 40+ messages in thread
end of thread, other threads:[~2011-12-06 21:11 UTC | newest]
Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-07 11:13 [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 01/17] env: clean environment.h checkpatch and code style Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 02/17] common: move extern char console_buffer[] to common.h Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 03/17] env: move extern default_environment[] to environment.h Igor Grinberg
2011-11-07 11:17 ` Stefan Roese
2011-11-17 14:12 ` Stefano Babic
2011-11-17 15:14 ` Igor Grinberg
2011-11-17 15:30 ` Stefano Babic
2011-11-17 16:07 ` [U-Boot] [PATCH v2 04/17] env: move extern environment[] " Igor Grinberg
2011-11-25 21:12 ` Mike Frysinger
2011-11-27 8:31 ` Igor Grinberg
2011-11-28 7:57 ` [U-Boot] [PATCH] tools/envcrc: fix compile breakage Igor Grinberg
2011-11-28 8:07 ` Wolfgang Denk
2011-11-28 9:04 ` Igor Grinberg
2011-11-28 15:15 ` Wolfgang Denk
2011-11-29 6:38 ` Igor Grinberg
2011-11-28 18:52 ` Mike Frysinger
2011-11-29 6:35 ` Igor Grinberg
2011-11-28 8:18 ` Wolfgang Denk
2011-11-28 8:53 ` Igor Grinberg
2011-11-29 4:25 ` Mike Frysinger
2011-11-29 6:41 ` Igor Grinberg
2011-12-05 10:48 ` Igor Grinberg
2011-12-06 21:11 ` Wolfgang Denk
2011-11-07 11:13 ` [U-Boot] [PATCH 04/17] env: move extern environment[] to environment.h Igor Grinberg
2011-11-07 11:13 ` [U-Boot] [PATCH 05/17] env: clean cmd_nvedit.c checkpatch and code style Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 06/17] env: clean env_nowhere.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 07/17] env: clean env_mgdisk.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 08/17] env: clean env_dataflash.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 09/17] env: clean env_onenand.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 10/17] env: clean env_nvram.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 11/17] env: clean env_mmc.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 12/17] env: clean env_embedded.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 13/17] env: clean env_eeprom.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 14/17] env: clean env_sf.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 15/17] env: clean env_flash.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 16/17] env: clean env_nand.c " Igor Grinberg
2011-11-07 11:14 ` [U-Boot] [PATCH 17/17] env: clean env_common.c " Igor Grinberg
2011-11-13 8:29 ` [U-Boot] [PATCH 00/17] Cleanup environment related files Igor Grinberg
2011-11-22 8:52 ` Stefano Babic
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.