Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d8cc89c authored by Linus Walleij's avatar Linus Walleij
Browse files

gpio: fixup line flags for userspace ABI



This fixes the wrongly indicated lines in the userspace
ABI: test for the right BITS, do not treat bit numbers as
bitmasks.

Reported-by: default avatarMarkus Pargmann <mpa@pengutronix.de>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 2307f3aa
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -380,17 +380,19 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
		 * this GPIO so it can't use it.
		 */
		lineinfo.flags = 0;
		if (desc->flags & (FLAG_REQUESTED | FLAG_IS_HOGGED |
				   FLAG_USED_AS_IRQ | FLAG_EXPORT |
				   FLAG_SYSFS))
		if (test_bit(FLAG_REQUESTED, &desc->flags) ||
		    test_bit(FLAG_IS_HOGGED, &desc->flags) ||
		    test_bit(FLAG_USED_AS_IRQ, &desc->flags) ||
		    test_bit(FLAG_EXPORT, &desc->flags) ||
		    test_bit(FLAG_SYSFS, &desc->flags))
			lineinfo.flags |= GPIOLINE_FLAG_KERNEL;
		if (desc->flags & FLAG_IS_OUT)
		if (test_bit(FLAG_IS_OUT, &desc->flags))
			lineinfo.flags |= GPIOLINE_FLAG_IS_OUT;
		if (desc->flags & FLAG_ACTIVE_LOW)
		if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
			lineinfo.flags |= GPIOLINE_FLAG_ACTIVE_LOW;
		if (desc->flags & FLAG_OPEN_DRAIN)
		if (test_bit(FLAG_OPEN_DRAIN, &desc->flags))
			lineinfo.flags |= GPIOLINE_FLAG_OPEN_DRAIN;
		if (desc->flags & FLAG_OPEN_SOURCE)
		if (test_bit(FLAG_OPEN_SOURCE, &desc->flags))
			lineinfo.flags |= GPIOLINE_FLAG_OPEN_SOURCE;

		if (copy_to_user(ip, &lineinfo, sizeof(lineinfo)))