Commit 6105b2e3 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
parent 322b86e7
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -3933,7 +3933,9 @@ 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) {
		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
@@ -3944,9 +3946,6 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
		 */
		dev_info(dev, "nonexclusive access to GPIO for %s\n", con_id ?: devname);
		return desc;
		} else {
			return ERR_PTR(ret);
		}
	}

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