~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ufs/swab.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php