linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Joe Perches <joe@perches.com>
Cc: Laurent Vivier <laurent@vivier.eu>,
	linux1394-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] firewire: firewire is a big-endian bus
Date: Tue, 21 Apr 2015 16:13:01 +0200	[thread overview]
Message-ID: <20150421161301.31874fd2@kant> (raw)
In-Reply-To: <1429578297.4216.43.camel@perches.com>

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/

  reply	other threads:[~2015-04-21 14:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21  0:36 [PATCH 0/2] Some firewire minor patches Laurent Vivier
2015-04-21  0:36 ` [PATCH 1/2] firewire: firewire is a big-endian bus Laurent Vivier
2015-04-21  1:04   ` Joe Perches
2015-04-21 14:13     ` Stefan Richter [this message]
2015-04-21 13:13   ` Stefan Richter
2015-04-21 16:04     ` Laurent Vivier
2015-04-21  0:36 ` [PATCH 2/2] firewire: add a parameter to force the speed of the devices Laurent Vivier
2015-04-21 14:03   ` Clemens Ladisch
2015-04-21 14:16     ` Stefan Richter
2015-04-21 14:33   ` Stefan Richter
2015-04-21 16:55     ` Laurent Vivier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150421161301.31874fd2@kant \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=joe@perches.com \
    --cc=laurent@vivier.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).