summaryrefslogtreecommitdiff
path: root/env/common.c
AgeCommit message (Collapse)Author
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-04-16env: Relocate env drivers if manual reloc is requiredSiva Durga Prasad Paladugu
Relocate env drivers if manual relocation is enabled. This patch fixes the issue of u-boot hang incase if env is present in any of the flash devices. Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-02-01env: move more common code to env_import_redundSimon Goldschmidt
There is more common code in mmc, nand and ubi env drivers that can be shared by moving to env_import_redund. For this, a status/error value whether the buffers were loaded are passed as additional parameters to env_import_redund. Ideally, these are already returned to the env driver by the storage driver. This is the case for mmc, nand and ubi, so for this change, code deduplicated. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2018-01-31env: make env_import(_redund) return 0 on success, not 1Simon Goldschmidt
env_import (and env_import_redund) currently return 1 on success and 0 on error. However, they are only used from functions returning 0 on success or a negative value on error. Let's clean this up by making env_import and env_import_redund return 0 on success and -EIO on error (as was the case for all users before). Users that cared for the return value are also updated. Funny enough, this only affects onenand.c and sf.c Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2018-01-27env: common: Make the debug messages play a little nicerMaxime Ripard
Since we have global messages to indicate what's going on, the custom messages in the environment drivers only make the output less readable. Make the common code play a little nicer by removing all the extra output in the standard case. Reviewed-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
2017-11-21env: Remove CONFIG_ENV_AES supportTom Rini
This support has been deprecated since v2017.09 due to security issues. We now remove this support. Signed-off-by: Tom Rini <trini@konsulko.com>
2017-10-04treewide: replace with error() with pr_err()Masahiro Yamada
U-Boot widely uses error() as a bit noisier variant of printf(). This macro causes name conflict with the following line in include/linux/compiler-gcc.h: # define __compiletime_error(message) __attribute__((error(message))) This prevents us from using __compiletime_error(), and makes it difficult to fully sync BUILD_BUG macros with Linux. (Notice Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().) Let's convert error() into now treewide-available pr_err(). Done with the help of Coccinelle, excluing tools/ directory. The semantic patch I used is as follows: // <smpl> @@@@ -error +pr_err (...) // </smpl> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Re-run Coccinelle] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-08-20env: Replace all open-coded gd->env_valid values with ENV_ flagsSimon Glass
Some of these were missed in the conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename some other getenv()-related functionsSimon Glass
We are now using an env_ prefix for environment functions. Rename these other functions as well, for consistency: getenv_vlan() getenv_bootm_size() getenv_bootm_low() getenv_bootm_mapsize() env_get_default() Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()Simon Glass
We are now using an env_ prefix for environment functions. Rename these for consistency. Also add function comments in common.h. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-15env: Drop env_relocate_spec() in favour of env_load()Simon Glass
This is a strange name for a function that loads the environment. There is now only one implementation of this function, so use the new env_load() function directly instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-15env: Drop env_get_char_spec()Simon Glass
We only have a single implementation of this function now and it is called env_get_char(). Drop the old function and the weak version. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-15env: common: Drop env_get_char_memory()Simon Glass
This function is the same as env_get_char_spec() apart from dropping the brackets. Drop the brackets from env_get_char_spec() and use that instead of env_get_char_memory(). Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-15env: common: Drop env_get_char_init()Simon Glass
This function does nothing but call env_get_char_spec(). Drop it and adjust its only caller. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-15env: common: Factor out the common env_valid checkSimon Glass
The check for gd->env_valid is used in both the 'if' and 'else' part of env_get_char(). Move it into that function instead for simplicity. Drop that code from the two leaf functions. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-15env: common: Drop env_get_addr()Simon Glass
This function is not used anywhere other than env_get_char(). Move the code into that function. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-15env: common: Make env_get_addr/get_char_memory() staticSimon Glass
These functions are not used outside this file. Make them static and order them to avoid forward declarations. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-15Move environment files from common/ to env/Simon Glass
About a quarter of the files in common/ relate to the environment. It seems better to put these into their own subdirectory and remove the prefix. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>