Merge tag 'dm-9oct18' of git://git.denx.de/u-boot-dm
[platform/kernel/u-boot.git] / test / dm / bus.c
index 7006d41..08137a2 100644 (file)
@@ -1,10 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2014 Google, Inc
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#ifdef CONFIG_SANDBOX
+#include <os.h>
+#endif
 #include <dm.h>
 #include <dm/device-internal.h>
 #include <dm/test.h>
@@ -105,7 +107,7 @@ UCLASS_DRIVER(testbus) = {
 /* Test that we can probe for children */
 static int dm_test_bus_children(struct unit_test_state *uts)
 {
-       int num_devices = 6;
+       int num_devices = 7;
        struct udevice *bus;
        struct uclass *uc;
 
@@ -298,6 +300,11 @@ static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts)
        ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
        drv = (struct driver *)bus->driver;
        size = drv->per_child_auto_alloc_size;
+
+#ifdef CONFIG_SANDBOX
+       os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv));
+       os_mprotect_allow(drv, sizeof(*drv));
+#endif
        bus->uclass->uc_drv->per_child_auto_alloc_size = size;
        drv->per_child_auto_alloc_size = 0;
        ret = test_bus_parent_data(uts);
@@ -441,6 +448,10 @@ static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts)
        ut_assertok(uclass_find_device(UCLASS_TEST_BUS, 0, &bus));
        drv = (struct driver *)bus->driver;
        size = drv->per_child_platdata_auto_alloc_size;
+#ifdef CONFIG_SANDBOX
+       os_mprotect_allow(bus->uclass->uc_drv, sizeof(*bus->uclass->uc_drv));
+       os_mprotect_allow(drv, sizeof(*drv));
+#endif
        bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size;
        drv->per_child_platdata_auto_alloc_size = 0;
        ret = test_bus_parent_platdata(uts);