Skip to contentSkip to conversation

i2c: align i2c_device_id

PATCH In review Jiri Slaby 4 participants 5 messages May 19, 2008 – May 20, 2008 I2C subsystem host drivers

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 i2c: align i2c_device_id

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

(Added in d2653e92732bd3911feff6bee5e23dbf959381db.)

---
 include/linux/mod_devicetable.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/mod_devicetable.h +2 -1
index a37db57..1fd03e7 100644
@@ -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))));
 };
 
 
Signature · 7 lines
1.5.4.5


_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
#1 lore raw
Quoted 15 lines · Jiri Slaby

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

(Added in d2653e92732bd3911feff6bee5e23dbf959381db.)

---
 include/linux/mod_devicetable.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/mod_devicetable.h +0 -0
index a37db57..1fd03e7 100644

include/linux/mod_devicetable.h struct virtio_device_id { · line 389

Quoted 7 lines
include/linux/mod_devicetable.h +2 -1
@@ -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))));
 };

Thanks Jiri.

Sam

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#2 lore raw
In reply to Jiri Slaby

Hi Jiri,

Quoted 15 lines · Jiri Slaby

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

(Added in d2653e92732bd3911feff6bee5e23dbf959381db.)

---
 include/linux/mod_devicetable.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/mod_devicetable.h +0 -0
index a37db57..1fd03e7 100644

include/linux/mod_devicetable.h struct virtio_device_id { · line 390

Quoted 8 lines
include/linux/mod_devicetable.h +2 -1
@@ -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))));
 };
 

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.

Signature · 1 line
Jean Delvare
author
#3 lore raw
Quoted 1 line · Jean Delvare

Hi Jiri,

Hi.

Quoted 3 lines

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.

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

#4 lore raw
Quoted 7 lines · Jiri Slaby
Quoted 3 lines · Jean Delvare

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.

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

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?