[U-Boot] [PATCH v5 29/30] env: Adjust the get_char() method to return an int

Simon Glass sjg at chromium.org
Thu Aug 3 18:22:16 UTC 2017


In principle this can fail, e.g. if the index is out of range. Adjust the
driver signature to allow returning an error code.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Tom Rini <trini at konsulko.com>
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/dataflash.c       | 2 +-
 env/eeprom.c          | 2 +-
 env/nvram.c           | 2 +-
 include/environment.h | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/env/dataflash.c b/env/dataflash.c
index 28dcf6fa1c..afa08f8fd5 100644
--- a/env/dataflash.c
+++ b/env/dataflash.c
@@ -14,7 +14,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static unsigned char env_dataflash_get_char(int index)
+static int env_dataflash_get_char(int index)
 {
 	uchar c;
 
diff --git a/env/eeprom.c b/env/eeprom.c
index 39adccabbe..fbe4fd4efc 100644
--- a/env/eeprom.c
+++ b/env/eeprom.c
@@ -61,7 +61,7 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,
 	return rcode;
 }
 
-static uchar env_eeprom_get_char(int index)
+static int env_eeprom_get_char(int index)
 {
 	uchar c;
 	unsigned int off = CONFIG_ENV_OFFSET;
diff --git a/env/nvram.c b/env/nvram.c
index ac389ace62..85af37d4a0 100644
--- a/env/nvram.c
+++ b/env/nvram.c
@@ -41,7 +41,7 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
 
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-static uchar env_nvram_get_char(int index)
+static int env_nvram_get_char(int index)
 {
 	uchar c;
 
diff --git a/include/environment.h b/include/environment.h
index 9a44215235..ba8af28414 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -227,9 +227,9 @@ struct env_driver {
 	 * will read from gd->env_addr.
 	 *
 	 * @index: Index of character to read (0=first)
-	 * @return character read
+	 * @return character read, or -ve on error
 	 */
-	unsigned char (*get_char)(int index);
+	int (*get_char)(int index);
 
 	/**
 	 * load() - Load the environment from storage
-- 
2.14.0.rc1.383.gd1ce394fe2-goog



More information about the U-Boot mailing list