blob: 29d1524634601bebf3c996bff3ad6a709e22871b [file] [log] [blame]
Sean Anderson726a8022023-07-31 17:27:33 -04001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2023 Sean Anderson <sean.anderson@seco.com>
4 *
5 * ARM bitops to call when using THUMB1, which doesn't have these instructions.
6 */
7#include <linux/linkage.h>
8#include <asm/assembler.h>
9
10.pushsection .text.__fls
11ENTRY(__fls)
12 clz r0, r0
13 rsb r0, r0, #31
14 ret lr
15ENDPROC(__fls)
16.popsection
17
18.pushsection .text.__ffs
19ENTRY(__ffs)
20 rsb r3, r0, #0
21 and r0, r0, r3
22 clz r0, r0
23 rsb r0, r0, #31
24 ret lr
25ENDPROC(__ffs)
26.popsection
27
28.pushsection .text.fls
29ENTRY(fls)
30 cmp r0, #0
31 clzne r0, r0
32 rsbne r0, r0, #32
33 ret lr
34ENDPROC(fls)
35.popsection
36
37.pushsection .text.ffs
38ENTRY(ffs)
39 rsb r3, r0, #0
40 and r0, r0, r3
41 clz r0, r0
42 rsb r0, r0, #32
43 ret lr
44ENDPROC(ffs)
45.popsection