summaryrefslogtreecommitdiff
path: root/common/env_mgdisk.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/env_mgdisk.c')
-rw-r--r--common/env_mgdisk.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/common/env_mgdisk.c b/common/env_mgdisk.c
index b9de1ed..a69923b 100644
--- a/common/env_mgdisk.c
+++ b/common/env_mgdisk.c
@@ -30,7 +30,7 @@
/* references to names in env_common.c */
extern uchar default_environment[];
-char * env_name_spec = "MG_DISK";
+char *env_name_spec = "MG_DISK";
env_t *env_ptr = 0;
@@ -38,34 +38,27 @@ 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)
{
- unsigned int err;
+ char buf[CONFIG_ENV_SIZE];
+ unsigned int err, rc;
err = mg_disk_init();
if (err) {
- puts ("*** Warning - mg_disk_init error");
- goto OUT;
- }
- err = mg_disk_read(CONFIG_ENV_ADDR, (u_char *)env_ptr, CONFIG_ENV_SIZE);
- if (err) {
- puts ("*** Warning - mg_disk_read error");
- goto OUT;
+ set_default_env("!mg_disk_init error");
+ return;
}
- if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) {
- puts ("*** Warning - CRC error");
- goto OUT;
+ err = mg_disk_read(CONFIG_ENV_ADDR, buf, CONFIG_ENV_SIZE);
+ if (err) {
+ set_default_env("!mg_disk_read error");
+ return;
}
- return;
-
-OUT:
- printf (", using default environment\n\n");
- set_default_env();
+ env_import(buf, 1);
}
int saveenv(void)
@@ -76,7 +69,7 @@ int saveenv(void)
err = mg_disk_write(CONFIG_ENV_ADDR, (u_char *)env_ptr,
CONFIG_ENV_SIZE);
if (err)
- puts ("*** Warning - mg_disk_write error\n\n");
+ puts("*** Warning - mg_disk_write error\n\n");
return err;
}
@@ -84,7 +77,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;