]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - test/dm/bus.c
dm: core: Allow the uclass to set up a device's child after binding
[karo-tx-uboot.git] / test / dm / bus.c
index e9096970628e70ec0f0e6ce9f99c4eebef25b902..c123ed7931092e77fc7470767d53a953c4341080 100644 (file)
@@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR;
 struct dm_test_parent_platdata {
        int count;
        int bind_flag;
+       int uclass_bind_flag;
 };
 
 enum {
@@ -38,6 +39,7 @@ static int testbus_child_post_bind(struct udevice *dev)
 
        plat = dev_get_parent_platdata(dev);
        plat->bind_flag = 1;
+       plat->uclass_bind_flag = 2;
 
        return 0;
 }
@@ -443,3 +445,27 @@ static int dm_test_bus_child_post_bind(struct dm_test_state *dms)
        return 0;
 }
 DM_TEST(dm_test_bus_child_post_bind, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test that the child post_bind method is called */
+static int dm_test_bus_child_post_bind_uclass(struct dm_test_state *dms)
+{
+       struct dm_test_parent_platdata *plat;
+       struct udevice *bus, *dev;
+       int child_count;
+
+       ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
+       for (device_find_first_child(bus, &dev), child_count = 0;
+            dev;
+            device_find_next_child(&dev)) {
+               /* Check that platform data is allocated */
+               plat = dev_get_parent_platdata(dev);
+               ut_assert(plat != NULL);
+               ut_asserteq(2, plat->uclass_bind_flag);
+               child_count++;
+       }
+       ut_asserteq(3, child_count);
+
+       return 0;
+}
+DM_TEST(dm_test_bus_child_post_bind_uclass,
+       DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);