lkml.org 
[lkml]   [2007]   [Dec]   [3]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC v2] Documentation about unaligned memory access
FromJohannes Berg <>
DateMon, 03 Dec 2007 10:26:29 +0100
> 	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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2007-12-03 11:39    [from the cache]
©2003-2008