Re: [i2c] [PATCH 1/1] i2c: align i2c_device_id

Previous thread: [PATCH 00/57] watchdog: Giant scrub by Alan Cox on Monday, May 19, 2008 - 9:04 am. (72 messages)

Next thread: [PATCH] ip2: Fix crashes on load/unload by Alan Cox on Monday, May 19, 2008 - 9:20 am. (4 messages)
To: <khali@...>
Cc: <i2c@...>, <linux-kernel@...>, Jiri Slaby <jirislaby@...>
Date: Monday, May 19, 2008 - 9:18 am

Align i2c_device_id.driver_data to 8 bytes to not fail on crossbuilds.

(Added in d2653e92732bd3911feff6bee5e23dbf959381db.)

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
---
include/linux/mod_devicetable.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index a37db57..1fd03e7 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -384,7 +384,8 @@ struct virtio_device_id {

struct i2c_device_id {
char name[I2C_NAME_SIZE];
- kernel_ulong_t driver_data; /* Data private to the driver */
+ kernel_ulong_t driver_data /* Data private to the driver */
+ __attribute__((aligned(sizeof(kernel_ulong_t))));
};

--
1.5.4.5

--

To: Jiri Slaby <jirislaby@...>
Cc: <i2c@...>, <linux-kernel@...>
Date: Monday, May 19, 2008 - 3:00 pm

Hi Jiri,

Thanks for this patch, it's in my i2c tree now and will be sent to
Linus by the end of the week. I wasn't aware of this possible alignment
issue, sorry.

--
Jean Delvare
--

To: Jean Delvare <khali@...>
Cc: <i2c@...>, <linux-kernel@...>
Date: Monday, May 19, 2008 - 3:20 pm

To be honest, neither I was until I hit it while testing hid bus (where I did
the same mistake). Thanks.
--

To: Jiri Slaby <jirislaby@...>
Cc: Jean Delvare <khali@...>, <i2c@...>, <linux-kernel@...>
Date: Tuesday, May 20, 2008 - 12:25 am

Is there any more information about this? Items in a structure should be
aligned to the alignment required by their type. Usually sizeof(x) ==
alignof(x), but not always.

I guess in this case the structures are used as a cross-platform binary on
disk representation, and so the alignment of the build host must match the
alignment of the target?

Maybe it would be better to include the alignment attribute in the
definition of kernel_ulong_t?
--

To: Jiri Slaby <jirislaby@...>
Cc: <khali@...>, <i2c@...>, <linux-kernel@...>
Date: Monday, May 19, 2008 - 9:40 am

Thanks Jiri.

Sam
--

Previous thread: [PATCH 00/57] watchdog: Giant scrub by Alan Cox on Monday, May 19, 2008 - 9:04 am. (72 messages)

Next thread: [PATCH] ip2: Fix crashes on load/unload by Alan Cox on Monday, May 19, 2008 - 9:20 am. (4 messages)