diff mbox

offb: make the screen properties endian safe

Message ID 1383149647-15500-1-git-send-email-clg@fr.ibm.com (mailing list archive)
State Superseded
Headers show

Commit Message

Cédric Le Goater Oct. 30, 2013, 4:14 p.m. UTC
The "screen" properties : depth, width, height, linebytes need
to be converted to the host endian order when read from the device
tree.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 drivers/video/offb.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Benjamin Herrenschmidt Oct. 31, 2013, 2:08 a.m. UTC | #1
On Wed, 2013-10-30 at 17:14 +0100, Cédric Le Goater wrote:
> @@ -552,25 +552,25 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
>  	if (pp == NULL)
>  		pp = of_get_property(dp, "depth", &len);
>  	if (pp && len == sizeof(u32))
> -		depth = *pp;
> +		depth = be32_to_cpu(*pp);

This is usually written as

		depth = be32_to_cpup(pp);

It used to be that the latter generated better code but that might not
be the case anymore, however it's still a better alternative.

Cheers,
Ben.
diff mbox

Patch

diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 0c4f343..c1cf591 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -536,7 +536,7 @@  static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
 	unsigned int flags, rsize, addr_prop = 0;
 	unsigned long max_size = 0;
 	u64 rstart, address = OF_BAD_ADDR;
-	const u32 *pp, *addrp, *up;
+	const __be32 *pp, *addrp, *up;
 	u64 asize;
 	int foreign_endian = 0;
 
@@ -552,25 +552,25 @@  static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
 	if (pp == NULL)
 		pp = of_get_property(dp, "depth", &len);
 	if (pp && len == sizeof(u32))
-		depth = *pp;
+		depth = be32_to_cpu(*pp);
 
 	pp = of_get_property(dp, "linux,bootx-width", &len);
 	if (pp == NULL)
 		pp = of_get_property(dp, "width", &len);
 	if (pp && len == sizeof(u32))
-		width = *pp;
+		width = be32_to_cpu(*pp);
 
 	pp = of_get_property(dp, "linux,bootx-height", &len);
 	if (pp == NULL)
 		pp = of_get_property(dp, "height", &len);
 	if (pp && len == sizeof(u32))
-		height = *pp;
+		height = be32_to_cpu(*pp);
 
 	pp = of_get_property(dp, "linux,bootx-linebytes", &len);
 	if (pp == NULL)
 		pp = of_get_property(dp, "linebytes", &len);
 	if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
-		pitch = *pp;
+		pitch = be32_to_cpu(*pp);
 	else
 		pitch = width * ((depth + 7) / 8);