Commit eb58a7fc7772985e7af19d23ff4331eefd4077d7
Committed by
Stefano Babic
1 parent
dd2a233c94
Exists in
master
and in
54 other branches
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>
Showing 1 changed file with 20 additions and 28 deletions Side-by-side Diff
common/env_sf.c
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | # define CONFIG_ENV_SPI_BUS 0 |
37 | 37 | #endif |
38 | 38 | #ifndef CONFIG_ENV_SPI_CS |
39 | -# define CONFIG_ENV_SPI_CS 0 | |
39 | +# define CONFIG_ENV_SPI_CS 0 | |
40 | 40 | #endif |
41 | 41 | #ifndef CONFIG_ENV_SPI_MAX_HZ |
42 | 42 | # define CONFIG_ENV_SPI_MAX_HZ 1000000 |
43 | 43 | |
44 | 44 | |
... | ... | @@ -46,16 +46,16 @@ |
46 | 46 | #endif |
47 | 47 | |
48 | 48 | #ifdef CONFIG_ENV_OFFSET_REDUND |
49 | -static ulong env_offset = CONFIG_ENV_OFFSET; | |
50 | -static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND; | |
49 | +static ulong env_offset = CONFIG_ENV_OFFSET; | |
50 | +static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND; | |
51 | 51 | |
52 | -#define ACTIVE_FLAG 1 | |
53 | -#define OBSOLETE_FLAG 0 | |
52 | +#define ACTIVE_FLAG 1 | |
53 | +#define OBSOLETE_FLAG 0 | |
54 | 54 | #endif /* CONFIG_ENV_OFFSET_REDUND */ |
55 | 55 | |
56 | 56 | DECLARE_GLOBAL_DATA_PTR; |
57 | 57 | |
58 | -char * env_name_spec = "SPI Flash"; | |
58 | +char *env_name_spec = "SPI Flash"; | |
59 | 59 | |
60 | 60 | static struct spi_flash *env_flash; |
61 | 61 | |
62 | 62 | |
63 | 63 | |
... | ... | @@ -65,17 +65,13 @@ |
65 | 65 | } |
66 | 66 | |
67 | 67 | #if defined(CONFIG_ENV_OFFSET_REDUND) |
68 | - | |
69 | 68 | int saveenv(void) |
70 | 69 | { |
71 | 70 | env_t env_new; |
72 | 71 | ssize_t len; |
73 | - char *res; | |
74 | - u32 saved_size, saved_offset; | |
75 | - char *saved_buffer = NULL; | |
76 | - u32 sector = 1; | |
72 | + char *res, *saved_buffer = NULL, flag = OBSOLETE_FLAG; | |
73 | + u32 saved_size, saved_offset, sector = 1; | |
77 | 74 | int ret; |
78 | - char flag = OBSOLETE_FLAG; | |
79 | 75 | |
80 | 76 | if (!env_flash) { |
81 | 77 | env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, |
... | ... | @@ -93,8 +89,8 @@ |
93 | 89 | error("Cannot export environment: errno = %d\n", errno); |
94 | 90 | return 1; |
95 | 91 | } |
96 | - env_new.crc = crc32(0, env_new.data, ENV_SIZE); | |
97 | - env_new.flags = ACTIVE_FLAG; | |
92 | + env_new.crc = crc32(0, env_new.data, ENV_SIZE); | |
93 | + env_new.flags = ACTIVE_FLAG; | |
98 | 94 | |
99 | 95 | if (gd->env_valid == 1) { |
100 | 96 | env_new_offset = CONFIG_ENV_OFFSET_REDUND; |
101 | 97 | |
102 | 98 | |
... | ... | @@ -145,21 +141,21 @@ |
145 | 141 | goto done; |
146 | 142 | } |
147 | 143 | |
148 | - ret = spi_flash_write(env_flash, | |
149 | - env_offset + offsetof(env_t, flags), | |
150 | - sizeof(env_new.flags), &flag); | |
144 | + ret = spi_flash_write(env_flash, env_offset + offsetof(env_t, flags), | |
145 | + sizeof(env_new.flags), &flag); | |
151 | 146 | if (ret) |
152 | 147 | goto done; |
153 | 148 | |
154 | 149 | puts("done\n"); |
155 | 150 | |
156 | - gd->env_valid = (gd->env_valid == 2 ? 1 : 2); | |
151 | + gd->env_valid = gd->env_valid == 2 ? 1 : 2; | |
157 | 152 | |
158 | 153 | printf("Valid environment: %d\n", (int)gd->env_valid); |
159 | 154 | |
160 | 155 | done: |
161 | 156 | if (saved_buffer) |
162 | 157 | free(saved_buffer); |
158 | + | |
163 | 159 | return ret; |
164 | 160 | } |
165 | 161 | |
166 | 162 | |
167 | 163 | |
... | ... | @@ -245,18 +241,14 @@ |
245 | 241 | out: |
246 | 242 | free(tmp_env1); |
247 | 243 | free(tmp_env2); |
248 | - | |
249 | - return; | |
250 | 244 | } |
251 | 245 | #else |
252 | 246 | int saveenv(void) |
253 | 247 | { |
254 | - u32 saved_size, saved_offset; | |
255 | - char *saved_buffer = NULL; | |
256 | - u32 sector = 1; | |
257 | - int ret = 1; | |
248 | + u32 saved_size, saved_offset, sector = 1; | |
249 | + char *res, *saved_buffer = NULL; | |
250 | + int ret = 1; | |
258 | 251 | env_t env_new; |
259 | - char *res; | |
260 | 252 | ssize_t len; |
261 | 253 | |
262 | 254 | if (!env_flash) { |
263 | 255 | |
... | ... | @@ -274,9 +266,9 @@ |
274 | 266 | saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE; |
275 | 267 | saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE; |
276 | 268 | saved_buffer = malloc(saved_size); |
277 | - if (!saved_buffer) { | |
269 | + if (!saved_buffer) | |
278 | 270 | goto done; |
279 | - } | |
271 | + | |
280 | 272 | ret = spi_flash_read(env_flash, saved_offset, |
281 | 273 | saved_size, saved_buffer); |
282 | 274 | if (ret) |
... | ... | @@ -322,6 +314,7 @@ |
322 | 314 | done: |
323 | 315 | if (saved_buffer) |
324 | 316 | free(saved_buffer); |
317 | + | |
325 | 318 | return ret; |
326 | 319 | } |
327 | 320 | |
... | ... | @@ -345,7 +338,6 @@ |
345 | 338 | } |
346 | 339 | |
347 | 340 | ret = env_import(buf, 1); |
348 | - | |
349 | 341 | if (ret) |
350 | 342 | gd->env_valid = 1; |
351 | 343 | out: |