diff options
-rw-r--r-- | drivers/core/uclass.c | 3 | ||||
-rw-r--r-- | include/dm/uclass.h | 3 | ||||
-rw-r--r-- | test/dm/core.c | 1 |
3 files changed, 6 insertions, 1 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 117d35ac49..3146dfd032 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -146,6 +146,9 @@ int uclass_get(enum uclass_id id, struct uclass **ucp) { struct uclass *uc; + /* Immediately fail if driver model is not set up */ + if (!gd->uclass_root) + return -EDEADLK; *ucp = NULL; uc = uclass_find(id); if (!uc) { diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 2778818b52..da0c1bfadb 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -159,7 +159,8 @@ void *uclass_get_priv(const struct uclass *uc); * * @key: ID to look up * @ucp: Returns pointer to uclass (there is only one per ID) - * @return 0 if OK, -ve on error + * @return 0 if OK, -EDEADLK if driver model is not yet inited, other -ve on + * other error */ int uclass_get(enum uclass_id key, struct uclass **ucp); diff --git a/test/dm/core.c b/test/dm/core.c index 48e66b7333..c9a7606666 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -994,6 +994,7 @@ static int dm_test_uclass_before_ready(struct unit_test_state *uts) memset(&gd->uclass_root, '\0', sizeof(gd->uclass_root)); ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST)); + ut_asserteq(-EDEADLK, uclass_get(UCLASS_TEST, &uc)); return 0; } |