From: "Jan Beulich" const-ify the font control structures and data, to make somewhat better guarantees that these are not modified anywhere in the kernel. Specifically for a kernel debugger to share this information from the normal kernel code, such a guarantee seems rather desirable. Signed-off-by: Jan Beulich Cc: "Antonino A. Daplas" Signed-off-by: Andrew Morton --- drivers/video/console/fbcon.c | 16 ++++++++-------- drivers/video/console/fbcon.h | 2 +- drivers/video/console/font_10x18.c | 4 ++-- drivers/video/console/font_6x11.c | 4 ++-- drivers/video/console/font_7x14.c | 4 ++-- drivers/video/console/font_8x16.c | 4 ++-- drivers/video/console/font_8x8.c | 4 ++-- drivers/video/console/font_acorn_8x8.c | 4 ++-- drivers/video/console/font_mini_4x6.c | 4 ++-- drivers/video/console/font_pearl_8x8.c | 4 ++-- drivers/video/console/font_sun12x22.c | 4 ++-- drivers/video/console/font_sun8x16.c | 4 ++-- drivers/video/console/fonts.c | 9 ++++----- include/linux/fb.h | 2 +- include/linux/font.h | 10 +++++----- 15 files changed, 39 insertions(+), 40 deletions(-) diff -puN drivers/video/console/fbcon.c~fbcon-constify-font-data drivers/video/console/fbcon.c --- 25/drivers/video/console/fbcon.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/fbcon.c Fri Sep 9 16:59:45 2005 @@ -767,7 +767,7 @@ static const char *fbcon_startup(void) const char *display_desc = "frame buffer device"; struct display *p = &fb_display[fg_console]; struct vc_data *vc = vc_cons[fg_console].d; - struct font_desc *font = NULL; + const struct font_desc *font = NULL; struct module *owner; struct fb_info *info = NULL; struct fbcon_ops *ops; @@ -841,7 +841,7 @@ static const char *fbcon_startup(void) info->var.yres); vc->vc_font.width = font->width; vc->vc_font.height = font->height; - vc->vc_font.data = p->fontdata = font->data; + vc->vc_font.data = (void *)(p->fontdata = font->data); vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ } @@ -941,7 +941,7 @@ static void fbcon_init(struct vc_data *v fb, copy the font from that console */ t = &fb_display[svc->vc_num]; if (!vc->vc_font.data) { - vc->vc_font.data = p->fontdata = t->fontdata; + vc->vc_font.data = (void *)(p->fontdata = t->fontdata); vc->vc_font.width = (*default_mode)->vc_font.width; vc->vc_font.height = (*default_mode)->vc_font.height; p->userfont = t->userfont; @@ -1188,7 +1188,7 @@ static void fbcon_set_disp(struct fb_inf return; t = &fb_display[svc->vc_num]; if (!vc->vc_font.data) { - vc->vc_font.data = p->fontdata = t->fontdata; + vc->vc_font.data = (void *)(p->fontdata = t->fontdata); vc->vc_font.width = (*default_mode)->vc_font.width; vc->vc_font.height = (*default_mode)->vc_font.height; p->userfont = t->userfont; @@ -2150,7 +2150,7 @@ static int fbcon_get_font(struct vc_data } static int fbcon_do_set_font(struct vc_data *vc, int w, int h, - u8 * data, int userfont) + const u8 * data, int userfont) { struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; struct display *p = &fb_display[vc->vc_num]; @@ -2168,7 +2168,7 @@ static int fbcon_do_set_font(struct vc_d cnt = FNTCHARCNT(data); else cnt = 256; - vc->vc_font.data = p->fontdata = data; + vc->vc_font.data = (void *)(p->fontdata = data); if ((p->userfont = userfont)) REFCOUNT(data)++; vc->vc_font.width = w; @@ -2325,7 +2325,7 @@ static int fbcon_set_font(struct vc_data tmp->vc_font.width == w && !memcmp(fb_display[i].fontdata, new_data, size)) { kfree(new_data - FONT_EXTRA_WORDS * sizeof(int)); - new_data = fb_display[i].fontdata; + new_data = (u8 *)fb_display[i].fontdata; break; } } @@ -2335,7 +2335,7 @@ static int fbcon_set_font(struct vc_data static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name) { struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; - struct font_desc *f; + const struct font_desc *f; if (!name) f = get_default_font(info->var.xres, info->var.yres); diff -puN drivers/video/console/fbcon.h~fbcon-constify-font-data drivers/video/console/fbcon.h --- 25/drivers/video/console/fbcon.h~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/fbcon.h Fri Sep 9 16:59:45 2005 @@ -30,7 +30,7 @@ struct display { /* Filled in by the frame buffer device */ u_short inverse; /* != 0 text black on white as default */ /* Filled in by the low-level console driver */ - u_char *fontdata; + const u_char *fontdata; int userfont; /* != 0 if fontdata kmalloc()ed */ u_short scrollmode; /* Scroll Method */ short yscroll; /* Hardware scrolling */ diff -puN drivers/video/console/font_10x18.c~fbcon-constify-font-data drivers/video/console/font_10x18.c --- 25/drivers/video/console/font_10x18.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_10x18.c Fri Sep 9 16:59:45 2005 @@ -7,7 +7,7 @@ #define FONTDATAMAX 9216 -static unsigned char fontdata_10x18[FONTDATAMAX] = { +static const unsigned char fontdata_10x18[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, 0x00, /* 0000000000 */ @@ -5132,7 +5132,7 @@ static unsigned char fontdata_10x18[FONT }; -struct font_desc font_10x18 = { +const struct font_desc font_10x18 = { FONT10x18_IDX, "10x18", 10, diff -puN drivers/video/console/font_6x11.c~fbcon-constify-font-data drivers/video/console/font_6x11.c --- 25/drivers/video/console/font_6x11.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_6x11.c Fri Sep 9 16:59:45 2005 @@ -8,7 +8,7 @@ #define FONTDATAMAX (11*256) -static unsigned char fontdata_6x11[FONTDATAMAX] = { +static const unsigned char fontdata_6x11[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, /* 00000000 */ @@ -3341,7 +3341,7 @@ static unsigned char fontdata_6x11[FONTD }; -struct font_desc font_vga_6x11 = { +const struct font_desc font_vga_6x11 = { VGA6x11_IDX, "ProFont6x11", 6, diff -puN drivers/video/console/font_7x14.c~fbcon-constify-font-data drivers/video/console/font_7x14.c --- 25/drivers/video/console/font_7x14.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_7x14.c Fri Sep 9 16:59:45 2005 @@ -7,7 +7,7 @@ #define FONTDATAMAX 3584 -static unsigned char fontdata_7x14[FONTDATAMAX] = { +static const unsigned char fontdata_7x14[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, /* 0000000 */ @@ -4108,7 +4108,7 @@ static unsigned char fontdata_7x14[FONTD }; -struct font_desc font_7x14 = { +const struct font_desc font_7x14 = { FONT7x14_IDX, "7x14", 7, diff -puN drivers/video/console/font_8x16.c~fbcon-constify-font-data drivers/video/console/font_8x16.c --- 25/drivers/video/console/font_8x16.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_8x16.c Fri Sep 9 16:59:45 2005 @@ -8,7 +8,7 @@ #define FONTDATAMAX 4096 -static unsigned char fontdata_8x16[FONTDATAMAX] = { +static const unsigned char fontdata_8x16[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, /* 00000000 */ @@ -4621,7 +4621,7 @@ static unsigned char fontdata_8x16[FONTD }; -struct font_desc font_vga_8x16 = { +const struct font_desc font_vga_8x16 = { VGA8x16_IDX, "VGA8x16", 8, diff -puN drivers/video/console/font_8x8.c~fbcon-constify-font-data drivers/video/console/font_8x8.c --- 25/drivers/video/console/font_8x8.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_8x8.c Fri Sep 9 16:59:45 2005 @@ -8,7 +8,7 @@ #define FONTDATAMAX 2048 -static unsigned char fontdata_8x8[FONTDATAMAX] = { +static const unsigned char fontdata_8x8[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, /* 00000000 */ @@ -2573,7 +2573,7 @@ static unsigned char fontdata_8x8[FONTDA }; -struct font_desc font_vga_8x8 = { +const struct font_desc font_vga_8x8 = { VGA8x8_IDX, "VGA8x8", 8, diff -puN drivers/video/console/font_acorn_8x8.c~fbcon-constify-font-data drivers/video/console/font_acorn_8x8.c --- 25/drivers/video/console/font_acorn_8x8.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_acorn_8x8.c Fri Sep 9 16:59:45 2005 @@ -3,7 +3,7 @@ #include #include -static unsigned char acorndata_8x8[] = { +static const unsigned char acorndata_8x8[] = { /* 00 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */ /* 01 */ 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */ /* 02 */ 0x7e, 0xff, 0xbd, 0xff, 0xc3, 0xe7, 0xff, 0x7e, /* ^B */ @@ -262,7 +262,7 @@ static unsigned char acorndata_8x8[] = { /* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -struct font_desc font_acorn_8x8 = { +const struct font_desc font_acorn_8x8 = { ACORN8x8_IDX, "Acorn8x8", 8, diff -puN drivers/video/console/font_mini_4x6.c~fbcon-constify-font-data drivers/video/console/font_mini_4x6.c --- 25/drivers/video/console/font_mini_4x6.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_mini_4x6.c Fri Sep 9 16:59:45 2005 @@ -43,7 +43,7 @@ __END__; #define FONTDATAMAX 1536 -static unsigned char fontdata_mini_4x6[FONTDATAMAX] = { +static const unsigned char fontdata_mini_4x6[FONTDATAMAX] = { /*{*/ /* Char 0: ' ' */ @@ -2147,7 +2147,7 @@ static unsigned char fontdata_mini_4x6[F /*}*/ }; -struct font_desc font_mini_4x6 = { +const struct font_desc font_mini_4x6 = { MINI4x6_IDX, "MINI4x6", 4, diff -puN drivers/video/console/font_pearl_8x8.c~fbcon-constify-font-data drivers/video/console/font_pearl_8x8.c --- 25/drivers/video/console/font_pearl_8x8.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_pearl_8x8.c Fri Sep 9 16:59:45 2005 @@ -13,7 +13,7 @@ #define FONTDATAMAX 2048 -static unsigned char fontdata_pearl8x8[FONTDATAMAX] = { +static const unsigned char fontdata_pearl8x8[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, /* 00000000 */ @@ -2577,7 +2577,7 @@ static unsigned char fontdata_pearl8x8[F }; -struct font_desc font_pearl_8x8 = { +const struct font_desc font_pearl_8x8 = { PEARL8x8_IDX, "PEARL8x8", 8, diff -puN drivers/video/console/fonts.c~fbcon-constify-font-data drivers/video/console/fonts.c --- 25/drivers/video/console/fonts.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/fonts.c Fri Sep 9 16:59:45 2005 @@ -23,7 +23,7 @@ #define NO_FONTS -static struct font_desc *fonts[] = { +static const struct font_desc *fonts[] = { #ifdef CONFIG_FONT_8x8 #undef NO_FONTS &font_vga_8x8, @@ -84,7 +84,7 @@ static struct font_desc *fonts[] = { * */ -struct font_desc *find_font(char *name) +const struct font_desc *find_font(const char *name) { unsigned int i; @@ -108,10 +108,10 @@ struct font_desc *find_font(char *name) * */ -struct font_desc *get_default_font(int xres, int yres) +const struct font_desc *get_default_font(int xres, int yres) { int i, c, cc; - struct font_desc *f, *g; + const struct font_desc *f, *g; g = NULL; cc = -10000; @@ -138,7 +138,6 @@ struct font_desc *get_default_font(int x return g; } -EXPORT_SYMBOL(fonts); EXPORT_SYMBOL(find_font); EXPORT_SYMBOL(get_default_font); diff -puN drivers/video/console/font_sun12x22.c~fbcon-constify-font-data drivers/video/console/font_sun12x22.c --- 25/drivers/video/console/font_sun12x22.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_sun12x22.c Fri Sep 9 16:59:45 2005 @@ -2,7 +2,7 @@ #define FONTDATAMAX 11264 -static unsigned char fontdata_sun12x22[FONTDATAMAX] = { +static const unsigned char fontdata_sun12x22[FONTDATAMAX] = { /* 0 0x00 '^@' */ 0x00, 0x00, /* 000000000000 */ @@ -6151,7 +6151,7 @@ static unsigned char fontdata_sun12x22[F }; -struct font_desc font_sun_12x22 = { +const struct font_desc font_sun_12x22 = { SUN12x22_IDX, "SUN12x22", 12, diff -puN drivers/video/console/font_sun8x16.c~fbcon-constify-font-data drivers/video/console/font_sun8x16.c --- 25/drivers/video/console/font_sun8x16.c~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/drivers/video/console/font_sun8x16.c Fri Sep 9 16:59:45 2005 @@ -2,7 +2,7 @@ #define FONTDATAMAX 4096 -static unsigned char fontdata_sun8x16[FONTDATAMAX] = { +static const unsigned char fontdata_sun8x16[FONTDATAMAX] = { /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00, /* */ 0x00,0x00,0x7e,0xff,0xdb,0xff,0xff,0xc3,0xe7,0xff,0xff,0x7e,0x00,0x00,0x00,0x00, @@ -261,7 +261,7 @@ static unsigned char fontdata_sun8x16[FO /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; -struct font_desc font_sun_8x16 = { +const struct font_desc font_sun_8x16 = { SUN8x16_IDX, "SUN8x16", 8, diff -puN include/linux/fb.h~fbcon-constify-font-data include/linux/fb.h --- 25/include/linux/fb.h~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/include/linux/fb.h Fri Sep 9 16:59:45 2005 @@ -619,7 +619,7 @@ struct fb_tilemap { __u32 height; /* height of each tile in scanlines */ __u32 depth; /* color depth of each tile */ __u32 length; /* number of tiles in the map */ - __u8 *data; /* actual tile map: a bitmap array, packed + const __u8 *data; /* actual tile map: a bitmap array, packed to the nearest byte */ }; diff -puN include/linux/font.h~fbcon-constify-font-data include/linux/font.h --- 25/include/linux/font.h~fbcon-constify-font-data Fri Sep 9 16:59:45 2005 +++ 25-akpm/include/linux/font.h Fri Sep 9 16:59:45 2005 @@ -15,9 +15,9 @@ struct font_desc { int idx; - char *name; + const char *name; int width, height; - void *data; + const void *data; int pref; }; @@ -32,7 +32,7 @@ struct font_desc { #define ACORN8x8_IDX 8 #define MINI4x6_IDX 9 -extern struct font_desc font_vga_8x8, +extern const struct font_desc font_vga_8x8, font_vga_8x16, font_pearl_8x8, font_vga_6x11, @@ -45,11 +45,11 @@ extern struct font_desc font_vga_8x8, /* Find a font with a specific name */ -extern struct font_desc *find_font(char *name); +extern const struct font_desc *find_font(const char *name); /* Get the default font for a specific screen size */ -extern struct font_desc *get_default_font(int xres, int yres); +extern const struct font_desc *get_default_font(int xres, int yres); /* Max. length for the name of a predefined font */ #define MAX_FONT_NAME 32 _