2 * Copyright (c) 2013 Google, Inc
5 * Pavel Herrmann <morpheus.ibis@gmail.com>
7 * SPDX-License-Identifier: GPL-2.0+
17 #include <linux/list.h>
19 static struct dm_test_state *dms = &global_test_state;
21 int test_ping(struct udevice *dev, int pingval, int *pingret)
23 const struct test_ops *ops = device_get_ops(dev);
28 return ops->ping(dev, pingval, pingret);
31 static int test_post_bind(struct udevice *dev)
33 dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
34 ut_assert(!device_active(dev));
39 static int test_pre_unbind(struct udevice *dev)
41 dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]++;
46 static int test_pre_probe(struct udevice *dev)
48 struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
50 dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++;
52 ut_assert(device_active(dev));
57 static int test_post_probe(struct udevice *dev)
59 struct udevice *prev = list_entry(dev->uclass_node.prev,
60 struct udevice, uclass_node);
62 struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
63 struct uclass *uc = dev->uclass;
65 dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]++;
67 ut_assert(device_active(dev));
69 if (dms->skip_post_probe)
71 if (&prev->uclass_node != &uc->dev_head) {
72 struct dm_test_uclass_perdev_priv *prev_uc_priv
73 = dev_get_uclass_priv(prev);
74 struct dm_test_pdata *pdata = prev->platdata;
77 ut_assert(prev_uc_priv);
78 priv->base_add = prev_uc_priv->base_add + pdata->ping_add;
84 static int test_pre_remove(struct udevice *dev)
86 dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]++;
91 static int test_init(struct uclass *uc)
93 dm_testdrv_op_count[DM_TEST_OP_INIT]++;
99 static int test_destroy(struct uclass *uc)
101 dm_testdrv_op_count[DM_TEST_OP_DESTROY]++;
106 UCLASS_DRIVER(test) = {
109 .post_bind = test_post_bind,
110 .pre_unbind = test_pre_unbind,
111 .pre_probe = test_pre_probe,
112 .post_probe = test_post_probe,
113 .pre_remove = test_pre_remove,
115 .destroy = test_destroy,
116 .priv_auto_alloc_size = sizeof(struct dm_test_uclass_priv),
117 .per_device_auto_alloc_size = sizeof(struct dm_test_uclass_perdev_priv),