Skip to content

Commit

Permalink
powerpc/powernv: Fix endian bug in LPC bus debugfs accessors
Browse files Browse the repository at this point in the history
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 <[email protected]>
CC: <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
ozbenh authored and mpe committed Oct 7, 2014
1 parent 75d43b2 commit bf7588a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/powerpc/platforms/powernv/opal-lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
Expand Down

0 comments on commit bf7588a

Please sign in to comment.