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]++;
38 static int test_pre_unbind(struct udevice *dev)
40 dm_testdrv_op_count[DM_TEST_OP_PRE_UNBIND]++;
45 static int test_post_probe(struct udevice *dev)
47 struct udevice *prev = list_entry(dev->uclass_node.prev,
48 struct udevice, uclass_node);
50 struct dm_test_uclass_perdev_priv *priv = dev->uclass_priv;
51 struct uclass *uc = dev->uclass;
53 dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]++;
55 ut_assert(device_active(dev));
57 if (dms->skip_post_probe)
59 if (&prev->uclass_node != &uc->dev_head) {
60 struct dm_test_uclass_perdev_priv *prev_uc_priv
62 struct dm_test_pdata *pdata = prev->platdata;
65 ut_assert(prev_uc_priv);
66 priv->base_add = prev_uc_priv->base_add + pdata->ping_add;
72 static int test_pre_remove(struct udevice *dev)
74 dm_testdrv_op_count[DM_TEST_OP_PRE_REMOVE]++;
79 static int test_init(struct uclass *uc)
81 dm_testdrv_op_count[DM_TEST_OP_INIT]++;
87 static int test_destroy(struct uclass *uc)
89 dm_testdrv_op_count[DM_TEST_OP_DESTROY]++;
94 UCLASS_DRIVER(test) = {
97 .post_bind = test_post_bind,
98 .pre_unbind = test_pre_unbind,
99 .post_probe = test_post_probe,
100 .pre_remove = test_pre_remove,
102 .destroy = test_destroy,
103 .priv_auto_alloc_size = sizeof(struct dm_test_uclass_priv),
104 .per_device_auto_alloc_size = sizeof(struct dm_test_uclass_perdev_priv),