gpiolib: Simplify error path in gpiod_get_index() when requesting GPIO
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 1 Feb 2022 15:27:58 +0000 (17:27 +0200)
committerBartosz Golaszewski <brgl@bgdev.pl>
Tue, 8 Feb 2022 09:36:11 +0000 (10:36 +0100)
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>
drivers/gpio/gpiolib.c

index daedf82..b4d8bf3 100644 (file)
@@ -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);