From 6e43d1b19982b1756b7c607569d1778e556d6577 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 28 Dec 2017 13:14:15 -0700 Subject: dm: core: Add a function to look up a uclass by name Each uclass has a driver name which we can use to look up the uclass. This is useful for logging, where the uclass ID is used as the category. Add a function to handle this, as well as a test. Signed-off-by: Simon Glass --- test/dm/core.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/dm/core.c b/test/dm/core.c index 50ee41b9e2..052bf8fffb 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -862,3 +862,12 @@ static int dm_test_device_get_uclass_id(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_device_get_uclass_id, DM_TESTF_SCAN_PDATA); + +static int dm_test_uclass_names(struct unit_test_state *uts) +{ + ut_asserteq_str("test", uclass_get_name(UCLASS_TEST)); + ut_asserteq(UCLASS_TEST, uclass_get_by_name("test")); + + return 0; +} +DM_TEST(dm_test_uclass_names, DM_TESTF_SCAN_PDATA); -- cgit v1.2.3