ARM: cpaccess: write-enables kernel space for write

Calls the mmu function to ensure that kernel space is
write-enabled before writing the updated CP15
instruction. Removes the unnecessary write of the
constant bx lr instruction.

Change-Id: Idfe44bb89e793b009b17565e7486f3a6e8cdf582
Signed-off-by: Neil Leeder <nleeder@codeaurora.org>
diff --git a/arch/arm/common/cpaccess.c b/arch/arm/common/cpaccess.c
index d3d0537..e71e318 100644
--- a/arch/arm/common/cpaccess.c
+++ b/arch/arm/common/cpaccess.c
@@ -29,6 +29,7 @@
 #include <linux/smp.h>
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
+#include <asm/mmu_writeable.h>
 
 #ifdef CONFIG_ARCH_MSM_KRAIT
 #include <mach/msm-krait-l2-accessors.h>
@@ -191,16 +192,11 @@
 	(per_cpu(cp_param.cp, cpu) << 8);
 
 	/*
-	 * Grab address of the Dummy function, insert MRC/MCR
-	 * instruction and a return instruction ("bx lr"). Do
-	 * a D cache clean and I cache invalidate after inserting
-	 * new code.
+	 * Grab address of the Dummy function, write the MRC/MCR
+	 * instruction, ensuring cache coherency.
 	 */
 	p_opcode = (unsigned long *)&cpaccess_dummy;
-	*p_opcode++ = opcode;
-	*p_opcode-- = 0xE12FFF1E;
-	__cpuc_coherent_kern_range((unsigned long)p_opcode,
-	 ((unsigned long)p_opcode + (sizeof(long) * 2)));
+	mem_text_write_kernel_word(p_opcode, opcode);
 
 #ifdef CONFIG_SMP
 	/*