Building with CONFIG_VIDEO enabled but CONFIG_VIDEO_LOGO disabled fails
at link time:
video-uclass.o: in function `video_get_u_boot_logo':
video-uclass.c:593: undefined reference to `__splash_u_boot_logo_begin'
The __splash_u_boot_logo_begin/_end symbols are provided by
u_boot_logo.bmp.o, which is only built when CONFIG_VIDEO_LOGO is set:
obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.bmp.o
The only remaining caller, video_post_probe(), is fine: it sits under an
if (CONFIG_IS_ENABLED(VIDEO_LOGO) && ...) check and is eliminated when
the logo is disabled. video_get_u_boot_logo() however is an exported
function and is always emitted, leaving the reference dangling.
Guard the splash symbol declaration and video_get_u_boot_logo() with
CONFIG_IS_ENABLED(VIDEO_LOGO), and provide a static inline stub
returning NULL for the disabled case in video.h. Callers already handle
a NULL logo pointer (e.g. bootflow_menu.c), so no caller changes are
needed.
Reproduce with any board that enables VIDEO without VIDEO_LOGO or
enabling SPLASH_SCREEN (it disables automatically VIDEO_LOGO).
Fixes: 0d3890188d6b ("video: Add function to obtain the U-Boot logo")
Signed-off-by: Julien Stephan <[email protected]>
---
drivers/video/video-uclass.c | 2 ++
include/video.h | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 1a268137bde..22183d00d97 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -579,6 +579,7 @@ int video_get_ysize(struct udevice *dev)
return priv->ysize;
}
+#if CONFIG_IS_ENABLED(VIDEO_LOGO)
#define SPLASH_DECL(_name) \
extern u8 __splash_ ## _name ## _begin[]; \
extern u8 __splash_ ## _name ## _end[]
@@ -591,6 +592,7 @@ void *video_get_u_boot_logo(void)
{
return SPLASH_START(u_boot_logo);
}
+#endif
int video_default_font_height(struct udevice *dev)
{
diff --git a/include/video.h b/include/video.h
index 9ea6b676463..8e4c1544e56 100644
--- a/include/video.h
+++ b/include/video.h
@@ -418,9 +418,16 @@ bool video_is_active(void);
/**
* video_get_u_boot_logo() - Get a pointer to the U-Boot logo
*
- * Returns: Pointer to logo
+ * Returns: Pointer to logo, or NULL if CONFIG_VIDEO_LOGO is disabled
*/
+#if CONFIG_IS_ENABLED(VIDEO_LOGO)
void *video_get_u_boot_logo(void);
+#else
+static inline void *video_get_u_boot_logo(void)
+{
+ return NULL;
+}
+#endif
/*
* bmp_display() - Display BMP (bitmap) data located in memory
--
2.55.0