diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-02-22 07:44:53 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-02-22 07:44:53 -0500 |
commit | 9d8cc89c316d9cc8ff269068ac8f904f13b5a70d (patch) | |
tree | f6efe1eafa20feff5ec79fc15cf2ce295022e778 | |
parent | 2307f3aab887bc43e0f262d298977fd9c6b9eee3 (diff) |
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: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpiolib.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b81646982375..872774a404f1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -380,17 +380,19 @@ static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
380 | * this GPIO so it can't use it. | 380 | * this GPIO so it can't use it. |
381 | */ | 381 | */ |
382 | lineinfo.flags = 0; | 382 | lineinfo.flags = 0; |
383 | if (desc->flags & (FLAG_REQUESTED | FLAG_IS_HOGGED | | 383 | if (test_bit(FLAG_REQUESTED, &desc->flags) || |
384 | FLAG_USED_AS_IRQ | FLAG_EXPORT | | 384 | test_bit(FLAG_IS_HOGGED, &desc->flags) || |
385 | FLAG_SYSFS)) | 385 | test_bit(FLAG_USED_AS_IRQ, &desc->flags) || |
386 | test_bit(FLAG_EXPORT, &desc->flags) || | ||
387 | test_bit(FLAG_SYSFS, &desc->flags)) | ||
386 | lineinfo.flags |= GPIOLINE_FLAG_KERNEL; | 388 | lineinfo.flags |= GPIOLINE_FLAG_KERNEL; |
387 | if (desc->flags & FLAG_IS_OUT) | 389 | if (test_bit(FLAG_IS_OUT, &desc->flags)) |
388 | lineinfo.flags |= GPIOLINE_FLAG_IS_OUT; | 390 | lineinfo.flags |= GPIOLINE_FLAG_IS_OUT; |
389 | if (desc->flags & FLAG_ACTIVE_LOW) | 391 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
390 | lineinfo.flags |= GPIOLINE_FLAG_ACTIVE_LOW; | 392 | lineinfo.flags |= GPIOLINE_FLAG_ACTIVE_LOW; |
391 | if (desc->flags & FLAG_OPEN_DRAIN) | 393 | if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) |
392 | lineinfo.flags |= GPIOLINE_FLAG_OPEN_DRAIN; | 394 | lineinfo.flags |= GPIOLINE_FLAG_OPEN_DRAIN; |
393 | if (desc->flags & FLAG_OPEN_SOURCE) | 395 | if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) |
394 | lineinfo.flags |= GPIOLINE_FLAG_OPEN_SOURCE; | 396 | lineinfo.flags |= GPIOLINE_FLAG_OPEN_SOURCE; |
395 | 397 | ||
396 | if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) | 398 | if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) |