gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper
PATCH v3 1/1 gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper
Use the new compat_need_64bit_alignment_fixup() helper to avoid ugly ifdeffery in IOCTL compatibility code.
Depends-on: 527c412519eb ("compat: add a compat_need_64bit_alignment_fixup() helper")
Signed-off-by Andy Shevchenko <[email protected]>
Tested-by Kent Gibson <[email protected]>
---
v3: reworded commit message (Kent), added Tb tag (Kent), dropped extra Dep-on
drivers/gpio/gpiolib-cdev.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/gpio/gpiolib-cdev.c +8 -16
@@ -1479,21 +1479,10 @@ static __poll_t lineevent_poll(struct file *file,return events; } -static ssize_t lineevent_get_size (void ) -{ -#if defined(CONFIG_X86_64 ) && !defined(CONFIG_UML ) -/* i386 has no padding after 'id' */ -if (in_ia32_syscall ()) { -struct compat_gpioeevent_data { -compat_u64 timestamp; -u32 id; - }; - -return sizeof (struct compat_gpioeevent_data ); - } -#endif -return sizeof (struct gpioevent_data ); -} +struct compat_gpioeevent_data { +compat_u64 timestamp; +u32 id; +}; static ssize_t lineevent_read(struct file *file, char __user *buf,
@@ -1515,7 +1504,10 @@ static ssize_t lineevent_read(struct file *file,* actual sizeof() and pass this as an argument to copy_to_user() to * drop unneeded bytes from the output. */ - ge_size =lineevent_get_size (); +if (compat_need_64bit_alignment_fixup ()) + ge_size =sizeof (struct compat_gpioeevent_data ); +else + ge_size =sizeof (struct gpioevent_data );if (count < ge_size)return -EINVAL ;
Signature · 1 line
2.28.0
Quoted 8 lines · Andy Shevchenko
Use the new
compat_need_64bit_alignment_fixup()helper to avoid ugly ifdeffery in IOCTL compatibility code.Depends-on:
527c412519eb("compat: add acompat_need_64bit_alignment_fixup()helper")Signed-off-by Andy Shevchenko <[email protected]>Tested-by Kent Gibson <[email protected]>---
v3: reworded commit message (Kent), added Tb tag (Kent), dropped extra Dep-on
So much cleaner like this. Patch applied.
Yours,
Linus Walleij