From: Marek Szyprowski Date: Fri, 29 Jan 2021 12:01:31 +0000 (+0100) Subject: env: fat: allow to dynamically set storage interface X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d4190571ce25f4c6c989b35c393535c21946f0ed;p=platform%2Fkernel%2Fu-boot.git env: fat: allow to dynamically set storage interface Add support for setting the FAT env storage interface dynamically by defining board's own env_fat_get_interface() function. Signed-off-by: Marek Szyprowski Change-Id: I80eef53b9adff942524061c5a8be1bb583fea21f --- diff --git a/env/fat.c b/env/fat.c index 9d37d26f9e..0d96485c89 100644 --- a/env/fat.c +++ b/env/fat.c @@ -32,14 +32,19 @@ DECLARE_GLOBAL_DATA_PTR; -static char *env_fat_device_and_part(void) +__weak char *env_fat_get_interface(void) +{ + return CONFIG_ENV_FAT_INTERFACE; +} + +static char *env_fat_device_and_part(char *interface) { #ifdef CONFIG_MMC static char *part_str; if (!part_str) { part_str = CONFIG_ENV_FAT_DEVICE_AND_PART; - if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc") && part_str[0] == ':') { + if (!strcmp(interface, "mmc") && part_str[0] == ':') { part_str = "0" CONFIG_ENV_FAT_DEVICE_AND_PART; part_str[0] += mmc_get_env_dev(); } @@ -57,6 +62,7 @@ static int env_fat_save(void) struct blk_desc *dev_desc = NULL; struct disk_partition info; const char *file = CONFIG_ENV_FAT_FILE; + char *interface; int dev, part; int err; loff_t size; @@ -65,8 +71,9 @@ static int env_fat_save(void) if (err) return err; - part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, - env_fat_device_and_part(), + interface = env_fat_get_interface(); + part = blk_get_device_part_str(interface, + env_fat_device_and_part(interface), &dev_desc, &info, 1); if (part < 0) return 1; @@ -77,8 +84,7 @@ static int env_fat_save(void) * This printf is embedded in the messages from env_save that * will calling it. The missing \n is intentional. */ - printf("Unable to use %s %d:%d... ", - CONFIG_ENV_FAT_INTERFACE, dev, part); + printf("Unable to use %s %d:%d... ", interface, dev, part); return 1; } @@ -94,7 +100,7 @@ static int env_fat_save(void) * will calling it. The missing \n is intentional. */ printf("Unable to write \"%s\" from %s%d:%d... ", - file, CONFIG_ENV_FAT_INTERFACE, dev, part); + file, interface, dev, part); return 1; } @@ -115,16 +121,19 @@ static int env_fat_load(void) #endif struct blk_desc *dev_desc = NULL; struct disk_partition info; + char *interface; int dev, part; int err1; + interface = env_fat_get_interface(); + #ifdef CONFIG_MMC - if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc")) + if (!strcmp(interface, "mmc")) mmc_initialize(NULL); #endif - part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, - env_fat_device_and_part(), + part = blk_get_device_part_str(interface, + env_fat_device_and_part(interface), &dev_desc, &info, 1); if (part < 0) goto err_env_relocate; @@ -135,8 +144,7 @@ static int env_fat_load(void) * This printf is embedded in the messages from env_save that * will calling it. The missing \n is intentional. */ - printf("Unable to use %s %d:%d... ", - CONFIG_ENV_FAT_INTERFACE, dev, part); + printf("Unable to use %s %d:%d... ", interface, dev, part); goto err_env_relocate; } @@ -154,7 +162,7 @@ static int env_fat_load(void) * will calling it. The missing \n is intentional. */ printf("Unable to read \"%s\" from %s%d:%d... ", - CONFIG_ENV_FAT_FILE, CONFIG_ENV_FAT_INTERFACE, dev, part); + CONFIG_ENV_FAT_FILE, interface, dev, part); goto err_env_relocate; }