aboutsummaryrefslogtreecommitdiff
path: root/include/asm-generic/bitops/builtin-fls.h
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-08-18 13:45:58 -0400
committerTom Rini <trini@konsulko.com>2023-08-18 13:45:58 -0400
commit3881c9fbb7fdd98f6eae5cd33f7e9abe9455a585 (patch)
tree3522dea6d6e5bff9c2d9bcae8354e16223c5b518 /include/asm-generic/bitops/builtin-fls.h
parent14ba0a8bbc342a677982acc787ae542b84ed7993 (diff)
parent48f792e31b88343bfccbaf73808e3d02a2be90dc (diff)
Merge branch '2023-08-18-assorted-updates' into next
- Use built-in ffs/fls on ARM, fix a PIE issue in SPL on ARMv8, bcm283x and mediatek updates, whitespace fix in UFS uclass, make CI use "tools-only" defconfig for more tests, add TI TCA9554 GPIO support, cache alignment fix for SCSI, and fix a problem with SYS_MMCSD_RAW_MODE_ARGS_SECTOR in SPL.
Diffstat (limited to 'include/asm-generic/bitops/builtin-fls.h')
-rw-r--r--include/asm-generic/bitops/builtin-fls.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/asm-generic/bitops/builtin-fls.h b/include/asm-generic/bitops/builtin-fls.h
new file mode 100644
index 0000000000..c8455cc288
--- /dev/null
+++ b/include/asm-generic/bitops/builtin-fls.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
+#define _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_
+
+/**
+ * fls - find last (most-significant) bit set
+ * @x: the word to search
+ *
+ * This is defined the same way as ffs.
+ * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
+ */
+static __always_inline int fls(unsigned int x)
+{
+ return x ? sizeof(x) * 8 - __builtin_clz(x) : 0;
+}
+
+#endif