Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 1 | /* |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 2 | * (C) Copyright 2008-2011 Freescale Semiconductor, Inc. |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 3 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* #define DEBUG */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | |
| 11 | #include <command.h> |
| 12 | #include <environment.h> |
| 13 | #include <linux/stddef.h> |
| 14 | #include <malloc.h> |
| 15 | #include <mmc.h> |
Lei Wen | 6d1d51b | 2010-11-10 07:39:23 +0800 | [diff] [blame] | 16 | #include <search.h> |
Lei Wen | e79f483 | 2010-10-13 11:07:21 +0800 | [diff] [blame] | 17 | #include <errno.h> |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 18 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 19 | #if defined(CONFIG_ENV_SIZE_REDUND) && \ |
| 20 | (CONFIG_ENV_SIZE_REDUND != CONFIG_ENV_SIZE) |
| 21 | #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE |
| 22 | #endif |
| 23 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 24 | char *env_name_spec = "MMC"; |
| 25 | |
| 26 | #ifdef ENV_IS_EMBEDDED |
Igor Grinberg | 994bc67 | 2011-11-17 06:07:23 +0000 | [diff] [blame] | 27 | env_t *env_ptr = &environment; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 28 | #else /* ! ENV_IS_EMBEDDED */ |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 29 | env_t *env_ptr; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 30 | #endif /* ENV_IS_EMBEDDED */ |
| 31 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 34 | #if !defined(CONFIG_ENV_OFFSET) |
| 35 | #define CONFIG_ENV_OFFSET 0 |
| 36 | #endif |
| 37 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 38 | __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 39 | { |
Stephen Warren | 5c088ee | 2013-06-11 15:14:02 -0600 | [diff] [blame] | 40 | s64 offset; |
| 41 | |
| 42 | offset = CONFIG_ENV_OFFSET; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 43 | #ifdef CONFIG_ENV_OFFSET_REDUND |
| 44 | if (copy) |
Stephen Warren | 5c088ee | 2013-06-11 15:14:02 -0600 | [diff] [blame] | 45 | offset = CONFIG_ENV_OFFSET_REDUND; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 46 | #endif |
Stephen Warren | 5c088ee | 2013-06-11 15:14:02 -0600 | [diff] [blame] | 47 | |
| 48 | if (offset < 0) |
| 49 | offset += mmc->capacity; |
| 50 | |
| 51 | *env_addr = offset; |
| 52 | |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 53 | return 0; |
| 54 | } |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 55 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 56 | int env_init(void) |
| 57 | { |
| 58 | /* use default */ |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 59 | gd->env_addr = (ulong)&default_environment[0]; |
| 60 | gd->env_valid = 1; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 61 | |
| 62 | return 0; |
| 63 | } |
| 64 | |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 65 | static int init_mmc_for_env(struct mmc *mmc) |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 66 | { |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 67 | #ifdef CONFIG_SYS_MMC_ENV_PART |
| 68 | int dev = CONFIG_SYS_MMC_ENV_DEV; |
| 69 | |
| 70 | #ifdef CONFIG_SPL_BUILD |
| 71 | dev = 0; |
| 72 | #endif |
| 73 | #endif |
| 74 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 75 | if (!mmc) { |
| 76 | puts("No MMC card found\n"); |
| 77 | return -1; |
| 78 | } |
| 79 | |
| 80 | if (mmc_init(mmc)) { |
| 81 | puts("MMC init failed\n"); |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 82 | return -1; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 83 | } |
| 84 | |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 85 | #ifdef CONFIG_SYS_MMC_ENV_PART |
| 86 | if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) { |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 87 | if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) { |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 88 | puts("MMC partition switch failed\n"); |
| 89 | return -1; |
| 90 | } |
| 91 | } |
| 92 | #endif |
| 93 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 94 | return 0; |
| 95 | } |
| 96 | |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 97 | static void fini_mmc_for_env(struct mmc *mmc) |
| 98 | { |
| 99 | #ifdef CONFIG_SYS_MMC_ENV_PART |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 100 | int dev = CONFIG_SYS_MMC_ENV_DEV; |
| 101 | |
| 102 | #ifdef CONFIG_SPL_BUILD |
| 103 | dev = 0; |
| 104 | #endif |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 105 | if (CONFIG_SYS_MMC_ENV_PART != mmc->part_num) |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 106 | mmc_switch_part(dev, mmc->part_num); |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 107 | #endif |
| 108 | } |
| 109 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 110 | #ifdef CONFIG_CMD_SAVEENV |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 111 | static inline int write_env(struct mmc *mmc, unsigned long size, |
| 112 | unsigned long offset, const void *buffer) |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 113 | { |
| 114 | uint blk_start, blk_cnt, n; |
| 115 | |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 116 | blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; |
| 117 | blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 118 | |
| 119 | n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start, |
| 120 | blk_cnt, (u_char *)buffer); |
| 121 | |
| 122 | return (n == blk_cnt) ? 0 : -1; |
| 123 | } |
| 124 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 125 | #ifdef CONFIG_ENV_OFFSET_REDUND |
| 126 | static unsigned char env_flags; |
| 127 | #endif |
| 128 | |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 129 | int saveenv(void) |
| 130 | { |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 131 | ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); |
Lei Wen | e79f483 | 2010-10-13 11:07:21 +0800 | [diff] [blame] | 132 | ssize_t len; |
| 133 | char *res; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 134 | struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 135 | u32 offset; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 136 | int ret, copy = 0; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 137 | |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 138 | if (init_mmc_for_env(mmc)) |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 139 | return 1; |
| 140 | |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 141 | res = (char *)&env_new->data; |
Joe Hershberger | be11235 | 2012-12-11 22:16:23 -0600 | [diff] [blame] | 142 | len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL); |
Lei Wen | e79f483 | 2010-10-13 11:07:21 +0800 | [diff] [blame] | 143 | if (len < 0) { |
| 144 | error("Cannot export environment: errno = %d\n", errno); |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 145 | ret = 1; |
| 146 | goto fini; |
Lei Wen | e79f483 | 2010-10-13 11:07:21 +0800 | [diff] [blame] | 147 | } |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 148 | |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 149 | env_new->crc = crc32(0, &env_new->data[0], ENV_SIZE); |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 150 | |
| 151 | #ifdef CONFIG_ENV_OFFSET_REDUND |
| 152 | env_new->flags = ++env_flags; /* increase the serial */ |
| 153 | |
| 154 | if (gd->env_valid == 1) |
| 155 | copy = 1; |
| 156 | #endif |
| 157 | |
| 158 | if (mmc_get_env_addr(mmc, copy, &offset)) { |
| 159 | ret = 1; |
| 160 | goto fini; |
| 161 | } |
| 162 | |
| 163 | printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", |
| 164 | CONFIG_SYS_MMC_ENV_DEV); |
Stephen Warren | 4036b63 | 2012-05-24 11:38:33 +0000 | [diff] [blame] | 165 | if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) { |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 166 | puts("failed\n"); |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 167 | ret = 1; |
| 168 | goto fini; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | puts("done\n"); |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 172 | ret = 0; |
| 173 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 174 | #ifdef CONFIG_ENV_OFFSET_REDUND |
| 175 | gd->env_valid = gd->env_valid == 2 ? 1 : 2; |
| 176 | #endif |
| 177 | |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 178 | fini: |
| 179 | fini_mmc_for_env(mmc); |
| 180 | return ret; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 181 | } |
| 182 | #endif /* CONFIG_CMD_SAVEENV */ |
| 183 | |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 184 | static inline int read_env(struct mmc *mmc, unsigned long size, |
| 185 | unsigned long offset, const void *buffer) |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 186 | { |
| 187 | uint blk_start, blk_cnt, n; |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 188 | int dev = CONFIG_SYS_MMC_ENV_DEV; |
| 189 | |
| 190 | #ifdef CONFIG_SPL_BUILD |
| 191 | dev = 0; |
| 192 | #endif |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 193 | |
Igor Grinberg | e8db8f7 | 2011-11-07 01:14:05 +0000 | [diff] [blame] | 194 | blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len; |
| 195 | blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len; |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 196 | |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 197 | n = mmc->block_dev.block_read(dev, blk_start, blk_cnt, (uchar *)buffer); |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 198 | |
| 199 | return (n == blk_cnt) ? 0 : -1; |
| 200 | } |
| 201 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 202 | #ifdef CONFIG_ENV_OFFSET_REDUND |
| 203 | void env_relocate_spec(void) |
| 204 | { |
| 205 | #if !defined(ENV_IS_EMBEDDED) |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 206 | struct mmc *mmc; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 207 | u32 offset1, offset2; |
| 208 | int read1_fail = 0, read2_fail = 0; |
| 209 | int crc1_ok = 0, crc2_ok = 0; |
Markus Niebel | 452a272 | 2013-10-04 15:48:03 +0200 | [diff] [blame] | 210 | env_t *ep; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 211 | int ret; |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 212 | int dev = CONFIG_SYS_MMC_ENV_DEV; |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 213 | |
Markus Niebel | 452a272 | 2013-10-04 15:48:03 +0200 | [diff] [blame] | 214 | ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1); |
| 215 | ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env2, 1); |
| 216 | |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 217 | #ifdef CONFIG_SPL_BUILD |
| 218 | dev = 0; |
| 219 | #endif |
| 220 | |
| 221 | mmc = find_mmc_device(dev); |
| 222 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 223 | if (init_mmc_for_env(mmc)) { |
| 224 | ret = 1; |
| 225 | goto err; |
| 226 | } |
| 227 | |
| 228 | if (mmc_get_env_addr(mmc, 0, &offset1) || |
| 229 | mmc_get_env_addr(mmc, 1, &offset2)) { |
| 230 | ret = 1; |
| 231 | goto fini; |
| 232 | } |
| 233 | |
| 234 | read1_fail = read_env(mmc, CONFIG_ENV_SIZE, offset1, tmp_env1); |
| 235 | read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2); |
| 236 | |
| 237 | if (read1_fail && read2_fail) |
| 238 | puts("*** Error - No Valid Environment Area found\n"); |
| 239 | else if (read1_fail || read2_fail) |
| 240 | puts("*** Warning - some problems detected " |
| 241 | "reading environment; recovered successfully\n"); |
| 242 | |
| 243 | crc1_ok = !read1_fail && |
| 244 | (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc); |
| 245 | crc2_ok = !read2_fail && |
| 246 | (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); |
| 247 | |
| 248 | if (!crc1_ok && !crc2_ok) { |
| 249 | ret = 1; |
| 250 | goto fini; |
| 251 | } else if (crc1_ok && !crc2_ok) { |
| 252 | gd->env_valid = 1; |
| 253 | } else if (!crc1_ok && crc2_ok) { |
| 254 | gd->env_valid = 2; |
| 255 | } else { |
| 256 | /* both ok - check serial */ |
| 257 | if (tmp_env1->flags == 255 && tmp_env2->flags == 0) |
| 258 | gd->env_valid = 2; |
| 259 | else if (tmp_env2->flags == 255 && tmp_env1->flags == 0) |
| 260 | gd->env_valid = 1; |
| 261 | else if (tmp_env1->flags > tmp_env2->flags) |
| 262 | gd->env_valid = 1; |
| 263 | else if (tmp_env2->flags > tmp_env1->flags) |
| 264 | gd->env_valid = 2; |
| 265 | else /* flags are equal - almost impossible */ |
| 266 | gd->env_valid = 1; |
| 267 | } |
| 268 | |
| 269 | free(env_ptr); |
| 270 | |
| 271 | if (gd->env_valid == 1) |
| 272 | ep = tmp_env1; |
| 273 | else |
| 274 | ep = tmp_env2; |
| 275 | |
| 276 | env_flags = ep->flags; |
| 277 | env_import((char *)ep, 0); |
| 278 | ret = 0; |
| 279 | |
| 280 | fini: |
| 281 | fini_mmc_for_env(mmc); |
| 282 | err: |
| 283 | if (ret) |
| 284 | set_default_env(NULL); |
| 285 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 286 | #endif |
| 287 | } |
| 288 | #else /* ! CONFIG_ENV_OFFSET_REDUND */ |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 289 | void env_relocate_spec(void) |
| 290 | { |
| 291 | #if !defined(ENV_IS_EMBEDDED) |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 292 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 293 | struct mmc *mmc; |
Mingkai Hu | 97039ab | 2011-01-24 17:09:55 +0000 | [diff] [blame] | 294 | u32 offset; |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 295 | int ret; |
Tom Rini | b9c8cca | 2014-03-28 12:03:34 -0400 | [diff] [blame] | 296 | int dev = CONFIG_SYS_MMC_ENV_DEV; |
| 297 | |
| 298 | #ifdef CONFIG_SPL_BUILD |
| 299 | dev = 0; |
| 300 | #endif |
| 301 | |
| 302 | mmc = find_mmc_device(dev); |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 303 | |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 304 | if (init_mmc_for_env(mmc)) { |
| 305 | ret = 1; |
| 306 | goto err; |
| 307 | } |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 308 | |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 309 | if (mmc_get_env_addr(mmc, 0, &offset)) { |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 310 | ret = 1; |
| 311 | goto fini; |
| 312 | } |
| 313 | |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 314 | if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) { |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 315 | ret = 1; |
| 316 | goto fini; |
| 317 | } |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 318 | |
Tom Rini | cd0f4fa | 2013-04-05 14:55:21 -0400 | [diff] [blame] | 319 | env_import(buf, 1); |
Stephen Warren | 9404a5f | 2012-07-30 10:55:44 +0000 | [diff] [blame] | 320 | ret = 0; |
| 321 | |
| 322 | fini: |
| 323 | fini_mmc_for_env(mmc); |
| 324 | err: |
| 325 | if (ret) |
| 326 | set_default_env(NULL); |
Terry Lv | a806035 | 2010-05-17 10:57:01 +0800 | [diff] [blame] | 327 | #endif |
| 328 | } |
Michael Heimpold | d196bd8 | 2013-04-10 10:36:19 +0000 | [diff] [blame] | 329 | #endif /* CONFIG_ENV_OFFSET_REDUND */ |