core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * Tests for the core driver model code
  3. *
  4. * Copyright (c) 2013 Google, Inc
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <errno.h>
  10. #include <dm.h>
  11. #include <fdtdec.h>
  12. #include <malloc.h>
  13. #include <dm/device-internal.h>
  14. #include <dm/root.h>
  15. #include <dm/ut.h>
  16. #include <dm/util.h>
  17. #include <dm/test.h>
  18. #include <dm/uclass-internal.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. enum {
  21. TEST_INTVAL1 = 0,
  22. TEST_INTVAL2 = 3,
  23. TEST_INTVAL3 = 6,
  24. TEST_INTVAL_MANUAL = 101112,
  25. TEST_INTVAL_PRE_RELOC = 7,
  26. };
  27. static const struct dm_test_pdata test_pdata[] = {
  28. { .ping_add = TEST_INTVAL1, },
  29. { .ping_add = TEST_INTVAL2, },
  30. { .ping_add = TEST_INTVAL3, },
  31. };
  32. static const struct dm_test_pdata test_pdata_manual = {
  33. .ping_add = TEST_INTVAL_MANUAL,
  34. };
  35. static const struct dm_test_pdata test_pdata_pre_reloc = {
  36. .ping_add = TEST_INTVAL_PRE_RELOC,
  37. };
  38. U_BOOT_DEVICE(dm_test_info1) = {
  39. .name = "test_drv",
  40. .platdata = &test_pdata[0],
  41. };
  42. U_BOOT_DEVICE(dm_test_info2) = {
  43. .name = "test_drv",
  44. .platdata = &test_pdata[1],
  45. };
  46. U_BOOT_DEVICE(dm_test_info3) = {
  47. .name = "test_drv",
  48. .platdata = &test_pdata[2],
  49. };
  50. static struct driver_info driver_info_manual = {
  51. .name = "test_manual_drv",
  52. .platdata = &test_pdata_manual,
  53. };
  54. static struct driver_info driver_info_pre_reloc = {
  55. .name = "test_pre_reloc_drv",
  56. .platdata = &test_pdata_manual,
  57. };
  58. void dm_leak_check_start(struct dm_test_state *dms)
  59. {
  60. dms->start = mallinfo();
  61. if (!dms->start.uordblks)
  62. puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n");
  63. }
  64. int dm_leak_check_end(struct dm_test_state *dms)
  65. {
  66. struct mallinfo end;
  67. int id;
  68. /* Don't delete the root class, since we started with that */
  69. for (id = UCLASS_ROOT + 1; id < UCLASS_COUNT; id++) {
  70. struct uclass *uc;
  71. uc = uclass_find(id);
  72. if (!uc)
  73. continue;
  74. ut_assertok(uclass_destroy(uc));
  75. }
  76. end = mallinfo();
  77. ut_asserteq(dms->start.uordblks, end.uordblks);
  78. return 0;
  79. }
  80. /* Test that binding with platdata occurs correctly */
  81. static int dm_test_autobind(struct dm_test_state *dms)
  82. {
  83. struct udevice *dev;
  84. /*
  85. * We should have a single class (UCLASS_ROOT) and a single root
  86. * device with no children.
  87. */
  88. ut_assert(dms->root);
  89. ut_asserteq(1, list_count_items(&gd->uclass_root));
  90. ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
  91. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
  92. ut_assertok(dm_scan_platdata(false));
  93. /* We should have our test class now at least, plus more children */
  94. ut_assert(1 < list_count_items(&gd->uclass_root));
  95. ut_assert(0 < list_count_items(&gd->dm_root->child_head));
  96. /* Our 3 dm_test_infox children should be bound to the test uclass */
  97. ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);
  98. /* No devices should be probed */
  99. list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node)
  100. ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));
  101. /* Our test driver should have been bound 3 times */
  102. ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3);
  103. return 0;
  104. }
  105. DM_TEST(dm_test_autobind, 0);
  106. /* Test that autoprobe finds all the expected devices */
  107. static int dm_test_autoprobe(struct dm_test_state *dms)
  108. {
  109. int expected_base_add;
  110. struct udevice *dev;
  111. struct uclass *uc;
  112. int i;
  113. ut_assertok(uclass_get(UCLASS_TEST, &uc));
  114. ut_assert(uc);
  115. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
  116. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]);
  117. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
  118. /* The root device should not be activated until needed */
  119. ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
  120. /*
  121. * We should be able to find the three test devices, and they should
  122. * all be activated as they are used (lazy activation, required by
  123. * U-Boot)
  124. */
  125. for (i = 0; i < 3; i++) {
  126. ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
  127. ut_assert(dev);
  128. ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
  129. "Driver %d/%s already activated", i, dev->name);
  130. /* This should activate it */
  131. ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
  132. ut_assert(dev);
  133. ut_assert(dev->flags & DM_FLAG_ACTIVATED);
  134. /* Activating a device should activate the root device */
  135. if (!i)
  136. ut_assert(dms->root->flags & DM_FLAG_ACTIVATED);
  137. }
  138. /*
  139. * Our 3 dm_test_info children should be passed to pre_probe and
  140. * post_probe
  141. */
  142. ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]);
  143. ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]);
  144. /* Also we can check the per-device data */
  145. expected_base_add = 0;
  146. for (i = 0; i < 3; i++) {
  147. struct dm_test_uclass_perdev_priv *priv;
  148. struct dm_test_pdata *pdata;
  149. ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
  150. ut_assert(dev);
  151. priv = dev_get_uclass_priv(dev);
  152. ut_assert(priv);
  153. ut_asserteq(expected_base_add, priv->base_add);
  154. pdata = dev->platdata;
  155. expected_base_add += pdata->ping_add;
  156. }
  157. return 0;
  158. }
  159. DM_TEST(dm_test_autoprobe, DM_TESTF_SCAN_PDATA);
  160. /* Check that we see the correct platdata in each device */
  161. static int dm_test_platdata(struct dm_test_state *dms)
  162. {
  163. const struct dm_test_pdata *pdata;
  164. struct udevice *dev;
  165. int i;
  166. for (i = 0; i < 3; i++) {
  167. ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
  168. ut_assert(dev);
  169. pdata = dev->platdata;
  170. ut_assert(pdata->ping_add == test_pdata[i].ping_add);
  171. }
  172. return 0;
  173. }
  174. DM_TEST(dm_test_platdata, DM_TESTF_SCAN_PDATA);
  175. /* Test that we can bind, probe, remove, unbind a driver */
  176. static int dm_test_lifecycle(struct dm_test_state *dms)
  177. {
  178. int op_count[DM_TEST_OP_COUNT];
  179. struct udevice *dev, *test_dev;
  180. int pingret;
  181. int ret;
  182. memcpy(op_count, dm_testdrv_op_count, sizeof(op_count));
  183. ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
  184. &dev));
  185. ut_assert(dev);
  186. ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND]
  187. == op_count[DM_TEST_OP_BIND] + 1);
  188. ut_assert(!dev->priv);
  189. /* Probe the device - it should fail allocating private data */
  190. dms->force_fail_alloc = 1;
  191. ret = device_probe(dev);
  192. ut_assert(ret == -ENOMEM);
  193. ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
  194. == op_count[DM_TEST_OP_PROBE] + 1);
  195. ut_assert(!dev->priv);
  196. /* Try again without the alloc failure */
  197. dms->force_fail_alloc = 0;
  198. ut_assertok(device_probe(dev));
  199. ut_assert(dm_testdrv_op_count[DM_TEST_OP_PROBE]
  200. == op_count[DM_TEST_OP_PROBE] + 2);
  201. ut_assert(dev->priv);
  202. /* This should be device 3 in the uclass */
  203. ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev));
  204. ut_assert(dev == test_dev);
  205. /* Try ping */
  206. ut_assertok(test_ping(dev, 100, &pingret));
  207. ut_assert(pingret == 102);
  208. /* Now remove device 3 */
  209. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]);
  210. ut_assertok(device_remove(dev));
  211. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]);
  212. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_UNBIND]);
  213. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]);
  214. ut_assertok(device_unbind(dev));
  215. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_UNBIND]);
  216. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]);
  217. return 0;
  218. }
  219. DM_TEST(dm_test_lifecycle, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST);
  220. /* Test that we can bind/unbind and the lists update correctly */
  221. static int dm_test_ordering(struct dm_test_state *dms)
  222. {
  223. struct udevice *dev, *dev_penultimate, *dev_last, *test_dev;
  224. int pingret;
  225. ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
  226. &dev));
  227. ut_assert(dev);
  228. /* Bind two new devices (numbers 4 and 5) */
  229. ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
  230. &dev_penultimate));
  231. ut_assert(dev_penultimate);
  232. ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
  233. &dev_last));
  234. ut_assert(dev_last);
  235. /* Now remove device 3 */
  236. ut_assertok(device_remove(dev));
  237. ut_assertok(device_unbind(dev));
  238. /* The device numbering should have shifted down one */
  239. ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev));
  240. ut_assert(dev_penultimate == test_dev);
  241. ut_assertok(uclass_find_device(UCLASS_TEST, 4, &test_dev));
  242. ut_assert(dev_last == test_dev);
  243. /* Add back the original device 3, now in position 5 */
  244. ut_assertok(device_bind_by_name(dms->root, false, &driver_info_manual,
  245. &dev));
  246. ut_assert(dev);
  247. /* Try ping */
  248. ut_assertok(test_ping(dev, 100, &pingret));
  249. ut_assert(pingret == 102);
  250. /* Remove 3 and 4 */
  251. ut_assertok(device_remove(dev_penultimate));
  252. ut_assertok(device_unbind(dev_penultimate));
  253. ut_assertok(device_remove(dev_last));
  254. ut_assertok(device_unbind(dev_last));
  255. /* Our device should now be in position 3 */
  256. ut_assertok(uclass_find_device(UCLASS_TEST, 3, &test_dev));
  257. ut_assert(dev == test_dev);
  258. /* Now remove device 3 */
  259. ut_assertok(device_remove(dev));
  260. ut_assertok(device_unbind(dev));
  261. return 0;
  262. }
  263. DM_TEST(dm_test_ordering, DM_TESTF_SCAN_PDATA);
  264. /* Check that we can perform operations on a device (do a ping) */
  265. int dm_check_operations(struct dm_test_state *dms, struct udevice *dev,
  266. uint32_t base, struct dm_test_priv *priv)
  267. {
  268. int expected;
  269. int pingret;
  270. /* Getting the child device should allocate platdata / priv */
  271. ut_assertok(testfdt_ping(dev, 10, &pingret));
  272. ut_assert(dev->priv);
  273. ut_assert(dev->platdata);
  274. expected = 10 + base;
  275. ut_asserteq(expected, pingret);
  276. /* Do another ping */
  277. ut_assertok(testfdt_ping(dev, 20, &pingret));
  278. expected = 20 + base;
  279. ut_asserteq(expected, pingret);
  280. /* Now check the ping_total */
  281. priv = dev->priv;
  282. ut_asserteq(DM_TEST_START_TOTAL + 10 + 20 + base * 2,
  283. priv->ping_total);
  284. return 0;
  285. }
  286. /* Check that we can perform operations on devices */
  287. static int dm_test_operations(struct dm_test_state *dms)
  288. {
  289. struct udevice *dev;
  290. int i;
  291. /*
  292. * Now check that the ping adds are what we expect. This is using the
  293. * ping-add property in each node.
  294. */
  295. for (i = 0; i < ARRAY_SIZE(test_pdata); i++) {
  296. uint32_t base;
  297. ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));
  298. /*
  299. * Get the 'reg' property, which tells us what the ping add
  300. * should be. We don't use the platdata because we want
  301. * to test the code that sets that up (testfdt_drv_probe()).
  302. */
  303. base = test_pdata[i].ping_add;
  304. debug("dev=%d, base=%d\n", i, base);
  305. ut_assert(!dm_check_operations(dms, dev, base, dev->priv));
  306. }
  307. return 0;
  308. }
  309. DM_TEST(dm_test_operations, DM_TESTF_SCAN_PDATA);
  310. /* Remove all drivers and check that things work */
  311. static int dm_test_remove(struct dm_test_state *dms)
  312. {
  313. struct udevice *dev;
  314. int i;
  315. for (i = 0; i < 3; i++) {
  316. ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
  317. ut_assert(dev);
  318. ut_assertf(dev->flags & DM_FLAG_ACTIVATED,
  319. "Driver %d/%s not activated", i, dev->name);
  320. ut_assertok(device_remove(dev));
  321. ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
  322. "Driver %d/%s should have deactivated", i,
  323. dev->name);
  324. ut_assert(!dev->priv);
  325. }
  326. return 0;
  327. }
  328. DM_TEST(dm_test_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST);
  329. /* Remove and recreate everything, check for memory leaks */
  330. static int dm_test_leak(struct dm_test_state *dms)
  331. {
  332. int i;
  333. for (i = 0; i < 2; i++) {
  334. struct udevice *dev;
  335. int ret;
  336. int id;
  337. dm_leak_check_start(dms);
  338. ut_assertok(dm_scan_platdata(false));
  339. ut_assertok(dm_scan_fdt(gd->fdt_blob, false));
  340. /* Scanning the uclass is enough to probe all the devices */
  341. for (id = UCLASS_ROOT; id < UCLASS_COUNT; id++) {
  342. for (ret = uclass_first_device(UCLASS_TEST, &dev);
  343. dev;
  344. ret = uclass_next_device(&dev))
  345. ;
  346. ut_assertok(ret);
  347. }
  348. ut_assertok(dm_leak_check_end(dms));
  349. }
  350. return 0;
  351. }
  352. DM_TEST(dm_test_leak, 0);
  353. /* Test uclass init/destroy methods */
  354. static int dm_test_uclass(struct dm_test_state *dms)
  355. {
  356. struct uclass *uc;
  357. ut_assertok(uclass_get(UCLASS_TEST, &uc));
  358. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
  359. ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
  360. ut_assert(uc->priv);
  361. ut_assertok(uclass_destroy(uc));
  362. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_INIT]);
  363. ut_asserteq(1, dm_testdrv_op_count[DM_TEST_OP_DESTROY]);
  364. return 0;
  365. }
  366. DM_TEST(dm_test_uclass, 0);
  367. /**
  368. * create_children() - Create children of a parent node
  369. *
  370. * @dms: Test system state
  371. * @parent: Parent device
  372. * @count: Number of children to create
  373. * @key: Key value to put in first child. Subsequence children
  374. * receive an incrementing value
  375. * @child: If not NULL, then the child device pointers are written into
  376. * this array.
  377. * @return 0 if OK, -ve on error
  378. */
  379. static int create_children(struct dm_test_state *dms, struct udevice *parent,
  380. int count, int key, struct udevice *child[])
  381. {
  382. struct udevice *dev;
  383. int i;
  384. for (i = 0; i < count; i++) {
  385. struct dm_test_pdata *pdata;
  386. ut_assertok(device_bind_by_name(parent, false,
  387. &driver_info_manual, &dev));
  388. pdata = calloc(1, sizeof(*pdata));
  389. pdata->ping_add = key + i;
  390. dev->platdata = pdata;
  391. if (child)
  392. child[i] = dev;
  393. }
  394. return 0;
  395. }
  396. #define NODE_COUNT 10
  397. static int dm_test_children(struct dm_test_state *dms)
  398. {
  399. struct udevice *top[NODE_COUNT];
  400. struct udevice *child[NODE_COUNT];
  401. struct udevice *grandchild[NODE_COUNT];
  402. struct udevice *dev;
  403. int total;
  404. int ret;
  405. int i;
  406. /* We don't care about the numbering for this test */
  407. dms->skip_post_probe = 1;
  408. ut_assert(NODE_COUNT > 5);
  409. /* First create 10 top-level children */
  410. ut_assertok(create_children(dms, dms->root, NODE_COUNT, 0, top));
  411. /* Now a few have their own children */
  412. ut_assertok(create_children(dms, top[2], NODE_COUNT, 2, NULL));
  413. ut_assertok(create_children(dms, top[5], NODE_COUNT, 5, child));
  414. /* And grandchildren */
  415. for (i = 0; i < NODE_COUNT; i++)
  416. ut_assertok(create_children(dms, child[i], NODE_COUNT, 50 * i,
  417. i == 2 ? grandchild : NULL));
  418. /* Check total number of devices */
  419. total = NODE_COUNT * (3 + NODE_COUNT);
  420. ut_asserteq(total, dm_testdrv_op_count[DM_TEST_OP_BIND]);
  421. /* Try probing one of the grandchildren */
  422. ut_assertok(uclass_get_device(UCLASS_TEST,
  423. NODE_COUNT * 3 + 2 * NODE_COUNT, &dev));
  424. ut_asserteq_ptr(grandchild[0], dev);
  425. /*
  426. * This should have probed the child and top node also, for a total
  427. * of 3 nodes.
  428. */
  429. ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_PROBE]);
  430. /* Probe the other grandchildren */
  431. for (i = 1; i < NODE_COUNT; i++)
  432. ut_assertok(device_probe(grandchild[i]));
  433. ut_asserteq(2 + NODE_COUNT, dm_testdrv_op_count[DM_TEST_OP_PROBE]);
  434. /* Probe everything */
  435. for (ret = uclass_first_device(UCLASS_TEST, &dev);
  436. dev;
  437. ret = uclass_next_device(&dev))
  438. ;
  439. ut_assertok(ret);
  440. ut_asserteq(total, dm_testdrv_op_count[DM_TEST_OP_PROBE]);
  441. /* Remove a top-level child and check that the children are removed */
  442. ut_assertok(device_remove(top[2]));
  443. ut_asserteq(NODE_COUNT + 1, dm_testdrv_op_count[DM_TEST_OP_REMOVE]);
  444. dm_testdrv_op_count[DM_TEST_OP_REMOVE] = 0;
  445. /* Try one with grandchildren */
  446. ut_assertok(uclass_get_device(UCLASS_TEST, 5, &dev));
  447. ut_asserteq_ptr(dev, top[5]);
  448. ut_assertok(device_remove(dev));
  449. ut_asserteq(1 + NODE_COUNT * (1 + NODE_COUNT),
  450. dm_testdrv_op_count[DM_TEST_OP_REMOVE]);
  451. /* Try the same with unbind */
  452. ut_assertok(device_unbind(top[2]));
  453. ut_asserteq(NODE_COUNT + 1, dm_testdrv_op_count[DM_TEST_OP_UNBIND]);
  454. dm_testdrv_op_count[DM_TEST_OP_UNBIND] = 0;
  455. /* Try one with grandchildren */
  456. ut_assertok(uclass_get_device(UCLASS_TEST, 5, &dev));
  457. ut_asserteq_ptr(dev, top[6]);
  458. ut_assertok(device_unbind(top[5]));
  459. ut_asserteq(1 + NODE_COUNT * (1 + NODE_COUNT),
  460. dm_testdrv_op_count[DM_TEST_OP_UNBIND]);
  461. return 0;
  462. }
  463. DM_TEST(dm_test_children, 0);
  464. /* Test that pre-relocation devices work as expected */
  465. static int dm_test_pre_reloc(struct dm_test_state *dms)
  466. {
  467. struct udevice *dev;
  468. /* The normal driver should refuse to bind before relocation */
  469. ut_asserteq(-EPERM, device_bind_by_name(dms->root, true,
  470. &driver_info_manual, &dev));
  471. /* But this one is marked pre-reloc */
  472. ut_assertok(device_bind_by_name(dms->root, true,
  473. &driver_info_pre_reloc, &dev));
  474. return 0;
  475. }
  476. DM_TEST(dm_test_pre_reloc, 0);
  477. static int dm_test_uclass_before_ready(struct dm_test_state *dms)
  478. {
  479. struct uclass *uc;
  480. ut_assertok(uclass_get(UCLASS_TEST, &uc));
  481. memset(gd, '\0', sizeof(*gd));
  482. ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
  483. return 0;
  484. }
  485. DM_TEST(dm_test_uclass_before_ready, 0);
  486. static int dm_test_device_get_uclass_id(struct dm_test_state *dms)
  487. {
  488. struct udevice *dev;
  489. ut_assertok(uclass_get_device(UCLASS_TEST, 0, &dev));
  490. ut_asserteq(UCLASS_TEST, device_get_uclass_id(dev));
  491. return 0;
  492. }
  493. DM_TEST(dm_test_device_get_uclass_id, DM_TESTF_SCAN_PDATA);