[7/7] riscv: Remove extra variable in patch_text_nosync()

Message ID 20240212025529.1971876-8-samuel.holland@sifive.com
State New
Headers
Series riscv: Various text patching improvements |

Commit Message

Samuel Holland Feb. 12, 2024, 2:55 a.m. UTC
  This cast is superfluous, and is incorrect anyway if compressed
instructions may be present.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 arch/riscv/kernel/patch.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
  

Comments

Björn Töpel Feb. 19, 2024, 1:08 p.m. UTC | #1
Samuel Holland <samuel.holland@sifive.com> writes:

> This cast is superfluous, and is incorrect anyway if compressed
> instructions may be present.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>

Reviewed-by: Björn Töpel <bjorn@rivosinc.com>
  

Patch

diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
index b0cf050738aa..80755aa627d2 100644
--- a/arch/riscv/kernel/patch.c
+++ b/arch/riscv/kernel/patch.c
@@ -176,13 +176,11 @@  NOKPROBE_SYMBOL(patch_insn_set);
 
 int patch_text_set_nosync(void *addr, u8 c, size_t len)
 {
-	u32 *tp = addr;
 	int ret;
 
-	ret = patch_insn_set(tp, c, len);
-
+	ret = patch_insn_set(addr, c, len);
 	if (!ret)
-		flush_icache_range((uintptr_t)tp, (uintptr_t)tp + len);
+		flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len);
 
 	return ret;
 }
@@ -212,13 +210,11 @@  NOKPROBE_SYMBOL(patch_insn_write);
 
 int patch_text_nosync(void *addr, const void *insns, size_t len)
 {
-	u32 *tp = addr;
 	int ret;
 
-	ret = patch_insn_write(tp, insns, len);
-
+	ret = patch_insn_write(addr, insns, len);
 	if (!ret)
-		flush_icache_range((uintptr_t) tp, (uintptr_t) tp + len);
+		flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len);
 
 	return ret;
 }