Skip to content

Commit 705e71a

Browse files
mpredfearnamalon
authored andcommitted
MIPS: Watch: Avoid duplication of bits in mips_read_watch_registers
Currently the bits to be masked when watchhi is read is defined inline for each register. To avoid this, define the bits once and mask each register with that value. Signed-off-by: Matt Redfearn <matt.redfearn@mips.com> Acked-by: David Daney <david.daney@cavium.com> Reviewed-by: James Hogan <jhogan@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/18158/ Signed-off-by: James Hogan <jhogan@kernel.org>
1 parent f609cc3 commit 705e71a

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

arch/mips/kernel/watch.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@ void mips_read_watch_registers(void)
4848
{
4949
struct mips3264_watch_reg_state *watches =
5050
&current->thread.watch.mips3264;
51+
unsigned int watchhi_mask = MIPS_WATCHHI_MASK | MIPS_WATCHHI_IRW;
52+
5153
switch (current_cpu_data.watch_reg_use_cnt) {
5254
default:
5355
BUG();
5456
case 4:
55-
watches->watchhi[3] = (read_c0_watchhi3() &
56-
(MIPS_WATCHHI_MASK | MIPS_WATCHHI_IRW));
57+
watches->watchhi[3] = (read_c0_watchhi3() & watchhi_mask);
5758
case 3:
58-
watches->watchhi[2] = (read_c0_watchhi2() &
59-
(MIPS_WATCHHI_MASK | MIPS_WATCHHI_IRW));
59+
watches->watchhi[2] = (read_c0_watchhi2() & watchhi_mask);
6060
case 2:
61-
watches->watchhi[1] = (read_c0_watchhi1() &
62-
(MIPS_WATCHHI_MASK | MIPS_WATCHHI_IRW));
61+
watches->watchhi[1] = (read_c0_watchhi1() & watchhi_mask);
6362
case 1:
64-
watches->watchhi[0] = (read_c0_watchhi0() &
65-
(MIPS_WATCHHI_MASK | MIPS_WATCHHI_IRW));
63+
watches->watchhi[0] = (read_c0_watchhi0() & watchhi_mask);
6664
}
6765
if (current_cpu_data.watch_reg_use_cnt == 1 &&
6866
(watches->watchhi[0] & MIPS_WATCHHI_IRW) == 0) {

0 commit comments

Comments
 (0)