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

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

Version: ~ [ linux-5.4-rc3 ] ~ [ linux-5.3.6 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.79 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.149 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.196 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.196 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.75 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp