1 // SPDX-License-Identifier: GPL-2.0+
3 * Test for the NOP uclass
5 * (C) Copyright 2019 - Texas Instruments Incorporated - http://www.ti.com/
11 #include <dm/ofnode.h>
13 #include <dm/device.h>
18 static int noptest_bind(struct udevice *parent)
20 ofnode ofnode = dev_read_first_subnode(parent);
22 while (ofnode_valid(ofnode)) {
24 const char *bind_flag = ofnode_read_string(ofnode, "bind");
26 if (bind_flag && (strcmp(bind_flag, "True") == 0))
27 lists_bind_fdt(parent, ofnode, &dev, false);
28 ofnode = dev_read_next_subnode(ofnode);
34 static const struct udevice_id noptest1_ids[] = {
36 .compatible = "sandbox,nop_sandbox1",
41 U_BOOT_DRIVER(noptest_drv1) = {
42 .name = "noptest1_drv",
43 .of_match = noptest1_ids,
48 static const struct udevice_id noptest2_ids[] = {
50 .compatible = "sandbox,nop_sandbox2",
55 U_BOOT_DRIVER(noptest_drv2) = {
56 .name = "noptest2_drv",
57 .of_match = noptest2_ids,
61 static int dm_test_nop(struct unit_test_state *uts)
65 ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_0", &dev));
66 ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_1", &dev));
68 uclass_get_device_by_name(UCLASS_NOP, "nop-test_2", &dev));
73 DM_TEST(dm_test_nop, DM_TESTF_FLAT_TREE | DM_TESTF_SCAN_FDT);