diff options
author | Bartosz Golaszewski <brgl@bgdev.pl> | 2017-11-15 16:47:43 +0100 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-11-30 10:54:16 +0100 |
commit | 588fc3bceaf81bbd62e18af6f7bd475e01c2b7e8 (patch) | |
tree | b8d95ab721d0870ed3f2499366e4669482684301 /drivers/gpio/gpiolib.c | |
parent | gpio: max732x: Remove duplicate NULL check (diff) | |
download | linux-588fc3bceaf81bbd62e18af6f7bd475e01c2b7e8.tar.xz linux-588fc3bceaf81bbd62e18af6f7bd475e01c2b7e8.zip |
gpiolib: don't allow OPEN_DRAIN & OPEN_SOURCE flags simultaneously
Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If
the hardware actually supports enabling both at the same time the
electrical result would be disastrous.
Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index aad84a6306c4..bdcdcdefdb71 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -459,6 +459,15 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) if (lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) return -EINVAL; + /* + * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If + * the hardware actually supports enabling both at the same time the + * electrical result would be disastrous. + */ + if ((lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) && + (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) + return -EINVAL; + /* OPEN_DRAIN and OPEN_SOURCE flags only make sense for output mode. */ if (!(lflags & GPIOHANDLE_REQUEST_OUTPUT) && ((lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) || |