extern u32 __dtb_test_fdt_overlay_begin;
extern u32 __dtb_test_fdt_overlay_stacked_begin;
+static void *fdt;
+
static int ut_fdt_getprop_u32_by_index(void *fdt, const char *path,
const char *name, int index,
u32 *out)
static int fdt_overlay_change_int_property(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
u32 val = 0;
ut_assertok(ut_fdt_getprop_u32(fdt, "/test-node", "test-int-property",
static int fdt_overlay_change_str_property(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
const char *val = NULL;
ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property",
static int fdt_overlay_add_str_property(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
const char *val = NULL;
ut_assertok(fdt_getprop_str(fdt, "/test-node", "test-str-property-2",
static int fdt_overlay_add_node_by_phandle(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
int off;
off = fdt_path_offset(fdt, "/test-node/new-node");
static int fdt_overlay_add_node_by_path(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
int off;
off = fdt_path_offset(fdt, "/new-node");
static int fdt_overlay_add_subnode_property(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
int off;
off = fdt_path_offset(fdt, "/test-node/sub-test-node");
static int fdt_overlay_local_phandle(struct unit_test_state *uts)
{
uint32_t local_phandle;
- void *fdt = uts->priv;
u32 val = 0;
int off;
static int fdt_overlay_local_phandles(struct unit_test_state *uts)
{
uint32_t local_phandle, test_phandle;
- void *fdt = uts->priv;
u32 val = 0;
int off;
static int fdt_overlay_stacked(struct unit_test_state *uts)
{
- void *fdt = uts->priv;
u32 val = 0;
ut_assertok(ut_fdt_getprop_u32(fdt, "/new-local-node",
void *fdt_base = &__dtb_test_fdt_base_begin;
void *fdt_overlay = &__dtb_test_fdt_overlay_begin;
void *fdt_overlay_stacked = &__dtb_test_fdt_overlay_stacked_begin;
- void *fdt_base_copy, *fdt_overlay_copy, *fdt_overlay_stacked_copy;
+ void *fdt_overlay_copy, *fdt_overlay_stacked_copy;
int ret = -ENOMEM;
uts = calloc(1, sizeof(*uts));
ut_assertok(fdt_check_header(fdt_base));
ut_assertok(fdt_check_header(fdt_overlay));
- fdt_base_copy = malloc(FDT_COPY_SIZE);
- if (!fdt_base_copy)
+ fdt = malloc(FDT_COPY_SIZE);
+ if (!fdt)
goto err1;
- uts->priv = fdt_base_copy;
fdt_overlay_copy = malloc(FDT_COPY_SIZE);
if (!fdt_overlay_copy)
* (and relocate it since the memory might be mapped
* read-only)
*/
- ut_assertok(fdt_open_into(fdt_base, fdt_base_copy, FDT_COPY_SIZE));
+ ut_assertok(fdt_open_into(fdt_base, fdt, FDT_COPY_SIZE));
/*
* Resize the overlay to 4k so that we have room to operate on
FDT_COPY_SIZE));
/* Apply the overlay */
- ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_copy));
+ ut_assertok(fdt_overlay_apply(fdt, fdt_overlay_copy));
/* Apply the stacked overlay */
- ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_stacked_copy));
+ ut_assertok(fdt_overlay_apply(fdt, fdt_overlay_stacked_copy));
ret = cmd_ut_category("overlay", tests, n_ents, argc, argv);
err3:
free(fdt_overlay_copy);
err2:
- free(fdt_base_copy);
+ free(fdt);
err1:
- free(uts);
-
return ret;
}