Commit 08bc1dc5 authored by Anton Blanchard's avatar Anton Blanchard Committed by Benjamin Herrenschmidt

powerpc: Make RTAS device tree accesses endian safe

Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent e91ae5bd
...@@ -204,7 +204,7 @@ void rtas_progress(char *s, unsigned short hex) ...@@ -204,7 +204,7 @@ void rtas_progress(char *s, unsigned short hex)
{ {
struct device_node *root; struct device_node *root;
int width; int width;
const int *p; const __be32 *p;
char *os; char *os;
static int display_character, set_indicator; static int display_character, set_indicator;
static int display_width, display_lines, form_feed; static int display_width, display_lines, form_feed;
...@@ -221,13 +221,13 @@ void rtas_progress(char *s, unsigned short hex) ...@@ -221,13 +221,13 @@ void rtas_progress(char *s, unsigned short hex)
if ((root = of_find_node_by_path("/rtas"))) { if ((root = of_find_node_by_path("/rtas"))) {
if ((p = of_get_property(root, if ((p = of_get_property(root,
"ibm,display-line-length", NULL))) "ibm,display-line-length", NULL)))
display_width = *p; display_width = be32_to_cpu(*p);
if ((p = of_get_property(root, if ((p = of_get_property(root,
"ibm,form-feed", NULL))) "ibm,form-feed", NULL)))
form_feed = *p; form_feed = be32_to_cpu(*p);
if ((p = of_get_property(root, if ((p = of_get_property(root,
"ibm,display-number-of-lines", NULL))) "ibm,display-number-of-lines", NULL)))
display_lines = *p; display_lines = be32_to_cpu(*p);
row_width = of_get_property(root, row_width = of_get_property(root,
"ibm,display-truncation-length", NULL); "ibm,display-truncation-length", NULL);
of_node_put(root); of_node_put(root);
...@@ -322,11 +322,11 @@ EXPORT_SYMBOL(rtas_progress); /* needed by rtas_flash module */ ...@@ -322,11 +322,11 @@ EXPORT_SYMBOL(rtas_progress); /* needed by rtas_flash module */
int rtas_token(const char *service) int rtas_token(const char *service)
{ {
const int *tokp; const __be32 *tokp;
if (rtas.dev == NULL) if (rtas.dev == NULL)
return RTAS_UNKNOWN_SERVICE; return RTAS_UNKNOWN_SERVICE;
tokp = of_get_property(rtas.dev, service, NULL); tokp = of_get_property(rtas.dev, service, NULL);
return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; return tokp ? be32_to_cpu(*tokp) : RTAS_UNKNOWN_SERVICE;
} }
EXPORT_SYMBOL(rtas_token); EXPORT_SYMBOL(rtas_token);
...@@ -588,8 +588,8 @@ bool rtas_indicator_present(int token, int *maxindex) ...@@ -588,8 +588,8 @@ bool rtas_indicator_present(int token, int *maxindex)
{ {
int proplen, count, i; int proplen, count, i;
const struct indicator_elem { const struct indicator_elem {
u32 token; __be32 token;
u32 maxindex; __be32 maxindex;
} *indicators; } *indicators;
indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen); indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen);
...@@ -599,10 +599,10 @@ bool rtas_indicator_present(int token, int *maxindex) ...@@ -599,10 +599,10 @@ bool rtas_indicator_present(int token, int *maxindex)
count = proplen / sizeof(struct indicator_elem); count = proplen / sizeof(struct indicator_elem);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (indicators[i].token != token) if (__be32_to_cpu(indicators[i].token) != token)
continue; continue;
if (maxindex) if (maxindex)
*maxindex = indicators[i].maxindex; *maxindex = __be32_to_cpu(indicators[i].maxindex);
return true; return true;
} }
...@@ -1097,19 +1097,19 @@ void __init rtas_initialize(void) ...@@ -1097,19 +1097,19 @@ void __init rtas_initialize(void)
*/ */
rtas.dev = of_find_node_by_name(NULL, "rtas"); rtas.dev = of_find_node_by_name(NULL, "rtas");
if (rtas.dev) { if (rtas.dev) {
const u32 *basep, *entryp, *sizep; const __be32 *basep, *entryp, *sizep;
basep = of_get_property(rtas.dev, "linux,rtas-base", NULL); basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
sizep = of_get_property(rtas.dev, "rtas-size", NULL); sizep = of_get_property(rtas.dev, "rtas-size", NULL);
if (basep != NULL && sizep != NULL) { if (basep != NULL && sizep != NULL) {
rtas.base = *basep; rtas.base = __be32_to_cpu(*basep);
rtas.size = *sizep; rtas.size = __be32_to_cpu(*sizep);
entryp = of_get_property(rtas.dev, entryp = of_get_property(rtas.dev,
"linux,rtas-entry", NULL); "linux,rtas-entry", NULL);
if (entryp == NULL) /* Ugh */ if (entryp == NULL) /* Ugh */
rtas.entry = rtas.base; rtas.entry = rtas.base;
else else
rtas.entry = *entryp; rtas.entry = __be32_to_cpu(*entryp);
} else } else
rtas.dev = NULL; rtas.dev = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment