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