1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2048fa2dfSCatalin Marinas #ifndef _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_ 3048fa2dfSCatalin Marinas #define _ASM_GENERIC_BITOPS_BUILTIN_FLS_H_ 4048fa2dfSCatalin Marinas 5048fa2dfSCatalin Marinas /** 6048fa2dfSCatalin Marinas * fls - find last (most-significant) bit set 7048fa2dfSCatalin Marinas * @x: the word to search 8048fa2dfSCatalin Marinas * 9048fa2dfSCatalin Marinas * This is defined the same way as ffs. 10048fa2dfSCatalin Marinas * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. 11048fa2dfSCatalin Marinas */ fls(unsigned int x)12*3fc2579eSMatthew Wilcoxstatic __always_inline int fls(unsigned int x) 13048fa2dfSCatalin Marinas { 14048fa2dfSCatalin Marinas return x ? sizeof(x) * 8 - __builtin_clz(x) : 0; 15048fa2dfSCatalin Marinas } 16048fa2dfSCatalin Marinas 17048fa2dfSCatalin Marinas #endif 18