diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2014-04-24 03:23:28 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-04-28 03:35:35 -0400 |
commit | 926e6940f54313813d177b5cfb9ec31a441cd259 (patch) | |
tree | 018b48b91e6556ef7dc184ae1545d050e57719a6 /arch/powerpc/boot/oflib.c | |
parent | 163bed77b97c2f1e941641f81566da8ea647deda (diff) |
powerpc/boot: Add byteswapping routines in oflib
Values will need to be byte-swapped when calling prom (big endian) from
a little endian boot wrapper.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/boot/oflib.c')
-rw-r--r-- | arch/powerpc/boot/oflib.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c index 3b0c9458504f..0f72b1a42133 100644 --- a/arch/powerpc/boot/oflib.c +++ b/arch/powerpc/boot/oflib.c | |||
@@ -42,13 +42,13 @@ int of_call_prom(const char *service, int nargs, int nret, ...) | |||
42 | struct prom_args args; | 42 | struct prom_args args; |
43 | va_list list; | 43 | va_list list; |
44 | 44 | ||
45 | args.service = ADDR(service); | 45 | args.service = cpu_to_be32(ADDR(service)); |
46 | args.nargs = nargs; | 46 | args.nargs = cpu_to_be32(nargs); |
47 | args.nret = nret; | 47 | args.nret = cpu_to_be32(nret); |
48 | 48 | ||
49 | va_start(list, nret); | 49 | va_start(list, nret); |
50 | for (i = 0; i < nargs; i++) | 50 | for (i = 0; i < nargs; i++) |
51 | args.args[i] = va_arg(list, prom_arg_t); | 51 | args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t)); |
52 | va_end(list); | 52 | va_end(list); |
53 | 53 | ||
54 | for (i = 0; i < nret; i++) | 54 | for (i = 0; i < nret; i++) |
@@ -57,7 +57,7 @@ int of_call_prom(const char *service, int nargs, int nret, ...) | |||
57 | if (prom(&args) < 0) | 57 | if (prom(&args) < 0) |
58 | return -1; | 58 | return -1; |
59 | 59 | ||
60 | return (nret > 0)? args.args[nargs]: 0; | 60 | return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0; |
61 | } | 61 | } |
62 | 62 | ||
63 | static int of_call_prom_ret(const char *service, int nargs, int nret, | 63 | static int of_call_prom_ret(const char *service, int nargs, int nret, |
@@ -67,13 +67,13 @@ static int of_call_prom_ret(const char *service, int nargs, int nret, | |||
67 | struct prom_args args; | 67 | struct prom_args args; |
68 | va_list list; | 68 | va_list list; |
69 | 69 | ||
70 | args.service = ADDR(service); | 70 | args.service = cpu_to_be32(ADDR(service)); |
71 | args.nargs = nargs; | 71 | args.nargs = cpu_to_be32(nargs); |
72 | args.nret = nret; | 72 | args.nret = cpu_to_be32(nret); |
73 | 73 | ||
74 | va_start(list, rets); | 74 | va_start(list, rets); |
75 | for (i = 0; i < nargs; i++) | 75 | for (i = 0; i < nargs; i++) |
76 | args.args[i] = va_arg(list, prom_arg_t); | 76 | args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t)); |
77 | va_end(list); | 77 | va_end(list); |
78 | 78 | ||
79 | for (i = 0; i < nret; i++) | 79 | for (i = 0; i < nret; i++) |
@@ -84,9 +84,9 @@ static int of_call_prom_ret(const char *service, int nargs, int nret, | |||
84 | 84 | ||
85 | if (rets != (void *) 0) | 85 | if (rets != (void *) 0) |
86 | for (i = 1; i < nret; ++i) | 86 | for (i = 1; i < nret; ++i) |
87 | rets[i-1] = args.args[nargs+i]; | 87 | rets[i-1] = be32_to_cpu(args.args[nargs+i]); |
88 | 88 | ||
89 | return (nret > 0)? args.args[nargs]: 0; | 89 | return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | /* returns true if s2 is a prefix of s1 */ | 92 | /* returns true if s2 is a prefix of s1 */ |