From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755114AbbDUNNx (ORCPT ); Tue, 21 Apr 2015 09:13:53 -0400 Received: from einhorn.in-berlin.de ([192.109.42.8]:57209 "EHLO einhorn.in-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752744AbbDUNNu (ORCPT ); Tue, 21 Apr 2015 09:13:50 -0400 X-Envelope-From: stefanr@s5r6.in-berlin.de Date: Tue, 21 Apr 2015 15:13:35 +0200 From: Stefan Richter To: Laurent Vivier Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Joe Perches Subject: Re: [PATCH 1/2] firewire: firewire is a big-endian bus Message-ID: <20150421151335.45d1259f@kant> In-Reply-To: <1429576576-1637-2-git-send-email-laurent@vivier.eu> References: <1429576576-1637-1-git-send-email-laurent@vivier.eu> <1429576576-1637-2-git-send-email-laurent@vivier.eu> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.27; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Apr 21 Laurent Vivier wrote: > So, dump config_rom data as big-endian values. > > The value given by /sys/bus/firewire/devices/fw0 were correctly > given on a big-endian host (like powermac) not on a little-endian host > (like PC), for instance: > > 00000000 87 a4 04 04 34 39 33 31 22 a2 00 f0 33 22 11 00 |....4931"...3"..| > 00000010 66 66 66 33 0b dd 05 00 c0 83 00 0c 1e 0d d0 03 |fff3............| > 00000020 03 00 00 81 01 00 00 17 08 00 00 81 b7 4c 06 00 |.............L..| > 00000030 00 00 00 00 00 00 00 00 75 6e 69 4c 69 46 20 78 |........uniLiF x| > 00000040 69 77 65 72 00 00 65 72 1c ff 03 00 00 00 00 00 |iwer..er........| > 00000050 00 00 00 00 75 6a 75 4a |....ujuJ| > 00000058 > > instead of: > > 00000000 04 04 a4 87 31 33 39 34 f0 00 a2 22 00 11 22 33 |....1394...".."3| > 00000010 33 66 66 66 00 05 dd 0b 0c 00 83 c0 03 d0 0d 1e |3fff............| > 00000020 81 00 00 03 17 00 00 01 81 00 00 08 00 06 4c b7 |..............L.| > 00000030 00 00 00 00 00 00 00 00 4c 69 6e 75 78 20 46 69 |........Linux Fi| > 00000040 72 65 77 69 72 65 00 00 00 03 ff 1c 00 00 00 00 |rewire..........| > 00000050 00 00 00 00 4a 75 6a 75 |....Juju| > 00000058 > > This patch corrects this. > > Signed-off-by: Laurent Vivier As defined in Documentation/ABI/stable/sysfs-bus-firewire we deliberately export the Configuration ROM as an array of host-endian quadlets. As a stable kernel ABI, this will not be changed. (A python script called crpp which transforms this kind of binary data into a richly annotated hexdump is available as part of the jujuutils package, or standalone from http://me.in-berlin.de/~s5r6/linux1394/utils/.) > --- > drivers/firewire/core-device.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c > index f9e3aee..5245567 100644 > --- a/drivers/firewire/core-device.c > +++ b/drivers/firewire/core-device.c > @@ -399,14 +399,14 @@ static ssize_t config_rom_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > struct fw_device *device = fw_device(dev); > - size_t length; > + size_t i; > > down_read(&fw_device_rwsem); > - length = device->config_rom_length * 4; > - memcpy(buf, device->config_rom, length); > + for (i = 0; i < device->config_rom_length; i++) > + ((u32 *)buf)[i] = be32_to_cpu(device->config_rom[i]); > up_read(&fw_device_rwsem); > > - return length; > + return i * 4; > } > > static ssize_t guid_show(struct device *dev, -- Stefan Richter -=====-===== -=-- =-=-= http://arcgraph.de/sr/