* [PATCH v3] gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper
@ 2020-10-14 10:33 Andy Shevchenko
2020-10-19 13:31 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-10-14 10:33 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, linux-gpio
Cc: Andy Shevchenko, Kent Gibson
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 <andriy.shevchenko@linux.intel.com>
Tested-by: Kent Gibson <warthog618@gmail.com>
---
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(-)
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index e9faeaf65d14..192721f829a3 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -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;
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper
2020-10-14 10:33 [PATCH v3] gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper Andy Shevchenko
@ 2020-10-19 13:31 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2020-10-19 13:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM, Kent Gibson
On Wed, Oct 14, 2020 at 12:33 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> 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 <andriy.shevchenko@linux.intel.com>
> Tested-by: Kent Gibson <warthog618@gmail.com>
> ---
> v3: reworded commit message (Kent), added Tb tag (Kent), dropped extra Dep-on
So much cleaner like this. Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-19 13:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-14 10:33 [PATCH v3] gpiolib: Switch to use compat_need_64bit_alignment_fixup() helper Andy Shevchenko
2020-10-19 13:31 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).