summaryrefslogtreecommitdiff
path: root/arch/powerpc/xmon
diff options
context:
space:
mode:
authorJordan Niethe <jniethe5@gmail.com>2020-05-06 13:40:24 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2020-05-19 00:10:36 +1000
commit5a7fdcab54ef17c395fc47e73c828a1432e51683 (patch)
tree4c23847625fe5e2a2944c156dde4897f2add52ea /arch/powerpc/xmon
parent4eff2b4f32a309e2171bfe53db3e93b5614f77cb (diff)
powerpc/xmon: Use bitwise calculations in_breakpoint_table()
A modulo operation is used for calculating the current offset from a breakpoint within the breakpoint table. As instruction lengths are always a power of 2, this can be replaced with a bitwise 'and'. The current check for word alignment can be replaced with checking that the lower 2 bits are not set. Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Reviewed-by: Alistair Popple <alistair@popple.id.au> Link: https://lore.kernel.org/r/20200506034050.24806-5-jniethe5@gmail.com
Diffstat (limited to 'arch/powerpc/xmon')
-rw-r--r--arch/powerpc/xmon/xmon.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 948d025f2939..0fa3aaeee105 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -857,8 +857,8 @@ static struct bpt *in_breakpoint_table(unsigned long nip, unsigned long *offp)
off = nip - (unsigned long)bpt_table;
if (off >= sizeof(bpt_table))
return NULL;
- *offp = off % BPT_SIZE;
- if (*offp != 0 && *offp != 4)
+ *offp = off & (BPT_SIZE - 1);
+ if (off & 3)
return NULL;
return bpts + (off / BPT_SIZE);
}