From: "Urs Fässler" <urs.fassler@bytesatwork.ch>
To: daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org,
linux-kernel@vger.kernel.org, oliver.staebler@bytesatwork.ch,
plagnioj@jcrosoft.com, tomi.valkeinen@ti.com,
urs.fassler@bytesatwork.ch
Subject: [PATCH 1/3] video/logo: use list of logos to find logo
Date: Fri, 3 Jul 2015 10:38:14 +0200 [thread overview]
Message-ID: <1435912696-17546-2-git-send-email-urs.fassler@bytesatwork.ch> (raw)
In-Reply-To: <1435912696-17546-1-git-send-email-urs.fassler@bytesatwork.ch>
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@bytesatwork.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
next prev parent reply other threads:[~2015-07-03 8:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 8:38 [PATCH 0/3] video/logo: add option to return largest logo for a given resolution Urs Fässler
2015-07-03 8:38 ` Urs Fässler [this message]
2015-07-03 9:13 ` [PATCH 1/3] video/logo: use list of logos to find logo Geert Uytterhoeven
2015-07-03 8:38 ` [PATCH 2/3] logo: add option to return largest logo for a given resolution Urs Fässler
2015-07-03 8:38 ` [PATCH 3/3] fbdev: use largest logo if possible Urs Fässler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435912696-17546-2-git-send-email-urs.fassler@bytesatwork.ch \
--to=urs.fassler@bytesatwork.ch \
--cc=daniel.vetter@ffwll.ch \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.staebler@bytesatwork.ch \
--cc=plagnioj@jcrosoft.com \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox