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

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

From: nico@fluxnic.net (Nicolas Pitre)
Date: 2011-06-20 20:50:37
Also in: lkml
Subsystem: arm port, the rest · Maintainers: Russell King, Linus Torvalds

On Mon, 20 Jun 2011, Arnd Bergmann wrote:
On Monday 20 June 2011 20:48:49 Russell King - ARM Linux wrote:
quoted
If it is the case that these structures do not require packing to get
their desired layout, then they don't require packing, and the packed
attribute should be dropped.
Yes. But are you going to audit every other use of __packed in the kernel
to check if it is used on __iomem pointers?
The compiler might tell us about it:
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index d66605d..10c47e8 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -49,11 +49,11 @@ extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
 
 #define __raw_writeb(v,a)	(__chk_io_ptr(a), *(volatile unsigned char __force  *)(a) = (v))
 #define __raw_writew(v,a)	(__chk_io_ptr(a), *(volatile unsigned short __force *)(a) = (v))
-#define __raw_writel(v,a)	(__chk_io_ptr(a), *(volatile unsigned int __force   *)(a) = (v))
+#define __raw_writel(v,a)	(__chk_io_ptr(a), BUILD_BUG_ON_ZERO(__alignof(*(int *)a) != 4), *(volatile unsigned int __force   *)(a) = (v))
 
 #define __raw_readb(a)		(__chk_io_ptr(a), *(volatile unsigned char __force  *)(a))
 #define __raw_readw(a)		(__chk_io_ptr(a), *(volatile unsigned short __force *)(a))
-#define __raw_readl(a)		(__chk_io_ptr(a), *(volatile unsigned int __force   *)(a))
+#define __raw_readl(a)		(__chk_io_ptr(a), BUILD_BUG_ON_ZERO(__alignof(*(int *)a) != 4), *(volatile unsigned int __force   *)(a))
 
 /*
  * Architecture ioremap implementation.
And similar for readh/writeh, given that your GCC version is preserving 
the alignment attribute across the cast of course.

[...]

Scratch that.  The alignment of a void pointer dereference is 1.


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