Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #ifndef _ASM_GENERIC_BITOPS_FFS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #define _ASM_GENERIC_BITOPS_FFS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * ffs - find first bit set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * @x: the word to search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * This is defined the same way as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * the libc and compiler builtin ffs routines, therefore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * differs in spirit from the above ffz (man ffs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static inline int ffs(int x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	int r = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	if (!x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	if (!(x & 0xffff)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		x >>= 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 		r += 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	if (!(x & 0xff)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		x >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		r += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (!(x & 0xf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		x >>= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		r += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	if (!(x & 3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		x >>= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		r += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	if (!(x & 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		x >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		r += 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #endif /* _ASM_GENERIC_BITOPS_FFS_H_ */