summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_boottime.c1
-rw-r--r--lib/efi_loader/efi_console.c1
-rw-r--r--lib/efi_loader/efi_variable.c3
-rw-r--r--lib/fdtdec.c2
-rw-r--r--lib/gunzip.c5
-rw-r--r--lib/gzip.c1
-rw-r--r--lib/hashtable.c66
-rw-r--r--lib/smbios.c1
-rw-r--r--lib/uuid.c1
9 files changed, 45 insertions, 36 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index f75ca1a67c..b9bff894cb 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -8,7 +8,6 @@
#include <common.h>
#include <div64.h>
#include <efi_loader.h>
-#include <environment.h>
#include <malloc.h>
#include <linux/libfdt_env.h>
#include <u-boot/crc.h>
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 6c8229da42..d4765afb98 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -9,6 +9,7 @@
#include <charset.h>
#include <dm/device.h>
#include <efi_loader.h>
+#include <env.h>
#include <stdio_dev.h>
#include <video_console.h>
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 889a7f2ba0..6687b69a40 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -5,11 +5,12 @@
* Copyright (c) 2017 Rob Clark
*/
+#include <env.h>
#include <malloc.h>
#include <charset.h>
#include <efi_loader.h>
#include <hexdump.h>
-#include <environment.h>
+#include <env_internal.h>
#include <search.h>
#include <uuid.h>
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 3ee786b579..ef5e54875c 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -8,9 +8,11 @@
#include <boot_fit.h>
#include <dm.h>
#include <dm/of_extra.h>
+#include <env.h>
#include <errno.h>
#include <fdtdec.h>
#include <fdt_support.h>
+#include <gzip.h>
#include <mapmem.h>
#include <linux/libfdt.h>
#include <serial.h>
diff --git a/lib/gunzip.c b/lib/gunzip.c
index 15c7b2c932..1d65616c13 100644
--- a/lib/gunzip.c
+++ b/lib/gunzip.c
@@ -5,14 +5,15 @@
*/
#include <common.h>
-#include <watchdog.h>
#include <command.h>
#include <console.h>
+#include <div64.h>
+#include <gzip.h>
#include <image.h>
#include <malloc.h>
#include <memalign.h>
+#include <watchdog.h>
#include <u-boot/zlib.h>
-#include <div64.h>
#define HEADER0 '\x1f'
#define HEADER1 '\x8b'
diff --git a/lib/gzip.c b/lib/gzip.c
index 674d732fe6..c6c0ec880c 100644
--- a/lib/gzip.c
+++ b/lib/gzip.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <watchdog.h>
#include <command.h>
+#include <gzip.h>
#include <image.h>
#include <malloc.h>
#include <memalign.h>
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 0d288d12d9..2caab0a4c6 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -59,14 +59,14 @@
* which describes the current status.
*/
-typedef struct _ENTRY {
+struct env_entry_node {
int used;
- ENTRY entry;
-} _ENTRY;
+ struct env_entry entry;
+};
-static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
- int idx);
+static void _hdelete(const char *key, struct hsearch_data *htab,
+ struct env_entry *ep, int idx);
/*
* hcreate()
@@ -120,7 +120,8 @@ int hcreate_r(size_t nel, struct hsearch_data *htab)
htab->filled = 0;
/* allocate memory and zero out */
- htab->table = (_ENTRY *) calloc(htab->size + 1, sizeof(_ENTRY));
+ htab->table = (struct env_entry_node *)calloc(htab->size + 1,
+ sizeof(struct env_entry_node));
if (htab->table == NULL)
return 0;
@@ -151,7 +152,7 @@ void hdestroy_r(struct hsearch_data *htab)
/* free used memory */
for (i = 1; i <= htab->size; ++i) {
if (htab->table[i].used > 0) {
- ENTRY *ep = &htab->table[i].entry;
+ struct env_entry *ep = &htab->table[i].entry;
free((void *)ep->key);
free(ep->data);
@@ -193,14 +194,14 @@ void hdestroy_r(struct hsearch_data *htab)
* data any more.
* - The standard implementation does not provide a way to update an
* existing entry. This version will create a new entry or update an
- * existing one when both "action == ENTER" and "item.data != NULL".
+ * existing one when both "action == ENV_ENTER" and "item.data != NULL".
* - Instead of returning 1 on success, we return the index into the
* internal hash table, which is also guaranteed to be positive.
* This allows us direct access to the found hash table slot for
* example for functions like hdelete().
*/
-int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
+int hmatch_r(const char *match, int last_idx, struct env_entry **retval,
struct hsearch_data *htab)
{
unsigned int idx;
@@ -222,16 +223,17 @@ int hmatch_r(const char *match, int last_idx, ENTRY ** retval,
/*
* Compare an existing entry with the desired key, and overwrite if the action
- * is ENTER. This is simply a helper function for hsearch_r().
+ * is ENV_ENTER. This is simply a helper function for hsearch_r().
*/
-static inline int _compare_and_overwrite_entry(ENTRY item, ACTION action,
- ENTRY **retval, struct hsearch_data *htab, int flag,
- unsigned int hval, unsigned int idx)
+static inline int _compare_and_overwrite_entry(struct env_entry item,
+ enum env_action action, struct env_entry **retval,
+ struct hsearch_data *htab, int flag, unsigned int hval,
+ unsigned int idx)
{
if (htab->table[idx].used == hval
&& strcmp(item.key, htab->table[idx].entry.key) == 0) {
/* Overwrite existing value? */
- if ((action == ENTER) && (item.data != NULL)) {
+ if (action == ENV_ENTER && item.data) {
/* check for permission */
if (htab->change_ok != NULL && htab->change_ok(
&htab->table[idx].entry, item.data,
@@ -270,8 +272,8 @@ static inline int _compare_and_overwrite_entry(ENTRY item, ACTION action,
return -1;
}
-int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
- struct hsearch_data *htab, int flag)
+int hsearch_r(struct env_entry item, enum env_action action,
+ struct env_entry **retval, struct hsearch_data *htab, int flag)
{
unsigned int hval;
unsigned int count;
@@ -352,7 +354,7 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
}
/* An empty bucket has been found. */
- if (action == ENTER) {
+ if (action == ENV_ENTER) {
/*
* If table is full and another entry should be
* entered return with error.
@@ -431,10 +433,10 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
* do that.
*/
-static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
- int idx)
+static void _hdelete(const char *key, struct hsearch_data *htab,
+ struct env_entry *ep, int idx)
{
- /* free used ENTRY */
+ /* free used entry */
debug("hdelete: DELETING key \"%s\"\n", key);
free((void *)ep->key);
free(ep->data);
@@ -447,14 +449,14 @@ static void _hdelete(const char *key, struct hsearch_data *htab, ENTRY *ep,
int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
{
- ENTRY e, *ep;
+ struct env_entry e, *ep;
int idx;
debug("hdelete: DELETE key \"%s\"\n", key);
e.key = (char *)key;
- idx = hsearch_r(e, FIND, &ep, htab, 0);
+ idx = hsearch_r(e, ENV_FIND, &ep, htab, 0);
if (idx == 0) {
__set_errno(ESRCH);
return 0; /* not found */
@@ -528,8 +530,8 @@ int hdelete_r(const char *key, struct hsearch_data *htab, int flag)
static int cmpkey(const void *p1, const void *p2)
{
- ENTRY *e1 = *(ENTRY **) p1;
- ENTRY *e2 = *(ENTRY **) p2;
+ struct env_entry *e1 = *(struct env_entry **)p1;
+ struct env_entry *e2 = *(struct env_entry **)p2;
return (strcmp(e1->key, e2->key));
}
@@ -563,8 +565,8 @@ static int match_string(int flag, const char *str, const char *pat, void *priv)
return 0;
}
-static int match_entry(ENTRY *ep, int flag,
- int argc, char * const argv[])
+static int match_entry(struct env_entry *ep, int flag, int argc,
+ char *const argv[])
{
int arg;
void *priv = NULL;
@@ -596,7 +598,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
char **resp, size_t size,
int argc, char * const argv[])
{
- ENTRY *list[htab->size];
+ struct env_entry *list[htab->size];
char *res, *p;
size_t totlen;
int i, n;
@@ -617,7 +619,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
for (i = 1, n = 0, totlen = 0; i <= htab->size; ++i) {
if (htab->table[i].used > 0) {
- ENTRY *ep = &htab->table[i].entry;
+ struct env_entry *ep = &htab->table[i].entry;
int found = match_entry(ep, flag, argc, argv);
if ((argc > 0) && (found == 0))
@@ -657,7 +659,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
#endif
/* Sort list by keys */
- qsort(list, n, sizeof(ENTRY *), cmpkey);
+ qsort(list, n, sizeof(struct env_entry *), cmpkey);
/* Check if the user supplied buffer size is sufficient */
if (size) {
@@ -869,7 +871,7 @@ int himport_r(struct hsearch_data *htab,
}
/* Parse environment; allow for '\0' and 'sep' as separators */
do {
- ENTRY e, *rv;
+ struct env_entry e, *rv;
/* skip leading white space */
while (isblank(*dp))
@@ -929,7 +931,7 @@ int himport_r(struct hsearch_data *htab,
e.key = name;
e.data = value;
- hsearch_r(e, ENTER, &rv, htab, flag);
+ hsearch_r(e, ENV_ENTER, &rv, htab, flag);
if (rv == NULL)
printf("himport_r: can't insert \"%s=%s\" into hash table\n",
name, value);
@@ -976,7 +978,7 @@ end:
* Walk all of the entries in the hash, calling the callback for each one.
* this allows some generic operation to be performed on each element.
*/
-int hwalk_r(struct hsearch_data *htab, int (*callback)(ENTRY *))
+int hwalk_r(struct hsearch_data *htab, int (*callback)(struct env_entry *entry))
{
int i;
int retval;
diff --git a/lib/smbios.c b/lib/smbios.c
index e8ee55c4ae..7b74971f68 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -6,6 +6,7 @@
*/
#include <common.h>
+#include <env.h>
#include <mapmem.h>
#include <smbios.h>
#include <tables_csum.h>
diff --git a/lib/uuid.c b/lib/uuid.c
index ca8be2cdca..a48e19c06e 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -4,6 +4,7 @@
*/
#include <common.h>
+#include <env.h>
#include <linux/ctype.h>
#include <errno.h>
#include <common.h>