powerpc/powernv: Fix endian bug in LPC bus debugfs accessors
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 3 Oct 2014 07:12:25 +0000 (17:12 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 7 Oct 2014 05:01:18 +0000 (16:01 +1100)
When reading from the LPC, the OPAL FW calls return the value via pointer
to a uint32_t which is always returned big endian. Our internal inb/outb
implementation byteswaps that fine but our debugfs code is still broken.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: <stable@vger.kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/opal-lpc.c

index ad4b31df779a389ceb83b1c62d77a850e9c1b749..dd2c285ad1708d755b5a1950558566149e837839 100644 (file)
@@ -191,6 +191,7 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
 {
        struct lpc_debugfs_entry *lpc = filp->private_data;
        u32 data, pos, len, todo;
+       __be32 bedata;
        int rc;
 
        if (!access_ok(VERIFY_WRITE, ubuf, count))
@@ -213,9 +214,10 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
                                len = 2;
                }
                rc = opal_lpc_read(opal_lpc_chip_id, lpc->lpc_type, pos,
-                                  &data, len);
+                                  &bedata, len);
                if (rc)
                        return -ENXIO;
+               data = be32_to_cpu(bedata);
                switch(len) {
                case 4:
                        rc = __put_user((u32)data, (u32 __user *)ubuf);