diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2022-02-01 16:27:55 +0100 |
---|---|---|
committer | Bartosz Golaszewski <brgl@bgdev.pl> | 2022-02-08 10:34:15 +0100 |
commit | 95a4eed7dd5b7c1c3664a626174290686ddbee9f (patch) | |
tree | a02a6c528be9ef76cdc260be11755e43bf507335 /drivers/gpio/gpiolib.h | |
parent | gpio: aggregator: Fix calling into sleeping GPIO controllers (diff) | |
download | linux-95a4eed7dd5b7c1c3664a626174290686ddbee9f.tar.xz linux-95a4eed7dd5b7c1c3664a626174290686ddbee9f.zip |
gpiolib: Never return internal error codes to user space
Currently it's possible that character device interface may return
the error codes which are not supposed to be seen by user space.
In this case it's EPROBE_DEFER.
Wrap it to return -ENODEV instead as sysfs does.
Fixes: d7c51b47ac11 ("gpio: userspace ABI for reading/writing GPIO lines")
Fixes: 61f922db7221 ("gpio: userspace ABI for reading GPIO line events")
Fixes: 3c0d9c635ae2 ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL")
Reported-by: Suresh Balakrishnan <suresh.balakrishnan@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Diffstat (limited to 'drivers/gpio/gpiolib.h')
-rw-r--r-- | drivers/gpio/gpiolib.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 30bc3f80f83e..c31f4626915d 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -135,6 +135,18 @@ struct gpio_desc { int gpiod_request(struct gpio_desc *desc, const char *label); void gpiod_free(struct gpio_desc *desc); + +static inline int gpiod_request_user(struct gpio_desc *desc, const char *label) +{ + int ret; + + ret = gpiod_request(desc, label); + if (ret == -EPROBE_DEFER) + ret = -ENODEV; + + return ret; +} + int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, unsigned long lflags, enum gpiod_flags dflags); int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce); |