Skip to content

Commit 6105b2e

Browse files
andy-shevbrgl
authored andcommitted
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>
1 parent 322b86e commit 6105b2e

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,20 +3933,19 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
39333933
*/
39343934
ret = gpiod_request(desc, con_id ?: devname);
39353935
if (ret) {
3936-
if (ret == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) {
3937-
/*
3938-
* This happens when there are several consumers for
3939-
* the same GPIO line: we just return here without
3940-
* further initialization. It is a bit of a hack.
3941-
* This is necessary to support fixed regulators.
3942-
*
3943-
* FIXME: Make this more sane and safe.
3944-
*/
3945-
dev_info(dev, "nonexclusive access to GPIO for %s\n", con_id ?: devname);
3946-
return desc;
3947-
} else {
3936+
if (!(ret == -EBUSY && flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
39483937
return ERR_PTR(ret);
3949-
}
3938+
3939+
/*
3940+
* This happens when there are several consumers for
3941+
* the same GPIO line: we just return here without
3942+
* further initialization. It is a bit of a hack.
3943+
* This is necessary to support fixed regulators.
3944+
*
3945+
* FIXME: Make this more sane and safe.
3946+
*/
3947+
dev_info(dev, "nonexclusive access to GPIO for %s\n", con_id ?: devname);
3948+
return desc;
39503949
}
39513950

39523951
ret = gpiod_configure_flags(desc, con_id, lookupflags, flags);

0 commit comments

Comments
 (0)