video/logo: prevent use of logos after they have been freed
[pandora-kernel.git] / drivers / video / logo / logo.c
1
2 /*
3  *  Linux logo to be displayed on boot
4  *
5  *  Copyright (C) 1996 Larry Ewing (lewing@isc.tamu.edu)
6  *  Copyright (C) 1996,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7  *  Copyright (C) 2001 Greg Banks <gnb@alphalink.com.au>
8  *  Copyright (C) 2001 Jan-Benedict Glaw <jbglaw@lug-owl.de>
9  *  Copyright (C) 2003 Geert Uytterhoeven <geert@linux-m68k.org>
10  */
11
12 #include <linux/linux_logo.h>
13 #include <linux/stddef.h>
14 #include <linux/module.h>
15
16 #ifdef CONFIG_M68K
17 #include <asm/setup.h>
18 #endif
19
20 #ifdef CONFIG_MIPS
21 #include <asm/bootinfo.h>
22 #endif
23
24 static int nologo;
25 module_param(nologo, bool, 0);
26 MODULE_PARM_DESC(nologo, "Disables startup logo");
27
28 /*
29  * Logos are located in the initdata, and will be freed in kernel_init.
30  * Use late_init to mark the logos as freed to prevent any further use.
31  */
32
33 static bool logos_freed;
34
35 static int __init fb_logo_late_init(void)
36 {
37         logos_freed = true;
38         return 0;
39 }
40
41 late_initcall(fb_logo_late_init);
42
43 /* logo's are marked __initdata. Use __init_refok to tell
44  * modpost that it is intended that this function uses data
45  * marked __initdata.
46  */
47 const struct linux_logo * __init_refok fb_find_logo(int depth)
48 {
49         const struct linux_logo *logo = NULL;
50
51         if (nologo || logos_freed)
52                 return NULL;
53
54         if (depth >= 1) {
55 #ifdef CONFIG_LOGO_LINUX_MONO
56                 /* Generic Linux logo */
57                 logo = &logo_linux_mono;
58 #endif
59 #ifdef CONFIG_LOGO_SUPERH_MONO
60                 /* SuperH Linux logo */
61                 logo = &logo_superh_mono;
62 #endif
63         }
64         
65         if (depth >= 4) {
66 #ifdef CONFIG_LOGO_LINUX_VGA16
67                 /* Generic Linux logo */
68                 logo = &logo_linux_vga16;
69 #endif
70 #ifdef CONFIG_LOGO_BLACKFIN_VGA16
71                 /* Blackfin processor logo */
72                 logo = &logo_blackfin_vga16;
73 #endif
74 #ifdef CONFIG_LOGO_SUPERH_VGA16
75                 /* SuperH Linux logo */
76                 logo = &logo_superh_vga16;
77 #endif
78         }
79         
80         if (depth >= 8) {
81 #ifdef CONFIG_LOGO_LINUX_CLUT224
82                 /* Generic Linux logo */
83                 logo = &logo_linux_clut224;
84 #endif
85 #ifdef CONFIG_LOGO_BLACKFIN_CLUT224
86                 /* Blackfin Linux logo */
87                 logo = &logo_blackfin_clut224;
88 #endif
89 #ifdef CONFIG_LOGO_DEC_CLUT224
90                 /* DEC Linux logo on MIPS/MIPS64 or ALPHA */
91                 logo = &logo_dec_clut224;
92 #endif
93 #ifdef CONFIG_LOGO_MAC_CLUT224
94                 /* Macintosh Linux logo on m68k */
95                 if (MACH_IS_MAC)
96                         logo = &logo_mac_clut224;
97 #endif
98 #ifdef CONFIG_LOGO_PARISC_CLUT224
99                 /* PA-RISC Linux logo */
100                 logo = &logo_parisc_clut224;
101 #endif
102 #ifdef CONFIG_LOGO_SGI_CLUT224
103                 /* SGI Linux logo on MIPS/MIPS64 and VISWS */
104                 logo = &logo_sgi_clut224;
105 #endif
106 #ifdef CONFIG_LOGO_SUN_CLUT224
107                 /* Sun Linux logo */
108                 logo = &logo_sun_clut224;
109 #endif
110 #ifdef CONFIG_LOGO_SUPERH_CLUT224
111                 /* SuperH Linux logo */
112                 logo = &logo_superh_clut224;
113 #endif
114 #ifdef CONFIG_LOGO_M32R_CLUT224
115                 /* M32R Linux logo */
116                 logo = &logo_m32r_clut224;
117 #endif
118         }
119         return logo;
120 }
121 EXPORT_SYMBOL_GPL(fb_find_logo);