Thread (5 messages) 5 messages, 2 authors, 2015-07-03

[PATCH 1/3] video/logo: use list of logos to find logo

STALE4110d

From: Urs Fässler <hidden>
Date: 2015-07-03 08:46:03
Also in: lkml
Subsystem: framebuffer layer, the rest · Maintainers: Helge Deller, Linus Torvalds

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]
Refactoring of fb_find_logo: declare list of logos explicit and loop over
it to find a match.

Signed-off-by: Urs Fässler <redacted>
---
 drivers/video/logo/logo.c | 109 ++++++++++++++++++++++++++--------------------
 1 file changed, 62 insertions(+), 47 deletions(-)
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index 10fbfd8..d0a44db 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -36,82 +36,97 @@ static int __init fb_logo_late_init(void)
 
 late_initcall(fb_logo_late_init);
 
-/* logo's are marked __initdata. Use __init_refok to tell
- * modpost that it is intended that this function uses data
- * marked __initdata.
- */
-const struct linux_logo * __init_refok fb_find_logo(int depth)
-{
-	const struct linux_logo *logo = NULL;
 
-	if (nologo || logos_freed)
-		return NULL;
-
-	if (depth >= 1) {
+static const struct linux_logo *logos[] __initconst = {
 #ifdef CONFIG_LOGO_LINUX_MONO
-		/* Generic Linux logo */
-		logo = &logo_linux_mono;
+	/* Generic Linux logo */
+	&logo_linux_mono,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_MONO
-		/* SuperH Linux logo */
-		logo = &logo_superh_mono;
+	/* SuperH Linux logo */
+	&logo_superh_mono,
 #endif
-	}
-	
-	if (depth >= 4) {
 #ifdef CONFIG_LOGO_LINUX_VGA16
-		/* Generic Linux logo */
-		logo = &logo_linux_vga16;
+	/* Generic Linux logo */
+	&logo_linux_vga16,
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_VGA16
-		/* Blackfin processor logo */
-		logo = &logo_blackfin_vga16;
+	/* Blackfin processor logo */
+	&logo_blackfin_vga16,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_VGA16
-		/* SuperH Linux logo */
-		logo = &logo_superh_vga16;
+	/* SuperH Linux logo */
+	&logo_superh_vga16,
 #endif
-	}
-	
-	if (depth >= 8) {
 #ifdef CONFIG_LOGO_LINUX_CLUT224
-		/* Generic Linux logo */
-		logo = &logo_linux_clut224;
+	/* Generic Linux logo */
+	&logo_linux_clut224,
 #endif
 #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
-		/* Blackfin Linux logo */
-		logo = &logo_blackfin_clut224;
+	/* Blackfin Linux logo */
+	&logo_blackfin_clut224,
 #endif
 #ifdef CONFIG_LOGO_DEC_CLUT224
-		/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
-		logo = &logo_dec_clut224;
+	/* DEC Linux logo on MIPS/MIPS64 or ALPHA */
+	&logo_dec_clut224,
 #endif
-#ifdef CONFIG_LOGO_MAC_CLUT224
-		/* Macintosh Linux logo on m68k */
-		if (MACH_IS_MAC)
-			logo = &logo_mac_clut224;
+#if defined(CONFIG_LOGO_MAC_CLUT224) && MACH_IS_MAC
+	/* Macintosh Linux logo on m68k */
+	&logo_mac_clut224,
 #endif
 #ifdef CONFIG_LOGO_PARISC_CLUT224
-		/* PA-RISC Linux logo */
-		logo = &logo_parisc_clut224;
+	/* PA-RISC Linux logo */
+	&logo_parisc_clut224,
 #endif
 #ifdef CONFIG_LOGO_SGI_CLUT224
-		/* SGI Linux logo on MIPS/MIPS64 */
-		logo = &logo_sgi_clut224;
+	/* SGI Linux logo on MIPS/MIPS64 */
+	&logo_sgi_clut224,
 #endif
 #ifdef CONFIG_LOGO_SUN_CLUT224
-		/* Sun Linux logo */
-		logo = &logo_sun_clut224;
+	/* Sun Linux logo */
+	&logo_sun_clut224,
 #endif
 #ifdef CONFIG_LOGO_SUPERH_CLUT224
-		/* SuperH Linux logo */
-		logo = &logo_superh_clut224;
+	/* SuperH Linux logo */
+	&logo_superh_clut224,
 #endif
 #ifdef CONFIG_LOGO_M32R_CLUT224
-		/* M32R Linux logo */
-		logo = &logo_m32r_clut224;
+	/* M32R Linux logo */
+	&logo_m32r_clut224,
 #endif
+	NULL
+};
+
+static bool type_depth_compatible(int type, int depth)
+{
+	switch (type) {
+	case LINUX_LOGO_MONO:
+		return depth >= 1;
+	case LINUX_LOGO_VGA16:
+		return depth >= 4;
+	case LINUX_LOGO_CLUT224:
+		return depth >= 8;
+	default:
+		return false;
 	}
+}
+
+/* logo's are marked __initdata. Use __init_refok to tell
+ * modpost that it is intended that this function uses data
+ * marked __initdata.
+ */
+const struct linux_logo * __init_refok fb_find_logo(int depth)
+{
+	const struct linux_logo *logo = NULL;
+	const struct linux_logo **logos_itr;
+
+	if (nologo || logos_freed)
+		return NULL;
+
+	for (logos_itr = logos; *logos_itr != NULL; logos_itr++)
+		if (type_depth_compatible((*logos_itr)->type, depth))
+			logo = *logos_itr;
+
 	return logo;
 }
 EXPORT_SYMBOL_GPL(fb_find_logo);
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help