Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754646AbbGCIqD (ORCPT ); Fri, 3 Jul 2015 04:46:03 -0400 Received: from bytesatwork.ch ([91.135.72.15]:33783 "EHLO bytesatwork.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754509AbbGCIpR (ORCPT ); Fri, 3 Jul 2015 04:45:17 -0400 From: =?UTF-8?q?Urs=20F=C3=A4ssler?= 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 Message-Id: <1435912696-17546-2-git-send-email-urs.fassler@bytesatwork.ch> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435912696-17546-1-git-send-email-urs.fassler@bytesatwork.ch> References: <1435912696-17546-1-git-send-email-urs.fassler@bytesatwork.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4275 Lines: 165 Refactoring of fb_find_logo: declare list of logos explicit and loop over it to find a match. Signed-off-by: Urs Fässler --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/