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)  *  linux/fs/ufs/swab.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1997, 1998 Francois-Rene Rideau <fare@tunes.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 1998 Jakub Jelinek <jj@ultra.linux.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2001 Christoph Hellwig <hch@infradead.org>
^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) #ifndef _UFS_SWAB_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _UFS_SWAB_H
^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)  * Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *    HERE WE ASSUME EITHER BIG OR LITTLE ENDIAN UFSes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *    in case there are ufs implementations that have strange bytesexes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *    you'll need to modify code here as well as in ufs_super.c and ufs_fs.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *    to support them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	BYTESEX_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	BYTESEX_BE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static inline u64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) fs64_to_cpu(struct super_block *sbp, __fs64 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		return le64_to_cpu((__force __le64)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		return be64_to_cpu((__force __be64)n);
^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) static inline __fs64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) cpu_to_fs64(struct super_block *sbp, u64 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		return (__force __fs64)cpu_to_le64(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		return (__force __fs64)cpu_to_be64(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static inline u32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) fs32_to_cpu(struct super_block *sbp, __fs32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		return le32_to_cpu((__force __le32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		return be32_to_cpu((__force __be32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static inline __fs32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) cpu_to_fs32(struct super_block *sbp, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return (__force __fs32)cpu_to_le32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		return (__force __fs32)cpu_to_be32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) fs32_add(struct super_block *sbp, __fs32 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		le32_add_cpu((__le32 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		be32_add_cpu((__be32 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) fs32_sub(struct super_block *sbp, __fs32 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		le32_add_cpu((__le32 *)n, -d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		be32_add_cpu((__be32 *)n, -d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static inline u16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) fs16_to_cpu(struct super_block *sbp, __fs16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		return le16_to_cpu((__force __le16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		return be16_to_cpu((__force __be16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static inline __fs16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) cpu_to_fs16(struct super_block *sbp, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return (__force __fs16)cpu_to_le16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		return (__force __fs16)cpu_to_be16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) fs16_add(struct super_block *sbp, __fs16 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		le16_add_cpu((__le16 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		be16_add_cpu((__be16 *)n, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) fs16_sub(struct super_block *sbp, __fs16 *n, int d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		le16_add_cpu((__le16 *)n, -d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		be16_add_cpu((__be16 *)n, -d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif /* _UFS_SWAB_H */