From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E377EDDE0F for ; Fri, 9 May 2008 10:15:05 +1000 (EST) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id m490ExUL000989 for ; Thu, 8 May 2008 19:15:00 -0500 Subject: lsprop patch for little endian From: Benjamin Herrenschmidt To: linuxppc-dev list Content-Type: text/plain Date: Fri, 09 May 2008 10:14:58 +1000 Message-Id: <1210292098.1421.93.camel@pasglop> Mime-Version: 1.0 Reply-To: benh@kernel.crashing.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , I'm not sure who packages that, I think it's in powerpc-utils, anyway, here's a patch that makes it work on device-tree tarballs lsprop'ed from a LE machine. --- /home/benh/grabbag/powerpc-utils-1.1.3/lsprop.c 2007-05-11 14:21:23.000000000 +1000 +++ lsprop.c 2008-05-09 10:13:49.000000000 +1000 @@ -7,10 +7,22 @@ */ #include #include +#include #include #include #include #include +#include +#include + +static inline unsigned int dt_swap_int(unsigned int data) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + return bswap_32(data); +#else + return data; +#endif +} int recurse; int maxbytes = 128; @@ -170,7 +182,7 @@ } else if ((n & 3) == 0) { nw = n >> 2; if (nw == 1) { - i = *(int *)buf; + i = dt_swap_int(*(int *)buf); printf(" %.8x", i); if (i > -0x10000 && !(i >= 0 && i <= 9)) printf(" (%d)", i); @@ -185,7 +197,7 @@ if (i != 0) printf("\n\t\t"); for (j = 0; j < npl && i + j < nw; ++j) - printf(" %.8x", ((unsigned int *)buf)[i+j]); + printf(" %.8x", dt_swap_int(((unsigned int *)buf)[i+j])); } } } else {