Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: Constify struct sbus_mmap_map

'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>

authored by

Christophe JAILLET and committed by
Helge Deller
161e95b8 57e755d3

+10 -10
+1 -1
drivers/video/fbdev/bw2.c
··· 147 147 return 0; 148 148 } 149 149 150 - static struct sbus_mmap_map bw2_mmap_map[] = { 150 + static const struct sbus_mmap_map bw2_mmap_map[] = { 151 151 { 152 152 .size = SBUS_MMAP_FBSIZE(1) 153 153 },
+1 -1
drivers/video/fbdev/cg14.c
··· 360 360 info->fix.accel = FB_ACCEL_SUN_CG14; 361 361 } 362 362 363 - static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = { 363 + static const struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] = { 364 364 { 365 365 .voff = CG14_REGS, 366 366 .poff = 0x80000000,
+1 -1
drivers/video/fbdev/cg3.c
··· 209 209 return 0; 210 210 } 211 211 212 - static struct sbus_mmap_map cg3_mmap_map[] = { 212 + static const struct sbus_mmap_map cg3_mmap_map[] = { 213 213 { 214 214 .voff = CG3_MMAP_OFFSET, 215 215 .poff = CG3_RAM_OFFSET,
+1 -1
drivers/video/fbdev/cg6.c
··· 545 545 return 0; 546 546 } 547 547 548 - static struct sbus_mmap_map cg6_mmap_map[] = { 548 + static const struct sbus_mmap_map cg6_mmap_map[] = { 549 549 { 550 550 .voff = CG6_FBC, 551 551 .poff = CG6_FBC_OFFSET,
+1 -1
drivers/video/fbdev/ffb.c
··· 710 710 return 0; 711 711 } 712 712 713 - static struct sbus_mmap_map ffb_mmap_map[] = { 713 + static const struct sbus_mmap_map ffb_mmap_map[] = { 714 714 { 715 715 .voff = FFB_SFB8R_VOFF, 716 716 .poff = FFB_SFB8R_POFF,
+1 -1
drivers/video/fbdev/leo.c
··· 338 338 return 0; 339 339 } 340 340 341 - static struct sbus_mmap_map leo_mmap_map[] = { 341 + static const struct sbus_mmap_map leo_mmap_map[] = { 342 342 { 343 343 .voff = LEO_SS0_MAP, 344 344 .poff = LEO_OFF_SS0,
+1 -1
drivers/video/fbdev/p9100.c
··· 206 206 return 0; 207 207 } 208 208 209 - static struct sbus_mmap_map p9100_mmap_map[] = { 209 + static const struct sbus_mmap_map p9100_mmap_map[] = { 210 210 { CG3_MMAP_OFFSET, 0, SBUS_MMAP_FBSIZE(1) }, 211 211 { 0, 0, 0 } 212 212 };
+1 -1
drivers/video/fbdev/sbuslib.c
··· 38 38 return fbsize * (-size); 39 39 } 40 40 41 - int sbusfb_mmap_helper(struct sbus_mmap_map *map, 41 + int sbusfb_mmap_helper(const struct sbus_mmap_map *map, 42 42 unsigned long physbase, 43 43 unsigned long fbsize, 44 44 unsigned long iospace,
+1 -1
drivers/video/fbdev/sbuslib.h
··· 19 19 20 20 extern void sbusfb_fill_var(struct fb_var_screeninfo *var, 21 21 struct device_node *dp, int bpp); 22 - extern int sbusfb_mmap_helper(struct sbus_mmap_map *map, 22 + extern int sbusfb_mmap_helper(const struct sbus_mmap_map *map, 23 23 unsigned long physbase, unsigned long fbsize, 24 24 unsigned long iospace, 25 25 struct vm_area_struct *vma);
+1 -1
drivers/video/fbdev/tcx.c
··· 236 236 return 0; 237 237 } 238 238 239 - static struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = { 239 + static const struct sbus_mmap_map __tcx_mmap_map[TCX_MMAP_ENTRIES] = { 240 240 { 241 241 .voff = TCX_RAM8BIT, 242 242 .size = SBUS_MMAP_FBSIZE(1)