diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2018-08-03 01:14:48 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-08-08 12:49:31 +0100 |
commit | 82b310430892d56a9cf1942a19ea33d9d8e47243 (patch) | |
tree | 3ac9f230d53dbd803be356763dd77ed6ba475320 | |
parent | 490d13a523cac0cdddf44fef492ad6493b342489 (diff) |
test: dm: pci: Test driver binding with driver data provided
With struct pci_device_id, it's possible to pass a driver data for
bound driver to use. This adds a test case for this functionality.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/dm/pci.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/dm/pci.c b/test/dm/pci.c index 089b72ee86..53d2ca1671 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -108,3 +108,20 @@ static int dm_test_pci_swapcase(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_pci_swapcase, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test that we can dynamically bind the device driver correctly */ +static int dm_test_pci_drvdata(struct unit_test_state *uts) +{ + struct udevice *bus, *swap; + + /* Check that asking for the device automatically fires up PCI */ + ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 1, &bus)); + + ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap)); + ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data); + ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap)); + ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data); + + return 0; +} +DM_TEST(dm_test_pci_drvdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |