mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
test: dm: Add compatible multimatch test
Add a test for binding of multiple drivers with the same compatible. If one of the drivers returns -ENODEV the other one needs to be bound. Reviewed-by: Simon Glass <simon.glass@canonical.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org> Signed-off-by: Markus Schneider-Pargmann (TI.com) <msp@baylibre.com>
This commit is contained in:
committed by
Tom Rini
parent
87d7d8190f
commit
c7e0e3fd33
@@ -457,6 +457,10 @@
|
||||
mux-control-names = "mux0";
|
||||
};
|
||||
|
||||
multimatch-test {
|
||||
compatible = "sandbox,multimatch-test";
|
||||
};
|
||||
|
||||
phy_provider0: gen_phy@0 {
|
||||
compatible = "sandbox,phy";
|
||||
#phy-cells = <1>;
|
||||
|
||||
@@ -1410,3 +1410,18 @@ static int dm_test_try_first_device(struct unit_test_state *uts)
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_try_first_device, 0);
|
||||
|
||||
/* Test that all drivers are iterated when bind returns -ENODEV */
|
||||
static int dm_test_multimatch(struct unit_test_state *uts)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
||||
ut_assertok(uclass_find_device_by_name(UCLASS_TEST, "multimatch-test",
|
||||
&dev));
|
||||
ut_assertnonnull(dev);
|
||||
ut_asserteq_str("test_multimatch_second", dev->driver->name);
|
||||
ut_asserteq(2, dm_testdrv_op_count[DM_TEST_OP_BIND]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_multimatch, UTF_SCAN_FDT);
|
||||
|
||||
@@ -197,3 +197,29 @@ U_BOOT_DRIVER(test_act_dma_vital_clk_drv) = {
|
||||
.unbind = test_manual_unbind,
|
||||
.flags = DM_FLAG_VITAL | DM_FLAG_ACTIVE_DMA,
|
||||
};
|
||||
|
||||
static int test_multimatch_first_bind(struct udevice *dev)
|
||||
{
|
||||
dm_testdrv_op_count[DM_TEST_OP_BIND]++;
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static const struct udevice_id test_multimatch_ids[] = {
|
||||
{ .compatible = "sandbox,multimatch-test" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(test_multimatch_first) = {
|
||||
.name = "test_multimatch_first",
|
||||
.id = UCLASS_TEST,
|
||||
.of_match = test_multimatch_ids,
|
||||
.bind = test_multimatch_first_bind,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(test_multimatch_second) = {
|
||||
.name = "test_multimatch_second",
|
||||
.id = UCLASS_TEST,
|
||||
.of_match = test_multimatch_ids,
|
||||
.bind = test_manual_bind,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user