[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <alpine.LFD.2.00.1106201634260.2142@xanadu.home>
Date: Mon, 20 Jun 2011 16:50:34 -0400 (EDT)
From: Nicolas Pitre <nico@...xnic.net>
To: Arnd Bergmann <arnd@...db.de>
Cc: linux-arm-kernel@...ts.infradead.org, gregkh@...e.de,
Russell King - ARM Linux <linux@....linux.org.uk>,
linux-usb@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>,
Rabin Vincent <rabin@....in>,
Alan Stern <stern@...land.harvard.edu>,
Alexander Holler <holler@...oftware.de>
Subject: Re: [PATCH] USB: ehci: use packed,
aligned(4) instead of removing the packed attribute
On Mon, 20 Jun 2011, Arnd Bergmann wrote:
> On Monday 20 June 2011 20:48:49 Russell King - ARM Linux wrote:
> > 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists