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

ARM: provide common method to clear bits in CPU control register

Several places open-code this manipulation, let's consolidate this.

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

+20 -9
+2 -3
arch/arm/mm/alignment.c
··· 28 28 #include <asm/opcodes.h> 29 29 30 30 #include "fault.h" 31 + #include "mm.h" 31 32 32 33 /* 33 34 * 32-bit misaligned trap handler (c) 1998 San Mehat (CCC) -July 1998 ··· 969 968 970 969 #ifdef CONFIG_CPU_CP15 971 970 if (cpu_is_v6_unaligned()) { 972 - cr_alignment &= ~CR_A; 973 - cr_no_alignment &= ~CR_A; 974 - set_cr(cr_alignment); 971 + set_cr(__clear_cr(CR_A)); 975 972 ai_usermode = safe_usermode(ai_usermode, false); 976 973 } 977 974 #endif
+10
arch/arm/mm/init.c
··· 23 23 #include <linux/dma-contiguous.h> 24 24 #include <linux/sizes.h> 25 25 26 + #include <asm/cp15.h> 26 27 #include <asm/mach-types.h> 27 28 #include <asm/memblock.h> 28 29 #include <asm/prom.h> ··· 36 35 #include <asm/mach/map.h> 37 36 38 37 #include "mm.h" 38 + 39 + #ifdef CONFIG_CPU_CP15_MMU 40 + unsigned long __init __clear_cr(unsigned long mask) 41 + { 42 + cr_no_alignment = cr_no_alignment & ~mask; 43 + cr_alignment = cr_alignment & ~mask; 44 + return cr_alignment; 45 + } 46 + #endif 39 47 40 48 static phys_addr_t phys_initrd_start __initdata = 0; 41 49 static unsigned long phys_initrd_size __initdata = 0;
+4
arch/arm/mm/mm.h
··· 2 2 #include <linux/list.h> 3 3 #include <linux/vmalloc.h> 4 4 5 + #include <asm/pgtable.h> 6 + 5 7 /* the upper-most page table pointer */ 6 8 extern pmd_t *top_pmd; 7 9 ··· 95 93 void __init bootmem_init(void); 96 94 void arm_mm_memblock_reserve(void); 97 95 void dma_contiguous_remap(void); 96 + 97 + unsigned long __clear_cr(unsigned long mask);
+4 -6
arch/arm/mm/mmu.c
··· 125 125 */ 126 126 static int __init early_cachepolicy(char *p) 127 127 { 128 + unsigned long cr = get_cr(); 128 129 int i; 129 130 130 131 for (i = 0; i < ARRAY_SIZE(cache_policies); i++) { ··· 133 132 134 133 if (memcmp(p, cache_policies[i].policy, len) == 0) { 135 134 cachepolicy = i; 136 - cr_alignment &= ~cache_policies[i].cr_mask; 137 - cr_no_alignment &= ~cache_policies[i].cr_mask; 135 + cr = __clear_cr(cache_policies[i].cr_mask); 138 136 break; 139 137 } 140 138 } ··· 151 151 cachepolicy = CPOLICY_WRITEBACK; 152 152 } 153 153 flush_cache_all(); 154 - set_cr(cr_alignment); 154 + set_cr(cr); 155 155 return 0; 156 156 } 157 157 early_param("cachepolicy", early_cachepolicy); ··· 188 188 189 189 static int __init noalign_setup(char *__unused) 190 190 { 191 - cr_alignment &= ~CR_A; 192 - cr_no_alignment &= ~CR_A; 193 - set_cr(cr_alignment); 191 + set_cr(__clear_cr(CR_A)); 194 192 return 1; 195 193 } 196 194 __setup("noalign", noalign_setup);