Skip to content

Commit 684f970

Browse files
author
Russell King
committed
[PATCH] ARM: bitops
Convert ARM bitop assembly to a macro. All bitops follow the same format, so it's silly duplicating the code when only one or two instructions are different. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
1 parent 652a12e commit 684f970

6 files changed

Lines changed: 12 additions & 68 deletions

File tree

‎arch/arm/lib/changebit.S‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
/* Purpose : Function to change a bit
@@ -17,12 +18,4 @@
1718
ENTRY(_change_bit_be)
1819
eor r0, r0, #0x18 @ big endian byte ordering
1920
ENTRY(_change_bit_le)
20-
and r2, r0, #7
21-
mov r3, #1
22-
mov r3, r3, lsl r2
23-
save_and_disable_irqs ip, r2
24-
ldrb r2, [r1, r0, lsr #3]
25-
eor r2, r2, r3
26-
strb r2, [r1, r0, lsr #3]
27-
restore_irqs ip
28-
RETINSTR(mov,pc,lr)
21+
bitop eor

‎arch/arm/lib/clearbit.S‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
/*
@@ -18,14 +19,4 @@
1819
ENTRY(_clear_bit_be)
1920
eor r0, r0, #0x18 @ big endian byte ordering
2021
ENTRY(_clear_bit_le)
21-
and r2, r0, #7
22-
mov r3, #1
23-
mov r3, r3, lsl r2
24-
save_and_disable_irqs ip, r2
25-
ldrb r2, [r1, r0, lsr #3]
26-
bic r2, r2, r3
27-
strb r2, [r1, r0, lsr #3]
28-
restore_irqs ip
29-
RETINSTR(mov,pc,lr)
30-
31-
22+
bitop bic

‎arch/arm/lib/setbit.S‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
/*
@@ -18,12 +19,4 @@
1819
ENTRY(_set_bit_be)
1920
eor r0, r0, #0x18 @ big endian byte ordering
2021
ENTRY(_set_bit_le)
21-
and r2, r0, #7
22-
mov r3, #1
23-
mov r3, r3, lsl r2
24-
save_and_disable_irqs ip, r2
25-
ldrb r2, [r1, r0, lsr #3]
26-
orr r2, r2, r3
27-
strb r2, [r1, r0, lsr #3]
28-
restore_irqs ip
29-
RETINSTR(mov,pc,lr)
22+
bitop orr

‎arch/arm/lib/testchangebit.S‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
ENTRY(_test_and_change_bit_be)
1516
eor r0, r0, #0x18 @ big endian byte ordering
1617
ENTRY(_test_and_change_bit_le)
17-
add r1, r1, r0, lsr #3
18-
and r3, r0, #7
19-
mov r0, #1
20-
save_and_disable_irqs ip, r2
21-
ldrb r2, [r1]
22-
tst r2, r0, lsl r3
23-
eor r2, r2, r0, lsl r3
24-
strb r2, [r1]
25-
restore_irqs ip
26-
moveq r0, #0
27-
RETINSTR(mov,pc,lr)
28-
29-
18+
testop eor, strb

‎arch/arm/lib/testclearbit.S‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
ENTRY(_test_and_clear_bit_be)
1516
eor r0, r0, #0x18 @ big endian byte ordering
1617
ENTRY(_test_and_clear_bit_le)
17-
add r1, r1, r0, lsr #3 @ Get byte offset
18-
and r3, r0, #7 @ Get bit offset
19-
mov r0, #1
20-
save_and_disable_irqs ip, r2
21-
ldrb r2, [r1]
22-
tst r2, r0, lsl r3
23-
bic r2, r2, r0, lsl r3
24-
strb r2, [r1]
25-
restore_irqs ip
26-
moveq r0, #0
27-
RETINSTR(mov,pc,lr)
28-
29-
18+
testop bicne, strneb

‎arch/arm/lib/testsetbit.S‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@
99
*/
1010
#include <linux/linkage.h>
1111
#include <asm/assembler.h>
12+
#include "bitops.h"
1213
.text
1314

1415
ENTRY(_test_and_set_bit_be)
1516
eor r0, r0, #0x18 @ big endian byte ordering
1617
ENTRY(_test_and_set_bit_le)
17-
add r1, r1, r0, lsr #3 @ Get byte offset
18-
and r3, r0, #7 @ Get bit offset
19-
mov r0, #1
20-
save_and_disable_irqs ip, r2
21-
ldrb r2, [r1]
22-
tst r2, r0, lsl r3
23-
orr r2, r2, r0, lsl r3
24-
strb r2, [r1]
25-
restore_irqs ip
26-
moveq r0, #0
27-
RETINSTR(mov,pc,lr)
28-
29-
18+
testop orreq, streqb

0 commit comments

Comments
 (0)