X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=env%2Fsata.c;h=e5715e6d51eb324842233cdd385b463de1ddea51;hb=83d290c56fab2d38cd1ab4c4cc7099559c1d5046;hp=64589117f25a357758b12483a1bc9c62b4450ce0;hpb=203e94f6c9ca03e260175ce240f5856507395585;p=platform%2Fkernel%2Fu-boot.git diff --git a/env/sata.c b/env/sata.c index 6458911..e5715e6 100644 --- a/env/sata.c +++ b/env/sata.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2010-2016 Freescale Semiconductor, Inc. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* #define DEBUG */ @@ -24,24 +23,11 @@ #error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined #endif -char *env_name_spec = "SATA"; - -DECLARE_GLOBAL_DATA_PTR; - __weak int sata_get_env_dev(void) { return CONFIG_SYS_SATA_ENV_DEV; } -int env_init(void) -{ - /* use default */ - gd->env_addr = (ulong)&default_environment[0]; - gd->env_valid = ENV_VALID; - - return 0; -} - #ifdef CONFIG_CMD_SAVEENV static inline int write_env(struct blk_desc *sata, unsigned long size, unsigned long offset, void *buffer) @@ -56,7 +42,7 @@ static inline int write_env(struct blk_desc *sata, unsigned long size, return (n == blk_cnt) ? 0 : -1; } -int saveenv(void) +static int env_sata_save(void) { ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1); struct blk_desc *sata = NULL; @@ -102,26 +88,34 @@ static inline int read_env(struct blk_desc *sata, unsigned long size, return (n == blk_cnt) ? 0 : -1; } -void env_relocate_spec(void) +static void env_sata_load(void) { ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE); struct blk_desc *sata = NULL; int env_sata; if (sata_initialize()) - return; + return -EIO; env_sata = sata_get_env_dev(); sata = sata_get_dev(env_sata); if (sata == NULL) { - printf("Unknown SATA(%d) device for environment!\n", - env_sata); - return; + printf("Unknown SATA(%d) device for environment!\n", env_sata); + return -EIO; } - if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) - return set_default_env(NULL); + if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) { + set_default_env(NULL); + return -EIO; + } - env_import(buf, 1); + return env_import(buf, 1); } + +U_BOOT_ENV_LOCATION(sata) = { + .location = ENVL_ESATA, + ENV_NAME("SATA") + .load = env_sata_load, + .save = env_save_ptr(env_sata_save), +};