diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2022-02-01 17:27:58 +0200 |
---|---|---|
committer | Bartosz Golaszewski <brgl@bgdev.pl> | 2022-02-08 10:36:11 +0100 |
commit | 6105b2e391879df0ebee20c764bbdd406cb74fb2 (patch) | |
tree | 30fc87a5d84adbe9ec5fb2b7c3d884c4229deb29 /drivers/gpio | |
parent | 322b86e7a73042300303844c9bc51bf6995a47ef (diff) | |
download | linux-6105b2e391879df0ebee20c764bbdd406cb74fb2.tar.bz2 |
gpiolib: Simplify error path in gpiod_get_index() when requesting GPIO
Simplify error path in the gpiod_get_index() when requesting a GPIO line by:
- checking for error condition first
- dropping redundant 'else'
As a result, decrease the indentation level for better readability.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpiolib.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index daedf8207173..b4d8bf3a1121 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3933,20 +3933,19 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, */ ret = gpiod_request(desc, con_id ?: devname); if (ret) { - if (ret == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) { - /* - * This happens when there are several consumers for - * the same GPIO line: we just return here without - * further initialization. It is a bit of a hack. - * This is necessary to support fixed regulators. - * - * FIXME: Make this more sane and safe. - */ - dev_info(dev, "nonexclusive access to GPIO for %s\n", con_id ?: devname); - return desc; - } else { + if (!(ret == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE)) return ERR_PTR(ret); - } + + /* + * This happens when there are several consumers for + * the same GPIO line: we just return here without + * further initialization. It is a bit of a hack. + * This is necessary to support fixed regulators. + * + * FIXME: Make this more sane and safe. + */ + dev_info(dev, "nonexclusive access to GPIO for %s\n", con_id ?: devname); + return desc; } ret = gpiod_configure_flags(desc, con_id, lookupflags, flags); |