Commit 163d1719 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarKent Gibson <warthog618@gmail.com>
Depends-on: 527c4125 ("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: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9ef6293c
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -1479,22 +1479,11 @@ 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);
}

static ssize_t lineevent_read(struct file *file,
			      char __user *buf,
			      size_t count,
@@ -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;