summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig1
-rw-r--r--common/Makefile4
-rw-r--r--common/calloc.c19
-rw-r--r--common/console.c4
-rw-r--r--common/dummy_malloc.c22
-rw-r--r--common/partitions/efi.c2
-rw-r--r--common/ratp/ratp.c2
-rw-r--r--common/state/state.c5
-rw-r--r--common/state/state_variables.c6
-rw-r--r--common/tlsf_malloc.c33
10 files changed, 51 insertions, 47 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 4909c82322..eddd99ea3b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -653,7 +653,6 @@ config BOOTM_FORCE_SIGNED_IMAGES
since they are the only supported image type that support signing.
config BLSPEC
- depends on BLOCK
depends on FLEXIBLE_BOOTARGS
depends on !SHELL_NONE
select BOOT
diff --git a/common/Makefile b/common/Makefile
index 13920cc5a6..861365bd55 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -34,8 +34,8 @@ obj-$(CONFIG_GLOBALVAR) += globalvar.o
obj-$(CONFIG_GREGORIAN_CALENDER) += date.o
obj-$(CONFIG_KALLSYMS) += kallsyms.o
obj-$(CONFIG_MALLOC_DLMALLOC) += dlmalloc.o
-obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o tlsf.o
-obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o
+obj-$(CONFIG_MALLOC_TLSF) += tlsf_malloc.o tlsf.o calloc.o
+obj-$(CONFIG_MALLOC_DUMMY) += dummy_malloc.o calloc.o
obj-$(CONFIG_MEMINFO) += meminfo.o
obj-$(CONFIG_MENU) += menu.o
obj-$(CONFIG_MODULES) += module.o
diff --git a/common/calloc.c b/common/calloc.c
new file mode 100644
index 0000000000..2b933ec272
--- /dev/null
+++ b/common/calloc.c
@@ -0,0 +1,19 @@
+#include <common.h>
+#include <malloc.h>
+
+/*
+ * calloc calls malloc, then zeroes out the allocated chunk.
+ */
+void *calloc(size_t n, size_t elem_size)
+{
+ size_t size = elem_size * n;
+ void *r = malloc(size);
+
+ if (!r)
+ return r;
+
+ memset(r, 0x0, size);
+
+ return r;
+}
+EXPORT_SYMBOL(calloc);
diff --git a/common/console.c b/common/console.c
index 40c26b66d9..47ccf2e54d 100644
--- a/common/console.c
+++ b/common/console.c
@@ -314,10 +314,10 @@ int console_register(struct console_device *newcdev)
if (newcdev->devname) {
dev->id = newcdev->devid;
- strcpy(dev->name, newcdev->devname);
+ dev_set_name(dev, newcdev->devname);
} else {
dev->id = DEVICE_ID_DYNAMIC;
- strcpy(dev->name, "cs");
+ dev_set_name(dev, "cs");
}
if (newcdev->dev)
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
index 641baa125a..0120d9be2e 100644
--- a/common/dummy_malloc.c
+++ b/common/dummy_malloc.c
@@ -30,11 +30,14 @@ void malloc_stats(void)
void *memalign(size_t alignment, size_t bytes)
{
- unsigned long mem = (unsigned long)sbrk(bytes + alignment);
+ void *mem = sbrk(bytes + alignment);
- mem = (mem + alignment) & ~(alignment - 1);
+ if (!mem) {
+ errno = ENOMEM;
+ return NULL;
+ }
- return (void *)mem;
+ return PTR_ALIGN(mem, alignment);
}
void *malloc(size_t size)
@@ -50,16 +53,3 @@ void *realloc(void *ptr, size_t size)
{
BUG();
}
-
-void *calloc(size_t n, size_t elem_size)
-{
- size_t size = elem_size * n;
- void *r = malloc(size);
-
- if (!r)
- return r;
-
- memset(r, 0x0, size);
-
- return r;
-}
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 88734f166b..3c1077fd0c 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -23,7 +23,7 @@
#include "efi.h"
#include "parser.h"
-static int force_gpt = IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE);
+static const int force_gpt = IS_ENABLED(CONFIG_PARTITION_DISK_EFI_GPT_NO_FORCE);
/**
* efi_crc32() - EFI version of crc32 function
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
index fae9cec5b9..9aea1786d6 100644
--- a/common/ratp/ratp.c
+++ b/common/ratp/ratp.c
@@ -72,7 +72,7 @@ int register_ratp_command(struct ratp_command *cmd)
}
EXPORT_SYMBOL(register_ratp_command);
-struct ratp_command *find_ratp_request(uint16_t request_id)
+static struct ratp_command *find_ratp_request(uint16_t request_id)
{
struct ratp_command *cmdtp;
diff --git a/common/state/state.c b/common/state/state.c
index 25d9502111..1597197ca2 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -179,7 +179,7 @@ static struct state *state_new(const char *name)
int ret;
state = xzalloc(sizeof(*state));
- safe_strncpy(state->dev.name, name, MAX_DRIVER_NAME);
+ dev_set_name(&state->dev, name);
state->name = state->dev.name;
state->dev.id = DEVICE_ID_SINGLE;
INIT_LIST_HEAD(&state->variables);
@@ -311,7 +311,7 @@ static int state_convert_node_variable(struct state *state,
if ((conv == STATE_CONVERT_TO_NODE)
|| (conv == STATE_CONVERT_FIXUP)) {
ret = of_property_write_string(new_node, "type",
- vtype->type_name);
+ vtype->type_name);
if (ret)
goto out;
@@ -583,6 +583,7 @@ void state_release(struct state *state)
/*
* state_new_from_node - create a new state instance from a device_node
*
+ * @node The device_node describing the new state instance
* @readonly This is a read-only state. Note that with this option set,
* there are no repairs done.
*/
diff --git a/common/state/state_variables.c b/common/state/state_variables.c
index de9ba4ab61..abd714ceda 100644
--- a/common/state/state_variables.c
+++ b/common/state/state_variables.c
@@ -339,8 +339,7 @@ static int state_string_export(struct state_variable *var,
int ret = 0;
if (string->value_default) {
- ret = of_set_property(node, "default", string->value_default,
- strlen(string->value_default) + 1, 1);
+ ret = of_property_write_string(node, "default", string->value_default);
if (ret)
return ret;
@@ -350,8 +349,7 @@ static int state_string_export(struct state_variable *var,
return 0;
if (string->value)
- ret = of_set_property(node, "value", string->value,
- strlen(string->value) + 1, 1);
+ ret = of_property_write_string(node, "value", string->value);
return ret;
}
diff --git a/common/tlsf_malloc.c b/common/tlsf_malloc.c
index a3541d8256..c8900fc6bb 100644
--- a/common/tlsf_malloc.c
+++ b/common/tlsf_malloc.c
@@ -28,6 +28,7 @@ extern tlsf_pool tlsf_mem_pool;
void *malloc(size_t bytes)
{
+ void *mem;
/*
* tlsf_malloc returns NULL for zero bytes, we instead want
* to have a valid pointer.
@@ -35,25 +36,13 @@ void *malloc(size_t bytes)
if (!bytes)
bytes = 1;
- return tlsf_malloc(tlsf_mem_pool, bytes);
-}
-EXPORT_SYMBOL(malloc);
-
-/*
- * calloc calls malloc, then zeroes out the allocated chunk.
- */
-void *calloc(size_t n, size_t elem_size)
-{
- void *mem;
- size_t sz;
-
- sz = n * elem_size;
- mem = malloc(sz);
- memset(mem, 0, sz);
+ mem = tlsf_malloc(tlsf_mem_pool, bytes);
+ if (!mem)
+ errno = ENOMEM;
return mem;
}
-EXPORT_SYMBOL(calloc);
+EXPORT_SYMBOL(malloc);
void free(void *mem)
{
@@ -63,13 +52,21 @@ EXPORT_SYMBOL(free);
void *realloc(void *oldmem, size_t bytes)
{
- return tlsf_realloc(tlsf_mem_pool, oldmem, bytes);
+ void *mem = tlsf_realloc(tlsf_mem_pool, oldmem, bytes);
+ if (!mem)
+ errno = ENOMEM;
+
+ return mem;
}
EXPORT_SYMBOL(realloc);
void *memalign(size_t alignment, size_t bytes)
{
- return tlsf_memalign(tlsf_mem_pool, alignment, bytes);
+ void *mem = tlsf_memalign(tlsf_mem_pool, alignment, bytes);
+ if (!mem)
+ errno = ENOMEM;
+
+ return mem;
}
EXPORT_SYMBOL(memalign);