X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=test%2Fdm%2Ftest-driver.c;h=d10af5114738cc62f3e077a7b47de5d2c90f58ae;hb=40b6f2d020ca8074ed38a1b6bfa170aead1a170e;hp=c4be8a12d71a5518cdc735f821c6e459e25370bd;hpb=1cad23c5f471d695bed1e3907e30caee3c2a3056;p=oweals%2Fu-boot.git diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index c4be8a12d7..d10af51147 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -12,13 +12,13 @@ #include #include #include -#include +#include #include int dm_testdrv_op_count[DM_TEST_OP_COUNT]; -static struct dm_test_state *dms = &global_test_state; +static struct unit_test_state *uts = &global_dm_test_state; -static int testdrv_ping(struct device *dev, int pingval, int *pingret) +static int testdrv_ping(struct udevice *dev, int pingval, int *pingret) { const struct dm_test_pdata *pdata = dev_get_platdata(dev); struct dm_test_priv *priv = dev_get_priv(dev); @@ -33,7 +33,7 @@ static const struct test_ops test_ops = { .ping = testdrv_ping, }; -static int test_bind(struct device *dev) +static int test_bind(struct udevice *dev) { /* Private data should not be allocated */ ut_assert(!dev_get_priv(dev)); @@ -42,7 +42,7 @@ static int test_bind(struct device *dev) return 0; } -static int test_probe(struct device *dev) +static int test_probe(struct udevice *dev) { struct dm_test_priv *priv = dev_get_priv(dev); @@ -54,7 +54,7 @@ static int test_probe(struct device *dev) return 0; } -static int test_remove(struct device *dev) +static int test_remove(struct udevice *dev) { /* Private data should still be allocated */ ut_assert(dev_get_priv(dev)); @@ -63,7 +63,7 @@ static int test_remove(struct device *dev) return 0; } -static int test_unbind(struct device *dev) +static int test_unbind(struct udevice *dev) { /* Private data should not be allocated */ ut_assert(!dev->priv); @@ -94,7 +94,7 @@ U_BOOT_DRIVER(test2_drv) = { .priv_auto_alloc_size = sizeof(struct dm_test_priv), }; -static int test_manual_drv_ping(struct device *dev, int pingval, int *pingret) +static int test_manual_drv_ping(struct udevice *dev, int pingval, int *pingret) { *pingret = pingval + 2; @@ -105,15 +105,17 @@ static const struct test_ops test_manual_ops = { .ping = test_manual_drv_ping, }; -static int test_manual_bind(struct device *dev) +static int test_manual_bind(struct udevice *dev) { dm_testdrv_op_count[DM_TEST_OP_BIND]++; return 0; } -static int test_manual_probe(struct device *dev) +static int test_manual_probe(struct udevice *dev) { + struct dm_test_state *dms = uts->priv; + dm_testdrv_op_count[DM_TEST_OP_PROBE]++; if (!dms->force_fail_alloc) dev->priv = calloc(1, sizeof(struct dm_test_priv)); @@ -123,13 +125,13 @@ static int test_manual_probe(struct device *dev) return 0; } -static int test_manual_remove(struct device *dev) +static int test_manual_remove(struct udevice *dev) { dm_testdrv_op_count[DM_TEST_OP_REMOVE]++; return 0; } -static int test_manual_unbind(struct device *dev) +static int test_manual_unbind(struct udevice *dev) { dm_testdrv_op_count[DM_TEST_OP_UNBIND]++; return 0; @@ -144,3 +146,14 @@ U_BOOT_DRIVER(test_manual_drv) = { .remove = test_manual_remove, .unbind = test_manual_unbind, }; + +U_BOOT_DRIVER(test_pre_reloc_drv) = { + .name = "test_pre_reloc_drv", + .id = UCLASS_TEST, + .ops = &test_manual_ops, + .bind = test_manual_bind, + .probe = test_manual_probe, + .remove = test_manual_remove, + .unbind = test_manual_unbind, + .flags = DM_FLAG_PRE_RELOC, +};