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

ARM: constify machine_desc structure uses

struct machine_desc records are defined everywhere as a 'const'
structure, but unfortuantely it loses its const-ness through the use of
linker magic - the symbols which surround the section are not declared
const so it becomes possible not to use 'const' for pointers to these
const structures.

Let's fix this oversight - all pointers to these structures should be
marked const too.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

+26 -25
+2 -2
arch/arm/include/asm/mach/arch.h
··· 65 65 /* 66 66 * Current machine - only accessible during boot. 67 67 */ 68 - extern struct machine_desc *machine_desc; 68 + extern const struct machine_desc *machine_desc; 69 69 70 70 /* 71 71 * Machine type table - also only accessible during boot 72 72 */ 73 - extern struct machine_desc __arch_info_begin[], __arch_info_end[]; 73 + extern const struct machine_desc __arch_info_begin[], __arch_info_end[]; 74 74 #define for_each_machine_desc(p) \ 75 75 for (p = __arch_info_begin; p < __arch_info_end; p++) 76 76
+1 -2
arch/arm/include/asm/memblock.h
··· 4 4 struct meminfo; 5 5 struct machine_desc; 6 6 7 - extern void arm_memblock_init(struct meminfo *, struct machine_desc *); 8 - 7 + void arm_memblock_init(struct meminfo *, const struct machine_desc *); 9 8 phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align); 10 9 11 10 #endif
+2 -2
arch/arm/include/asm/prom.h
··· 15 15 16 16 #ifdef CONFIG_OF 17 17 18 - extern struct machine_desc *setup_machine_fdt(unsigned int dt_phys); 18 + extern const struct machine_desc *setup_machine_fdt(unsigned int dt_phys); 19 19 extern void arm_dt_memblock_reserve(void); 20 20 extern void __init arm_dt_init_cpu_maps(void); 21 21 22 22 #else /* CONFIG_OF */ 23 23 24 - static inline struct machine_desc *setup_machine_fdt(unsigned int dt_phys) 24 + static inline const struct machine_desc *setup_machine_fdt(unsigned int dt_phys) 25 25 { 26 26 return NULL; 27 27 }
+3 -2
arch/arm/kernel/atags.h
··· 7 7 void convert_to_tag_list(struct tag *tags); 8 8 9 9 #ifdef CONFIG_ATAGS 10 - struct machine_desc *setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr); 10 + const struct machine_desc *setup_machine_tags(phys_addr_t __atags_pointer, 11 + unsigned int machine_nr); 11 12 #else 12 - static inline struct machine_desc * 13 + static inline const struct machine_desc * 13 14 setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr) 14 15 { 15 16 early_print("no ATAGS support: can't continue\n");
+3 -3
arch/arm/kernel/atags_parse.c
··· 178 178 tag->hdr.tag = ATAG_NONE; 179 179 } 180 180 181 - struct machine_desc * __init setup_machine_tags(phys_addr_t __atags_pointer, 182 - unsigned int machine_nr) 181 + const struct machine_desc * __init 182 + setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr) 183 183 { 184 184 struct tag *tags = (struct tag *)&default_tags; 185 - struct machine_desc *mdesc = NULL, *p; 185 + const struct machine_desc *mdesc = NULL, *p; 186 186 char *from = default_command_line; 187 187 188 188 default_tags.mem.start = PHYS_OFFSET;
+3 -3
arch/arm/kernel/devtree.c
··· 176 176 * If a dtb was passed to the kernel in r2, then use it to choose the 177 177 * correct machine_desc and to setup the system. 178 178 */ 179 - struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) 179 + const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) 180 180 { 181 181 struct boot_param_header *devtree; 182 - struct machine_desc *mdesc, *mdesc_best = NULL; 182 + const struct machine_desc *mdesc, *mdesc_best = NULL; 183 183 unsigned int score, mdesc_score = ~1; 184 184 unsigned long dt_root; 185 185 const char *model; ··· 188 188 DT_MACHINE_START(GENERIC_DT, "Generic DT based system") 189 189 MACHINE_END 190 190 191 - mdesc_best = (struct machine_desc *)&__mach_desc_GENERIC_DT; 191 + mdesc_best = &__mach_desc_GENERIC_DT; 192 192 #endif 193 193 194 194 if (!dt_phys)
+6 -6
arch/arm/kernel/setup.c
··· 72 72 __setup("fpe=", fpe_setup); 73 73 #endif 74 74 75 - extern void paging_init(struct machine_desc *desc); 75 + extern void paging_init(const struct machine_desc *desc); 76 76 extern void sanity_check_meminfo(void); 77 77 extern enum reboot_mode reboot_mode; 78 - extern void setup_dma_zone(struct machine_desc *desc); 78 + extern void setup_dma_zone(const struct machine_desc *desc); 79 79 80 80 unsigned int processor_id; 81 81 EXPORT_SYMBOL(processor_id); ··· 139 139 static const char *cpu_name; 140 140 static const char *machine_name; 141 141 static char __initdata cmd_line[COMMAND_LINE_SIZE]; 142 - struct machine_desc *machine_desc __initdata; 142 + const struct machine_desc *machine_desc __initdata; 143 143 144 144 static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } }; 145 145 #define ENDIANNESS ((char)endian_test.l) ··· 607 607 608 608 void __init dump_machine_table(void) 609 609 { 610 - struct machine_desc *p; 610 + const struct machine_desc *p; 611 611 612 612 early_print("Available machine support:\n\nID (hex)\tNAME\n"); 613 613 for_each_machine_desc(p) ··· 694 694 } 695 695 early_param("mem", early_mem); 696 696 697 - static void __init request_standard_resources(struct machine_desc *mdesc) 697 + static void __init request_standard_resources(const struct machine_desc *mdesc) 698 698 { 699 699 struct memblock_region *region; 700 700 struct resource *res; ··· 850 850 851 851 void __init setup_arch(char **cmdline_p) 852 852 { 853 - struct machine_desc *mdesc; 853 + const struct machine_desc *mdesc; 854 854 855 855 setup_processor(); 856 856 mdesc = setup_machine_fdt(__atags_pointer);
+3 -2
arch/arm/mm/init.c
··· 231 231 } 232 232 #endif 233 233 234 - void __init setup_dma_zone(struct machine_desc *mdesc) 234 + void __init setup_dma_zone(const struct machine_desc *mdesc) 235 235 { 236 236 #ifdef CONFIG_ZONE_DMA 237 237 if (mdesc->dma_zone_size) { ··· 335 335 return phys; 336 336 } 337 337 338 - void __init arm_memblock_init(struct meminfo *mi, struct machine_desc *mdesc) 338 + void __init arm_memblock_init(struct meminfo *mi, 339 + const struct machine_desc *mdesc) 339 340 { 340 341 int i; 341 342
+2 -2
arch/arm/mm/mmu.c
··· 1151 1151 * called function. This means you can't use any function or debugging 1152 1152 * method which may touch any device, otherwise the kernel _will_ crash. 1153 1153 */ 1154 - static void __init devicemaps_init(struct machine_desc *mdesc) 1154 + static void __init devicemaps_init(const struct machine_desc *mdesc) 1155 1155 { 1156 1156 struct map_desc map; 1157 1157 unsigned long addr; ··· 1272 1272 * paging_init() sets up the page tables, initialises the zone memory 1273 1273 * maps, and sets up the zero page, bad page and bad page tables. 1274 1274 */ 1275 - void __init paging_init(struct machine_desc *mdesc) 1275 + void __init paging_init(const struct machine_desc *mdesc) 1276 1276 { 1277 1277 void *zero_page; 1278 1278
+1 -1
arch/arm/mm/nommu.c
··· 299 299 * paging_init() sets up the page tables, initialises the zone memory 300 300 * maps, and sets up the zero page, bad page and bad page tables. 301 301 */ 302 - void __init paging_init(struct machine_desc *mdesc) 302 + void __init paging_init(const struct machine_desc *mdesc) 303 303 { 304 304 early_trap_init((void *)CONFIG_VECTORS_BASE); 305 305 mpu_setup();