Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755014AbbDUONW (ORCPT ); Tue, 21 Apr 2015 10:13:22 -0400 Received: from einhorn.in-berlin.de ([192.109.42.8]:58758 "EHLO einhorn.in-berlin.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752112AbbDUONT (ORCPT ); Tue, 21 Apr 2015 10:13:19 -0400 X-Envelope-From: stefanr@s5r6.in-berlin.de Date: Tue, 21 Apr 2015 16:13:01 +0200 From: Stefan Richter To: Joe Perches Cc: Laurent Vivier , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] firewire: firewire is a big-endian bus Message-ID: <20150421161301.31874fd2@kant> In-Reply-To: <1429578297.4216.43.camel@perches.com> References: <1429576576-1637-1-git-send-email-laurent@vivier.eu> <1429576576-1637-2-git-send-email-laurent@vivier.eu> <1429578297.4216.43.camel@perches.com> 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 Content-Length: 1617 Lines: 40 On Apr 20 Joe Perches wrote: > On Tue, 2015-04-21 at 02:36 +0200, 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: > [] > > diff --git 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]); > > Is buf guaranteed to be appropriately aligned on a u32? Good catch. Though as far as I know, the buffer is page-sized and thereby certainly page-aligned. This could be looked up in the sysfs core code. BTW, theoretically speaking it should be cpu_to_be32() here, and the buffer pointer should be annotated as a big endian pointer. (But as I noted in the previous reply, the patch will not be applied either way.) -- Stefan Richter -=====-===== -=-- =-=-= http://arcgraph.de/sr/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/