summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorNikhil M Jain <n-jain1@ti.com>2023-06-09 14:29:51 +0530
committerUdit Kumar <u-kumar1@ti.com>2023-06-12 09:49:41 +0530
commitdb4ff145fb2add1b43936f8f84b66d0682f18295 (patch)
tree4bf4e559dfc296d8de72f8fa997176834c94dde4 /common
parent1d9e0f476df3230995db687a0088ae2c0d68f246 (diff)
common: Replace #ifdef and #if with if's
Avoid using preprocessor compilation directives and instead use simple logical expressions for better readability since compiler will anyway optimize out the respective code block if condition is not satisfied. Signed-off-by: Nikhil M Jain <n-jain1@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Devarsh Thakkar <devarsht@ti.com>
Diffstat (limited to 'common')
-rw-r--r--common/bmp.c14
-rw-r--r--common/splash.c14
2 files changed, 12 insertions, 16 deletions
diff --git a/common/bmp.c b/common/bmp.c
index ad91351f19..57764f3653 100644
--- a/common/bmp.c
+++ b/common/bmp.c
@@ -31,9 +31,9 @@
* by the caller after use.
*
* Returns NULL if decompression failed, or if the decompressed data
- * didn't contain a valid BMP signature.
+ * didn't contain a valid BMP signature or decompression is not enabled in
+ * Kconfig.
*/
-#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)
struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
void **alloc_addr)
{
@@ -41,6 +41,9 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
unsigned long len;
struct bmp_image *bmp;
+ if (!CONFIG_IS_ENABLED(VIDEO_BMP_GZIP))
+ return NULL;
+
/*
* Decompress bmp image
*/
@@ -77,13 +80,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
*alloc_addr = dst;
return bmp;
}
-#else
-struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
- void **alloc_addr)
-{
- return NULL;
-}
-#endif
#ifdef CONFIG_NEEDS_MANUAL_RELOC
void bmp_reloc(void)
diff --git a/common/splash.c b/common/splash.c
index 3bc01bef63..e77b72e9e2 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -96,12 +96,11 @@ __weak int splash_screen_prepare(void)
return splash_video_logo_load();
}
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
void splash_get_pos(int *x, int *y)
{
char *s = env_get("splashpos");
- if (!s)
+ if (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || !s)
return;
if (s[0] == 'm')
@@ -117,7 +116,6 @@ void splash_get_pos(int *x, int *y)
*y = simple_strtol(s + 1, NULL, 0);
}
}
-#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
#if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
@@ -157,13 +155,13 @@ void splash_display_banner(void)
* Common function to show a splash image if env("splashimage") is set.
* For additional details please refer to doc/README.splashprepare.
*/
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
int splash_display(void)
{
ulong addr;
char *s;
int x = 0, y = 0, ret;
-
+ if (!CONFIG_IS_ENABLED(SPLASH_SCREEN))
+ return -ENOSYS;
s = env_get("splashimage");
if (!s)
return -EINVAL;
@@ -175,7 +173,10 @@ int splash_display(void)
splash_get_pos(&x, &y);
- ret = bmp_display(addr, x, y);
+ if (CONFIG_IS_ENABLED(BMP))
+ ret = bmp_display(addr, x, y);
+ else
+ return -ENOSYS;
/* Skip banner output on video console if the logo is not at 0,0 */
if (x || y)
@@ -187,4 +188,3 @@ int splash_display(void)
end:
return ret;
}
-#endif