From b18b38f2ae3f54b906e0f2ab86789d9dd0110ed2 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 30 Jul 2021 12:13:11 +0200 Subject: dm: migrate the dm_warn to use the log macro Migrate the dm_warn function to log macro with LOGC_DM category and LOGL_WARNING level. This macro allows filtering with log command and allows output on all log backend. Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- include/dm/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/util.h b/include/dm/util.h index 138893c..c634e47 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -7,7 +7,7 @@ #define __DM_UTIL_H #if CONFIG_IS_ENABLED(DM_WARN) -void dm_warn(const char *fmt, ...); +#define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt) #else static inline void dm_warn(const char *fmt, ...) { -- cgit v1.1 From 1e9ced28f18ed75bef96df08e47baad27dd51829 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Aug 2021 12:05:23 -0600 Subject: dm: core: Don't allow uclass use before ready At present it is possible to call uclass_get() before driver model is inited. In fact this happens on x86 boards which use Intel FSPv1, since mrccache_get_region() tries to get the SPI flash device very early during init. This has always been undefined behaviour. Previously it generally worked, i.e. returned an error code without crashing, because gd->uclass_root_s is zeroed and the uclass can be added despite driver model not being ready, due to the way lists are implemented. With the change to use a gd->uclass_root pointer, this no-longer works. For example, it causes a hang on minnowmax. Fix this by adding a check that driver model is ready when uclass_get() is called. This function is called in the process of locating any device, so it is a good place to add the check. This fixes booting on minnowmax. Signed-off-by: Simon Glass Fixes: 8a715530bb1 ("dm: core: Allow the uclass list to move") --- include/dm/uclass.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/uclass.h b/include/dm/uclass.h index 2778818..da0c1bf 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); -- cgit v1.1