diff options
| author | Bartosz Golaszewski <brgl@bgdev.pl> | 2017-11-15 16:47:43 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-19 09:09:52 +0100 |
| commit | 71dc53969aa944e91131e65abf140110868d3897 (patch) | |
| tree | 390eb8bda80c1cd9954dba2b1692a04e620c6544 /drivers | |
| parent | 3c113329473357bf9b15031b4679557d48da431c (diff) | |
| download | linux-71dc53969aa944e91131e65abf140110868d3897.tar.gz linux-71dc53969aa944e91131e65abf140110868d3897.tar.bz2 linux-71dc53969aa944e91131e65abf140110868d3897.zip | |
gpiolib: don't allow OPEN_DRAIN & OPEN_SOURCE flags simultaneously
[ Upstream commit 588fc3bceaf81bbd62e18af6f7bd475e01c2b7e8 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
| -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 f6efcf94f6ad..7a5cf5b08c54 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -460,6 +460,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) || |
