Skip to content

Commit 8b5f688

Browse files
mslusarzLinus Torvalds
authored andcommitted
byteorder: move le32_add_cpu & friends from OCFS2 to core
This patchset moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core header (1st), converts ext3 filesystem to this API (2nd) and replaces XFS different named functions with new ones (3rd). There are many places where these functions will be useful. Just look at: grep -r 'cpu_to_[ble12346]*([ble12346]*_to_cpu.*[-+]' linux-src/ Patch for ext3 is an example how conversions will probably look like. This patch: - move inline functions which add native byte order variable to little/big endian variable to core header * le16_add_cpu(__le16 *var, u16 val) * le32_add_cpu(__le32 *var, u32 val) * le64_add_cpu(__le64 *var, u64 val) * be32_add_cpu(__be32 *var, u32 val) - add for completeness: * be16_add_cpu(__be16 *var, u16 val) * be64_add_cpu(__be64 *var, u64 val) Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Acked-by: Mark Fasheh <mark.fasheh@oracle.com> Cc: David Chinner <dgc@sgi.com> Cc: Timothy Shimmin <tes@sgi.com> Cc: <linux-ext4@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2004dc8 commit 8b5f688

File tree

6 files changed

+30
-78
lines changed

6 files changed

+30
-78
lines changed

fs/ocfs2/cluster/endian.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

fs/ocfs2/cluster/nodemanager.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <linux/sysctl.h>
2525
#include <linux/configfs.h>
2626

27-
#include "endian.h"
2827
#include "tcp.h"
2928
#include "nodemanager.h"
3029
#include "heartbeat.h"

fs/ocfs2/dlm/dlmast.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "cluster/heartbeat.h"
4444
#include "cluster/nodemanager.h"
4545
#include "cluster/tcp.h"
46-
#include "cluster/endian.h"
4746

4847
#include "dlmapi.h"
4948
#include "dlmcommon.h"

fs/ocfs2/endian.h

Lines changed: 0 additions & 45 deletions
This file was deleted.

fs/ocfs2/ocfs2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "dlm/dlmapi.h"
4444

4545
#include "ocfs2_fs.h"
46-
#include "endian.h"
4746
#include "ocfs2_lockid.h"
4847

4948
/* Most user visible OCFS2 inodes will have very few pieces of

include/linux/byteorder/generic.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@
146146
#define htons(x) ___htons(x)
147147
#define ntohs(x) ___ntohs(x)
148148

149+
static inline void le16_add_cpu(__le16 *var, u16 val)
150+
{
151+
*var = cpu_to_le16(le16_to_cpu(*var) + val);
152+
}
153+
154+
static inline void le32_add_cpu(__le32 *var, u32 val)
155+
{
156+
*var = cpu_to_le32(le32_to_cpu(*var) + val);
157+
}
158+
159+
static inline void le64_add_cpu(__le64 *var, u64 val)
160+
{
161+
*var = cpu_to_le64(le64_to_cpu(*var) + val);
162+
}
163+
164+
static inline void be16_add_cpu(__be16 *var, u16 val)
165+
{
166+
*var = cpu_to_be16(be16_to_cpu(*var) + val);
167+
}
168+
169+
static inline void be32_add_cpu(__be32 *var, u32 val)
170+
{
171+
*var = cpu_to_be32(be32_to_cpu(*var) + val);
172+
}
173+
174+
static inline void be64_add_cpu(__be64 *var, u64 val)
175+
{
176+
*var = cpu_to_be64(be64_to_cpu(*var) + val);
177+
}
178+
149179
#endif /* KERNEL */
150180

151181
#endif /* _LINUX_BYTEORDER_GENERIC_H */

0 commit comments

Comments
 (0)