[PATCH] constify font data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(Note: Patch also attached because the inline version is certain to get
line wrapped.)

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 <[email protected]>

diff -Npru 2.6.13/drivers/video/console/fbcon.c
2.6.13-fonts-const/drivers/video/console/fbcon.c
--- 2.6.13/drivers/video/console/fbcon.c	2005-08-29
01:41:01.000000000 +0200
+++ 2.6.13-fonts-const/drivers/video/console/fbcon.c	2005-09-05
09:20:08.000000000 +0200
@@ -736,7 +736,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;
@@ -810,7 +810,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 */
 	}
 
@@ -921,7 +921,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;
@@ -1168,7 +1168,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;
@@ -2115,7 +2115,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];
@@ -2133,7 +2133,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;
@@ -2290,7 +2290,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;
 		}
 	}
@@ -2300,7 +2300,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 -Npru 2.6.13/drivers/video/console/fbcon.h
2.6.13-fonts-const/drivers/video/console/fbcon.h
--- 2.6.13/drivers/video/console/fbcon.h	2005-08-29
01:41:01.000000000 +0200
+++ 2.6.13-fonts-const/drivers/video/console/fbcon.h	2005-09-05
10:09:55.000000000 +0200
@@ -29,7 +29,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 -Npru 2.6.13/drivers/video/console/font_10x18.c
2.6.13-fonts-const/drivers/video/console/font_10x18.c
--- 2.6.13/drivers/video/console/font_10x18.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_10x18.c	2005-09-01
17:38:31.000000000 +0200
@@ -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 -Npru 2.6.13/drivers/video/console/font_6x11.c
2.6.13-fonts-const/drivers/video/console/font_6x11.c
--- 2.6.13/drivers/video/console/font_6x11.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_6x11.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/drivers/video/console/font_7x14.c
2.6.13-fonts-const/drivers/video/console/font_7x14.c
--- 2.6.13/drivers/video/console/font_7x14.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_7x14.c	2005-09-01
17:38:42.000000000 +0200
@@ -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 -Npru 2.6.13/drivers/video/console/font_8x16.c
2.6.13-fonts-const/drivers/video/console/font_8x16.c
--- 2.6.13/drivers/video/console/font_8x16.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_8x16.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/drivers/video/console/font_8x8.c
2.6.13-fonts-const/drivers/video/console/font_8x8.c
--- 2.6.13/drivers/video/console/font_8x8.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_8x8.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/drivers/video/console/font_acorn_8x8.c
2.6.13-fonts-const/drivers/video/console/font_acorn_8x8.c
--- 2.6.13/drivers/video/console/font_acorn_8x8.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_acorn_8x8.c	2005-03-16
12:24:41.000000000 +0100
@@ -3,7 +3,7 @@
 #include <linux/config.h>
 #include <linux/font.h>
 
-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 -Npru 2.6.13/drivers/video/console/font_mini_4x6.c
2.6.13-fonts-const/drivers/video/console/font_mini_4x6.c
--- 2.6.13/drivers/video/console/font_mini_4x6.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_mini_4x6.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/drivers/video/console/font_pearl_8x8.c
2.6.13-fonts-const/drivers/video/console/font_pearl_8x8.c
--- 2.6.13/drivers/video/console/font_pearl_8x8.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_pearl_8x8.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/drivers/video/console/fonts.c
2.6.13-fonts-const/drivers/video/console/fonts.c
--- 2.6.13/drivers/video/console/fonts.c	2005-08-29
01:41:01.000000000 +0200
+++ 2.6.13-fonts-const/drivers/video/console/fonts.c	2005-09-01
11:32:11.000000000 +0200
@@ -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 -Npru 2.6.13/drivers/video/console/font_sun12x22.c
2.6.13-fonts-const/drivers/video/console/font_sun12x22.c
--- 2.6.13/drivers/video/console/font_sun12x22.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_sun12x22.c	2005-09-01
11:32:11.000000000 +0200
@@ -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 -Npru 2.6.13/drivers/video/console/font_sun8x16.c
2.6.13-fonts-const/drivers/video/console/font_sun8x16.c
--- 2.6.13/drivers/video/console/font_sun8x16.c	2005-08-29
01:41:01.000000000 +0200
+++
2.6.13-fonts-const/drivers/video/console/font_sun8x16.c	2005-03-16
12:24:41.000000000 +0100
@@ -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 -Npru 2.6.13/include/linux/fb.h
2.6.13-fonts-const/include/linux/fb.h
--- 2.6.13/include/linux/fb.h	2005-08-29 01:41:01.000000000 +0200
+++ 2.6.13-fonts-const/include/linux/fb.h	2005-09-07
13:03:22.000000000 +0200
@@ -614,7 +614,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 -Npru 2.6.13/include/linux/font.h
2.6.13-fonts-const/include/linux/font.h
--- 2.6.13/include/linux/font.h	2005-08-29 01:41:01.000000000
+0200
+++ 2.6.13-fonts-const/include/linux/font.h	2005-09-01
17:37:28.000000000 +0200
@@ -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

Attachment: linux-2.6.13-fonts-const.patch
Description: Binary data


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux