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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #ifndef __XFS_BIT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define	__XFS_BIT_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * XFS bit manipulation routines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * masks with n high/low bits set, 64-bit values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static inline uint64_t xfs_mask64hi(int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	return (uint64_t)-1 << (64 - (n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static inline uint32_t xfs_mask32lo(int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	return ((uint32_t)1 << (n)) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) static inline uint64_t xfs_mask64lo(int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	return ((uint64_t)1 << (n)) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* Get high bit set out of 32-bit argument, -1 if none set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static inline int xfs_highbit32(uint32_t v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	return fls(v) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /* Get high bit set out of 64-bit argument, -1 if none set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static inline int xfs_highbit64(uint64_t v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	return fls64(v) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Get low bit set out of 32-bit argument, -1 if none set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline int xfs_lowbit32(uint32_t v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	return ffs(v) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Get low bit set out of 64-bit argument, -1 if none set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline int xfs_lowbit64(uint64_t v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	uint32_t	w = (uint32_t)v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	int		n = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	if (w) {	/* lower bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		n = ffs(w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	} else {	/* upper bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		w = (uint32_t)(v >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		if (w) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			n = ffs(w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			if (n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 				n += 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	return n - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* Return whether bitmap is empty (1 == empty) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) extern int xfs_bitmap_empty(uint *map, uint size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* Count continuous one bits in map starting with start_bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) extern int xfs_contig_bits(uint *map, uint size, uint start_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* Find next set bit in map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) extern int xfs_next_bit(uint *map, uint size, uint start_bit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #endif	/* __XFS_BIT_H__ */