summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_mtdparts.c19
-rw-r--r--common/cmd_nvedit.c5
-rw-r--r--common/console.c49
-rw-r--r--common/env_common.c10
4 files changed, 56 insertions, 27 deletions
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index d0639f6cd2..32d6c899d1 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -124,6 +124,7 @@
* field for read-only partitions */
#define MTD_WRITEABLE_CMD 1
+#ifndef CONFIG_MTDPARTS_DYNAMIC_DEFAULT
/* default values for mtdids and mtdparts variables */
#if defined(MTDIDS_DEFAULT)
static const char *const mtdids_default = MTDIDS_DEFAULT;
@@ -136,6 +137,15 @@ static const char *const mtdparts_default = MTDPARTS_DEFAULT;
#else
static const char *const mtdparts_default = NULL;
#endif
+char *get_mtdparts_default(void)
+{
+ return (char *)mtdparts_default;
+}
+char *get_mtdids_default(void)
+{
+ return (char *)mtdids_default;
+}
+#endif
/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
#define MTDIDS_MAXLEN 128
@@ -1307,6 +1317,7 @@ static void print_partition_table(void)
static void list_partitions(void)
{
struct part_info *part;
+ char *mtdids_default, *mtdparts_default;
debug("\n---list_partitions---\n");
print_partition_table();
@@ -1324,6 +1335,7 @@ static void list_partitions(void)
}
}
+ mtdids_default = get_mtdids_default();
printf("\ndefaults:\n");
printf("mtdids : %s\n",
mtdids_default ? mtdids_default : "none");
@@ -1332,6 +1344,7 @@ static void list_partitions(void)
* if default mtdparts string is greater than console
* printbuffer. Use puts() to prevent system crashes.
*/
+ mtdparts_default = get_mtdparts_default();
puts("mtdparts: ");
puts(mtdparts_default ? mtdparts_default : "none");
puts("\n");
@@ -1715,6 +1728,7 @@ int mtdparts_init(void)
const char *current_partition;
int ids_changed;
char tmp_ep[PARTITION_MAXLEN];
+ char *mtdids_default, *mtdparts_default;
debug("\n---mtdparts_init---\n");
if (!initialized) {
@@ -1747,6 +1761,7 @@ int mtdparts_init(void)
/* if mtdids varible is empty try to use defaults */
if (!ids) {
+ mtdids_default = get_mtdids_default();
if (mtdids_default) {
debug("mtdids variable not defined, using default\n");
ids = mtdids_default;
@@ -1933,8 +1948,12 @@ int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*/
int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
+ char *mtdids_default, *mtdparts_default;
+
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
+ mtdids_default = get_mtdids_default();
+ mtdparts_default = get_mtdparts_default();
setenv("mtdids", (char *)mtdids_default);
setenv("mtdparts", (char *)mtdparts_default);
setenv("partition", NULL);
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 91728f7109..bbebdd2f37 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -591,11 +591,6 @@ static int do_env_default(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
return cmd_usage(cmdtp);
set_default_env("## Resetting to default environment\n");
-#if defined(CONFIG_TOUCHUP_ENV)
- /* On a restored environment, need to initialise board
- * specific variables */
- touchup_env();
-#endif
return 0;
}
diff --git a/common/console.c b/common/console.c
index 8c650e05e1..340eee878f 100644
--- a/common/console.c
+++ b/common/console.c
@@ -270,22 +270,29 @@ void fputs(int file, const char *s)
console_puts(file, s);
}
+void fprintf_out(struct vsprintf_out *p, char ch)
+{
+ fputc(p->dat.file, ch);
+}
+
int fprintf(int file, const char *fmt, ...)
{
va_list args;
uint i;
- char printbuffer[CONFIG_SYS_PBSIZE];
+ struct vsprintf_out r;
+
+ memset(&r, 0, sizeof(r));
+ r.out = fprintf_out;
+ r.dat.file = file;
va_start(args, fmt);
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
- i = vsprintf(printbuffer, fmt, args);
+ i = vsfprintf(&r, fmt, args);
va_end(args);
- /* Send to desired file */
- fputs(file, printbuffer);
return i;
}
@@ -365,37 +372,39 @@ void puts(const char *s)
}
}
+static void vprintf_out(struct vsprintf_out *p, char ch)
+{
+ p->dat.len++;
+ putc(ch);
+}
+
+
int printf(const char *fmt, ...)
{
va_list args;
uint i;
- char printbuffer[CONFIG_SYS_PBSIZE];
+ struct vsprintf_out r;
- va_start(args, fmt);
+ memset(&r, 0, sizeof(r));
+ r.out = vprintf_out;
- /* For this to work, printbuffer must be larger than
- * anything we ever want to print.
- */
- i = vsprintf(printbuffer, fmt, args);
+ va_start(args, fmt);
+ i = vsfprintf(&r, fmt, args);
va_end(args);
- /* Print the string */
- puts(printbuffer);
return i;
}
int vprintf(const char *fmt, va_list args)
{
uint i;
- char printbuffer[CONFIG_SYS_PBSIZE];
+ struct vsprintf_out r;
- /* For this to work, printbuffer must be larger than
- * anything we ever want to print.
- */
- i = vsprintf(printbuffer, fmt, args);
+ memset(&r, 0, sizeof(r));
+ r.out = vprintf_out;
+
+ i = vsfprintf(&r, fmt, args);
- /* Print the string */
- puts(printbuffer);
return i;
}
@@ -459,7 +468,7 @@ inline void dbg(const char *fmt, ...)
/* For this to work, printbuffer must be larger than
* anything we ever want to print.
*/
- i = vsprintf(printbuffer, fmt, args);
+ i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args);
va_end(args);
if ((screen + sizeof(screen) - 1 - cursor)
diff --git a/common/env_common.c b/common/env_common.c
index 04a947e92b..af7a9cb57c 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -194,6 +194,9 @@ void set_default_env(const char *s)
error("Environment import failed: errno = %d\n", errno);
}
gd->flags |= GD_FLG_ENV_READY;
+#ifdef CONFIG_TOUCHUP_ENV
+ touchup_env(1);
+#endif
}
int env_check_valid(const char *buf)
@@ -221,6 +224,9 @@ int env_import(const char *buf, int check)
if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0)) {
gd->flags |= GD_FLG_ENV_READY;
+#ifdef CONFIG_TOUCHUP_ENV
+ touchup_env(0);
+#endif
return 1;
}
@@ -247,10 +253,10 @@ void env_relocate (void)
#endif
} else {
env_relocate_spec ();
- }
#ifdef CONFIG_TOUCHUP_ENV
- touchup_env();
+ touchup_env(0);
#endif
+ }
}
#ifdef CONFIG_AUTO_COMPLETE