summaryrefslogtreecommitdiff
path: root/common/env_sf.c
diff options
context:
space:
mode:
authorIgor Grinberg <grinberg@compulab.co.il>2011-11-07 01:14:08 +0000
committerStefano Babic <sbabic@denx.de>2011-11-22 08:39:26 +0100
commiteb58a7fc7772985e7af19d23ff4331eefd4077d7 (patch)
treec1d6be7445c92a4d3477d37ade083a262b18f25b /common/env_sf.c
parentdd2a233c94a4aaff0bc6cafbc6ed6de5bdbf324e (diff)
downloadu-boot-imx-eb58a7fc7772985e7af19d23ff4331eefd4077d7.zip
u-boot-imx-eb58a7fc7772985e7af19d23ff4331eefd4077d7.tar.gz
u-boot-imx-eb58a7fc7772985e7af19d23ff4331eefd4077d7.tar.bz2
env: clean env_sf.c checkpatch and code style
Cleanup the env_sf.c checkpatch warnings, errors and coding style. Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Diffstat (limited to 'common/env_sf.c')
-rw-r--r--common/env_sf.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/common/env_sf.c b/common/env_sf.c
index 8ff52a3..592b870 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: