mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Daniel Drake <dsd@gentoo.org>
Cc: linux-kernel@vger.kernel.org, avuton@gmail.com, hancockr@shaw.ca,
	alan@lxorguk.ukuu.org.uk, andi@firstfloor.org,
	mrmacman_g4@mac.com, dean@arctic.org, argggh@dolphinics.no,
	jengelh@computergmbh.de, shdl@zakalwe.fi, vlobanov@speakeasy.net,
	drzeus-list@drzeus.cx, strange@nsk.no-ip.org, dm.n9107@gmail.com
Subject: Re: [RFC v2] Documentation about unaligned memory access
Date: Mon, 03 Dec 2007 10:26:29 +0100	[thread overview]
Message-ID: <1196673989.6060.5.camel@johannes.berg> (raw)
In-Reply-To: <20071129161523.E0C349D4B52@zog.reactivated.net>

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]


> 	void myfunc(u8 *data, u32 value)
> 	{
> 		[...]
> 		value = cpu_to_le32(value);
> 		put_unaligned(value, data);

> 	u32 value = get_unaligned(data);

Actually, this is wrong. put_unaligned and get_unaligned use the type of
the "data" pointer, e.g. on powerpc get_unaligned does just "*data".

Hence, here you'll want to use

	put_unaligned(value, (u32 *)data);

and

	u32 value = get_unaligned((u32 *)data);

or you end up with a single-byte store/load.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

  parent reply	other threads:[~2007-12-03 10:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-29 16:15 Daniel Drake
2007-11-29 17:04 ` Kyle McMartin
2007-11-29 18:00   ` Jan Engelhardt
2007-11-29 17:44 ` Randy Dunlap
2007-11-30  7:58 ` DM
2007-12-03  9:26 ` Johannes Berg [this message]
2007-12-05 11:41 ` Jan Kara

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=1196673989.6060.5.camel@johannes.berg \
    --to=johannes@sipsolutions.net \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andi@firstfloor.org \
    --cc=argggh@dolphinics.no \
    --cc=avuton@gmail.com \
    --cc=dean@arctic.org \
    --cc=dm.n9107@gmail.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=dsd@gentoo.org \
    --cc=hancockr@shaw.ca \
    --cc=jengelh@computergmbh.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrmacman_g4@mac.com \
    --cc=shdl@zakalwe.fi \
    --cc=strange@nsk.no-ip.org \
    --cc=vlobanov@speakeasy.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

all inboxes | Powered by JetHome®