aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHarvey Harrison <harvey.harrison@gmail.com>2009-01-06 17:56:25 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 21:10:27 -0500
commit1af84a625356768ab1f9687b70c825250123d7fd (patch)
tree9bf824eab0ccaed29b217964d4ec5d0bc715fcc8 /arch
parent13f7877bb5aeb1d5ad01ffbf17a80fb550fa6642 (diff)
sh: introduce asm/swab.h
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/sh/include/asm/Kbuild1
-rw-r--r--arch/sh/include/asm/byteorder.h62
-rw-r--r--arch/sh/include/asm/swab.h60
3 files changed, 64 insertions, 59 deletions
diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild
index 43910cdf78a5..f1a2a0d1c79c 100644
--- a/arch/sh/include/asm/Kbuild
+++ b/arch/sh/include/asm/Kbuild
@@ -6,3 +6,4 @@ unifdef-y += unistd_32.h
6unifdef-y += unistd_64.h 6unifdef-y += unistd_64.h
7unifdef-y += posix_types_32.h 7unifdef-y += posix_types_32.h
8unifdef-y += posix_types_64.h 8unifdef-y += posix_types_64.h
9unifdef-y += swab.h
diff --git a/arch/sh/include/asm/byteorder.h b/arch/sh/include/asm/byteorder.h
index f5fa0653ebc6..e95c41a5c8cc 100644
--- a/arch/sh/include/asm/byteorder.h
+++ b/arch/sh/include/asm/byteorder.h
@@ -1,68 +1,12 @@
1#ifndef __ASM_SH_BYTEORDER_H 1#ifndef __ASM_SH_BYTEORDER_H
2#define __ASM_SH_BYTEORDER_H 2#define __ASM_SH_BYTEORDER_H
3 3
4/* 4#include <asm/swab.h>
5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 */
8#include <linux/compiler.h>
9#include <linux/types.h>
10 5
11#ifdef __LITTLE_ENDIAN__ 6#ifdef __LITTLE_ENDIAN__
12# define __LITTLE_ENDIAN 7#include <linux/byteorder/little_endian.h>
13#else 8#else
14# define __BIG_ENDIAN 9#include <linux/byteorder/big_endian.h>
15#endif 10#endif
16 11
17#define __SWAB_64_THRU_32__
18
19static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
20{
21 __asm__(
22#ifdef __SH5__
23 "byterev %0, %0\n\t"
24 "shari %0, 32, %0"
25#else
26 "swap.b %0, %0\n\t"
27 "swap.w %0, %0\n\t"
28 "swap.b %0, %0"
29#endif
30 : "=r" (x)
31 : "0" (x));
32
33 return x;
34}
35#define __arch_swab32 __arch_swab32
36
37static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
38{
39 __asm__(
40#ifdef __SH5__
41 "byterev %0, %0\n\t"
42 "shari %0, 32, %0"
43#else
44 "swap.b %0, %0"
45#endif
46 : "=r" (x)
47 : "0" (x));
48
49 return x;
50}
51#define __arch_swab16 __arch_swab16
52
53static inline __u64 __arch_swab64(__u64 val)
54{
55 union {
56 struct { __u32 a,b; } s;
57 __u64 u;
58 } v, w;
59 v.u = val;
60 w.s.b = __arch_swab32(v.s.a);
61 w.s.a = __arch_swab32(v.s.b);
62 return w.u;
63}
64#define __arch_swab64 __arch_swab64
65
66#include <linux/byteorder.h>
67
68#endif /* __ASM_SH_BYTEORDER_H */ 12#endif /* __ASM_SH_BYTEORDER_H */
diff --git a/arch/sh/include/asm/swab.h b/arch/sh/include/asm/swab.h
new file mode 100644
index 000000000000..e69315935107
--- /dev/null
+++ b/arch/sh/include/asm/swab.h
@@ -0,0 +1,60 @@
1#ifndef __ASM_SH_SWAB_H
2#define __ASM_SH_SWAB_H
3
4/*
5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000, 2001 Paolo Alberelli
7 */
8#include <linux/compiler.h>
9#include <linux/types.h>
10
11#define __SWAB_64_THRU_32__
12
13static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
14{
15 __asm__(
16#ifdef __SH5__
17 "byterev %0, %0\n\t"
18 "shari %0, 32, %0"
19#else
20 "swap.b %0, %0\n\t"
21 "swap.w %0, %0\n\t"
22 "swap.b %0, %0"
23#endif
24 : "=r" (x)
25 : "0" (x));
26
27 return x;
28}
29#define __arch_swab32 __arch_swab32
30
31static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
32{
33 __asm__(
34#ifdef __SH5__
35 "byterev %0, %0\n\t"
36 "shari %0, 32, %0"
37#else
38 "swap.b %0, %0"
39#endif
40 : "=r" (x)
41 : "0" (x));
42
43 return x;
44}
45#define __arch_swab16 __arch_swab16
46
47static inline __u64 __arch_swab64(__u64 val)
48{
49 union {
50 struct { __u32 a,b; } s;
51 __u64 u;
52 } v, w;
53 v.u = val;
54 w.s.b = __arch_swab32(v.s.a);
55 w.s.a = __arch_swab32(v.s.b);
56 return w.u;
57}
58#define __arch_swab64 __arch_swab64
59
60#endif /* __ASM_SH_SWAB_H */