fbdev: Constify struct sbus_mmap_map
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 13 Oct 2024 11:48:01 +0000 (13:48 +0200)
committerHelge Deller <deller@gmx.de>
Tue, 15 Oct 2024 08:07:32 +0000 (10:07 +0200)
'struct sbus_mmap_map' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increases overall security.

Update sbusfb_mmap_helper() accordingly.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
   2452     536      16    3004     bbc drivers/video/fbdev/bw2.o

After:
=====
   text    data     bss     dec     hex filename
   2500     483      16    2999     bb7 drivers/video/fbdev/bw2.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/bw2.c
drivers/video/fbdev/cg14.c
drivers/video/fbdev/cg3.c
drivers/video/fbdev/cg6.c
drivers/video/fbdev/ffb.c
drivers/video/fbdev/leo.c
drivers/video/fbdev/p9100.c
drivers/video/fbdev/sbuslib.c
drivers/video/fbdev/sbuslib.h
drivers/video/fbdev/tcx.c

index 4a64940..e757462 100644 (file)
@@ -147,7 +147,7 @@ bw2_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map bw2_mmap_map[] = {
+static const struct sbus_mmap_map bw2_mmap_map[] = {
        {
                .size = SBUS_MMAP_FBSIZE(1)
        },
index 430e1a7..5389f8f 100644 (file)
@@ -360,7 +360,7 @@ static void cg14_init_fix(struct fb_info *info, int linebytes,
        info->fix.accel = FB_ACCEL_SUN_CG14;
 }
 
-static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = {
+static const struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = {
        {
                .voff   = CG14_REGS,
                .poff   = 0x80000000,
index e4c53c6..a58a483 100644 (file)
@@ -209,7 +209,7 @@ static int cg3_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map cg3_mmap_map[] = {
+static const struct sbus_mmap_map cg3_mmap_map[] = {
        {
                .voff   = CG3_MMAP_OFFSET,
                .poff   = CG3_RAM_OFFSET,
index 0b60df5..56d7446 100644 (file)
@@ -545,7 +545,7 @@ static int cg6_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map cg6_mmap_map[] = {
+static const struct sbus_mmap_map cg6_mmap_map[] = {
        {
                .voff   = CG6_FBC,
                .poff   = CG6_FBC_OFFSET,
index 0b7e7b3..34b6abf 100644 (file)
@@ -710,7 +710,7 @@ static int ffb_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map ffb_mmap_map[] = {
+static const struct sbus_mmap_map ffb_mmap_map[] = {
        {
                .voff   = FFB_SFB8R_VOFF,
                .poff   = FFB_SFB8R_POFF,
index 271e2e8..b9fb059 100644 (file)
@@ -338,7 +338,7 @@ static int leo_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map leo_mmap_map[] = {
+static const struct sbus_mmap_map leo_mmap_map[] = {
        {
                .voff   = LEO_SS0_MAP,
                .poff   = LEO_OFF_SS0,
index 124468f..0bc0f78 100644 (file)
@@ -206,7 +206,7 @@ p9100_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map p9100_mmap_map[] = {
+static const struct sbus_mmap_map p9100_mmap_map[] = {
        { CG3_MMAP_OFFSET,      0,              SBUS_MMAP_FBSIZE(1) },
        { 0,                    0,              0                   }
 };
index 634e3d1..4c79654 100644 (file)
@@ -38,7 +38,7 @@ static unsigned long sbusfb_mmapsize(long size, unsigned long fbsize)
        return fbsize * (-size);
 }
 
-int sbusfb_mmap_helper(struct sbus_mmap_map *map,
+int sbusfb_mmap_helper(const struct sbus_mmap_map *map,
                       unsigned long physbase,
                       unsigned long fbsize,
                       unsigned long iospace,
index 6466b4c..e9af2dc 100644 (file)
@@ -19,7 +19,7 @@ struct sbus_mmap_map {
 
 extern void sbusfb_fill_var(struct fb_var_screeninfo *var,
                            struct device_node *dp, int bpp);
-extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
+extern int sbusfb_mmap_helper(const struct sbus_mmap_map *map,
                              unsigned long physbase, unsigned long fbsize,
                              unsigned long iospace,
                              struct vm_area_struct *vma);
index 6eb8bb2..f9a0085 100644 (file)
@@ -236,7 +236,7 @@ tcx_blank(int blank, struct fb_info *info)
        return 0;
 }
 
-static struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = {
+static const struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = {
        {
                .voff   = TCX_RAM8BIT,
                .size   = SBUS_MMAP_FBSIZE(1)