summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib-cdev.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-10-14 13:33:15 +0300
committerLinus Walleij <linus.walleij@linaro.org>2020-10-28 15:47:00 +0100
commit163d1719d30f137c5118b8cbcd8db73b0a580793 (patch)
tree7d5c06db2460f1b155e9503efd4602c0626fca5f /drivers/gpio/gpiolib-cdev.c
parent9ef6293c0659de3fa7981e795e70786c89610374 (diff)
downloadlinux-163d1719d30f137c5118b8cbcd8db73b0a580793.tar.bz2
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. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Kent Gibson <warthog618@gmail.com> Depends-on: 527c412519eb ("compat: add a compat_need_64bit_alignment_fixup() helper") Link: https://lore.kernel.org/r/20201014103315.82662-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib-cdev.c')
-rw-r--r--drivers/gpio/gpiolib-cdev.c24
1 files 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;