Thread (64 messages) 64 messages, 7 authors, 2011-06-29

[PATCH] USB: ehci: use packed, aligned(4) instead of removing the packed attribute

From: arnd@arndb.de (Arnd Bergmann)
Date: 2011-06-20 20:15:29
Also in: lkml

On Monday 20 June 2011 21:32:13 Russell King - ARM Linux wrote:
quoted
Here the d member is not naturally aligned.  On most architectures, 
including ARM with the ABI currently in use, the compiler would insert a 
32-bit padding between c and d.
And if 'struct foo' represents a structure in device memory, the end
result is highly unpredicable whether or not you have padding or
accessors to load 'd' there.  So, you would not have such a structure
describing a data structure in memory returned by ioremap().
Right.
Now, the real question is: is there any architecture which is (or may
be) supported by the Linux kernel which would add padding to:

struct foo {
        u8 a;
        u8 b;
        u16 c;
        u32 d;
        u64 e;
};
This is the other issue, which we were facing in the scsi drivers.
If an architecture requires padding because some members require
larger than natural alignment here, the 'packed' should be applied
to that member, in order to change the alignment of that member.

	Arnd
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help