Skip to content

Commit edafafc

Browse files
envf/part_env: Optimise mechanism
- env partition independs on envf - support macro define to replace env.img - it's better to handle bootargs late in board_fdt_chosen_bootargs() Signed-off-by: Joseph Chen <[email protected]> Change-Id: I94091b40b4022a68e92427eeb775117966f5446c
1 parent d32bfd7 commit edafafc

File tree

4 files changed

+34
-51
lines changed

4 files changed

+34
-51
lines changed

arch/arm/mach-rockchip/board.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,16 +1110,39 @@ char *board_fdt_chosen_bootargs(void *fdt)
11101110
#endif
11111111
}
11121112

1113-
#ifdef CONFIG_ENVF
1114-
char * sys_bootargs;
1113+
#if defined(CONFIG_ENVF) || defined(CONFIG_ENV_PARTITION)
1114+
char *part_type[] = { "mtdparts", "blkdevparts" };
1115+
char *part_list;
1116+
char *env;
1117+
int id = 0;
1118+
1119+
env = env_get(part_type[id]);
1120+
if (!env)
1121+
env = env_get(part_type[++id]);
1122+
if (env) {
1123+
if (!strstr(env, part_type[id])) {
1124+
part_list = calloc(1, strlen(env) + strlen(part_type[id]) + 2);
1125+
if (part_list) {
1126+
strcat(part_list, part_type[id]);
1127+
strcat(part_list, "=");
1128+
strcat(part_list, env);
1129+
}
1130+
} else {
1131+
part_list = env;
1132+
}
1133+
env_update("bootargs", part_list);
1134+
if (dump)
1135+
printf("## parts: %s\n\n", part_list);
1136+
}
11151137

1116-
sys_bootargs = env_get("sys_bootargs");
1117-
if (sys_bootargs) {
1118-
env_update("bootargs", sys_bootargs);
1138+
env = env_get("sys_bootargs");
1139+
if (env) {
1140+
env_update("bootargs", env);
11191141
if (dump)
1120-
printf("## sys_bootargs: %s\n\n", sys_bootargs);
1142+
printf("## sys_bootargs: %s\n\n", env);
11211143
}
11221144
#endif
1145+
11231146
#ifdef CONFIG_MTD_BLK
11241147
if (!env_get("mtdparts")) {
11251148
char *mtd_par_info = mtd_part_parse(NULL);

disk/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ config PARTITION_TYPE_GUID
137137

138138
config ENV_PARTITION
139139
bool "Enable ENV partition table support"
140-
depends on PARTITIONS && ENVF
141-
default y
140+
depends on PARTITIONS
141+
default y if ENVF
142142
help
143143
Say Y here if you would like to use ENV partition table.
144144

145145
config SPL_ENV_PARTITION
146146
bool "Enable ENV partition table support in SPL"
147-
depends on SPL && PARTITIONS && SPL_ENVF
148-
default y
147+
depends on SPL && PARTITIONS
148+
default y if SPL_ENVF
149149
help
150150
Say Y here if you would like to use ENV partition table in SPL.
151151

disk/part_env.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@ static int env_init_parts(struct blk_desc *dev_desc, struct list_head *parts_hea
8282
#if CONFIG_IS_ENABLED(ENVF)
8383
parts_list = envf_get_part_table(dev_desc);
8484
#else
85-
const char *parts_prefix[] = { "mtdparts", "blkdevparts", };
86-
int i;
87-
88-
for (i = 0; i < ARRAY_SIZE(parts_prefix); i++) {
89-
parts_list = env_get(parts_prefix[i]);
90-
if (parts_list)
91-
break;
92-
}
85+
parts_list = ENV_PARTITIONS;
9386
#endif
9487
if (!parts_list)
9588
return -EINVAL;

env/envf.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -262,35 +262,6 @@ static int envf_init_vars(void)
262262
return envf_num;
263263
}
264264

265-
#ifdef CONFIG_ENV_PARTITION
266-
static int envf_add_partition_bootargs(void)
267-
{
268-
char *part_list;
269-
char *bootargs;
270-
int i;
271-
272-
for (i = 0; i < ARRAY_SIZE(part_type); i++) {
273-
part_list = env_get(part_type[i]);
274-
if (part_list)
275-
break;
276-
}
277-
if (!part_list)
278-
return -EINVAL;
279-
280-
bootargs = calloc(1, strlen(part_list) + strlen(part_type[i]) + 2);
281-
if (!bootargs)
282-
return -ENOMEM;
283-
284-
strcat(bootargs, part_type[i]);
285-
strcat(bootargs, "=");
286-
strcat(bootargs, part_list);
287-
env_update("bootargs", bootargs);
288-
free(bootargs);
289-
290-
return 0;
291-
}
292-
#endif
293-
294265
static int envf_load(void)
295266
{
296267
struct blk_desc *desc;
@@ -314,10 +285,6 @@ static int envf_load(void)
314285
}
315286
}
316287

317-
#ifdef CONFIG_ENV_PARTITION
318-
envf_add_partition_bootargs();
319-
#endif
320-
321288
return 0;
322289
}
323290

0 commit comments

Comments
 (0)