Skip to content

Commit ff69a4c

Browse files
author
Russell King
committed
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>
1 parent 3b2f64d commit ff69a4c

10 files changed

Lines changed: 26 additions & 25 deletions

File tree

‎arch/arm/include/asm/mach/arch.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ struct machine_desc {
6565
/*
6666
* Current machine - only accessible during boot.
6767
*/
68-
extern struct machine_desc *machine_desc;
68+
extern const struct machine_desc *machine_desc;
6969

7070
/*
7171
* Machine type table - also only accessible during boot
7272
*/
73-
extern struct machine_desc __arch_info_begin[], __arch_info_end[];
73+
extern const struct machine_desc __arch_info_begin[], __arch_info_end[];
7474
#define for_each_machine_desc(p) \
7575
for (p = __arch_info_begin; p < __arch_info_end; p++)
7676

‎arch/arm/include/asm/memblock.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
struct meminfo;
55
struct machine_desc;
66

7-
extern void arm_memblock_init(struct meminfo *, struct machine_desc *);
8-
7+
void arm_memblock_init(struct meminfo *, const struct machine_desc *);
98
phys_addr_t arm_memblock_steal(phys_addr_t size, phys_addr_t align);
109

1110
#endif

‎arch/arm/include/asm/prom.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
#ifdef CONFIG_OF
1717

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);
1919
extern void arm_dt_memblock_reserve(void);
2020
extern void __init arm_dt_init_cpu_maps(void);
2121

2222
#else /* CONFIG_OF */
2323

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)
2525
{
2626
return NULL;
2727
}

‎arch/arm/kernel/atags.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ static inline void save_atags(struct tag *tags) { }
77
void convert_to_tag_list(struct tag *tags);
88

99
#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);
1112
#else
12-
static inline struct machine_desc *
13+
static inline const struct machine_desc *
1314
setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
1415
{
1516
early_print("no ATAGS support: can't continue\n");

‎arch/arm/kernel/atags_parse.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ static void __init squash_mem_tags(struct tag *tag)
178178
tag->hdr.tag = ATAG_NONE;
179179
}
180180

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)
183183
{
184184
struct tag *tags = (struct tag *)&default_tags;
185-
struct machine_desc *mdesc = NULL, *p;
185+
const struct machine_desc *mdesc = NULL, *p;
186186
char *from = default_command_line;
187187

188188
default_tags.mem.start = PHYS_OFFSET;

‎arch/arm/kernel/devtree.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ void __init arm_dt_init_cpu_maps(void)
176176
* If a dtb was passed to the kernel in r2, then use it to choose the
177177
* correct machine_desc and to setup the system.
178178
*/
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)
180180
{
181181
struct boot_param_header *devtree;
182-
struct machine_desc *mdesc, *mdesc_best = NULL;
182+
const struct machine_desc *mdesc, *mdesc_best = NULL;
183183
unsigned int score, mdesc_score = ~1;
184184
unsigned long dt_root;
185185
const char *model;
@@ -188,7 +188,7 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
188188
DT_MACHINE_START(GENERIC_DT, "Generic DT based system")
189189
MACHINE_END
190190

191-
mdesc_best = (struct machine_desc *)&__mach_desc_GENERIC_DT;
191+
mdesc_best = &__mach_desc_GENERIC_DT;
192192
#endif
193193

194194
if (!dt_phys)

‎arch/arm/kernel/setup.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ static int __init fpe_setup(char *line)
7272
__setup("fpe=", fpe_setup);
7373
#endif
7474

75-
extern void paging_init(struct machine_desc *desc);
75+
extern void paging_init(const struct machine_desc *desc);
7676
extern void sanity_check_meminfo(void);
7777
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);
7979

8080
unsigned int processor_id;
8181
EXPORT_SYMBOL(processor_id);
@@ -139,7 +139,7 @@ EXPORT_SYMBOL(elf_platform);
139139
static const char *cpu_name;
140140
static const char *machine_name;
141141
static char __initdata cmd_line[COMMAND_LINE_SIZE];
142-
struct machine_desc *machine_desc __initdata;
142+
const struct machine_desc *machine_desc __initdata;
143143

144144
static union { char c[4]; unsigned long l; } endian_test __initdata = { { 'l', '?', '?', 'b' } };
145145
#define ENDIANNESS ((char)endian_test.l)
@@ -607,7 +607,7 @@ static void __init setup_processor(void)
607607

608608
void __init dump_machine_table(void)
609609
{
610-
struct machine_desc *p;
610+
const struct machine_desc *p;
611611

612612
early_print("Available machine support:\n\nID (hex)\tNAME\n");
613613
for_each_machine_desc(p)
@@ -694,7 +694,7 @@ static int __init early_mem(char *p)
694694
}
695695
early_param("mem", early_mem);
696696

697-
static void __init request_standard_resources(struct machine_desc *mdesc)
697+
static void __init request_standard_resources(const struct machine_desc *mdesc)
698698
{
699699
struct memblock_region *region;
700700
struct resource *res;
@@ -850,7 +850,7 @@ void __init hyp_mode_check(void)
850850

851851
void __init setup_arch(char **cmdline_p)
852852
{
853-
struct machine_desc *mdesc;
853+
const struct machine_desc *mdesc;
854854

855855
setup_processor();
856856
mdesc = setup_machine_fdt(__atags_pointer);

‎arch/arm/mm/init.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
231231
}
232232
#endif
233233

234-
void __init setup_dma_zone(struct machine_desc *mdesc)
234+
void __init setup_dma_zone(const struct machine_desc *mdesc)
235235
{
236236
#ifdef CONFIG_ZONE_DMA
237237
if (mdesc->dma_zone_size) {
@@ -335,7 +335,8 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)
335335
return phys;
336336
}
337337

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)
339340
{
340341
int i;
341342

‎arch/arm/mm/mmu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ void __init arm_mm_memblock_reserve(void)
11511151
* called function. This means you can't use any function or debugging
11521152
* method which may touch any device, otherwise the kernel _will_ crash.
11531153
*/
1154-
static void __init devicemaps_init(struct machine_desc *mdesc)
1154+
static void __init devicemaps_init(const struct machine_desc *mdesc)
11551155
{
11561156
struct map_desc map;
11571157
unsigned long addr;
@@ -1272,7 +1272,7 @@ static void __init map_lowmem(void)
12721272
* paging_init() sets up the page tables, initialises the zone memory
12731273
* maps, and sets up the zero page, bad page and bad page tables.
12741274
*/
1275-
void __init paging_init(struct machine_desc *mdesc)
1275+
void __init paging_init(const struct machine_desc *mdesc)
12761276
{
12771277
void *zero_page;
12781278

‎arch/arm/mm/nommu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void __init sanity_check_meminfo(void)
299299
* paging_init() sets up the page tables, initialises the zone memory
300300
* maps, and sets up the zero page, bad page and bad page tables.
301301
*/
302-
void __init paging_init(struct machine_desc *mdesc)
302+
void __init paging_init(const struct machine_desc *mdesc)
303303
{
304304
early_trap_init((void *)CONFIG_VECTORS_BASE);
305305
mpu_setup();

0 commit comments

Comments
 (0)