[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1435912696-17546-2-git-send-email-urs.fassler@bytesatwork.ch>
Date: Fri, 3 Jul 2015 10:38:14 +0200
From: Urs Fässler <urs.fassler@...esatwork.ch>
To: daniel.vetter@...ll.ch, linux-fbdev@...r.kernel.org,
linux-kernel@...r.kernel.org, oliver.staebler@...esatwork.ch,
plagnioj@...osoft.com, tomi.valkeinen@...com,
urs.fassler@...esatwork.ch
Subject: [PATCH 1/3] video/logo: use list of logos to find logo
Refactoring of fb_find_logo: declare list of logos explicit and loop over
it to find a match.
Signed-off-by: Urs Fässler <urs.fassler@...esatwork.ch>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists