staging: fbtft: fbtft_request_gpios: reduce nesting
authorMike Rapoport <mike.rapoport@gmail.com>
Thu, 3 Sep 2015 05:13:12 +0000 (08:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:35 +0000 (18:24 -0700)
Returning immediately if no platform_data or platform_data->gpios is
specified reduceis code nesting

Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fbtft/fbtft-core.c

index a72e046f4fb4e0d3fa3da15e8ade2d761519cec1..d2f547e0ddbeafe485d9b9e0f4ee15c9e062b47e 100644 (file)
@@ -123,33 +123,34 @@ static int fbtft_request_gpios(struct fbtft_par *par)
        unsigned long flags;
        int ret;
 
-       if (pdata && pdata->gpios) {
-               gpio = pdata->gpios;
-               while (gpio->name[0]) {
-                       flags = FBTFT_GPIO_NO_MATCH;
-                       /* if driver provides match function, try it first,
-                          if no match use our own */
-                       if (par->fbtftops.request_gpios_match)
-                               flags = par->fbtftops.request_gpios_match(par, gpio);
-                       if (flags == FBTFT_GPIO_NO_MATCH)
-                               flags = fbtft_request_gpios_match(par, gpio);
-                       if (flags != FBTFT_GPIO_NO_MATCH) {
-                               ret = devm_gpio_request_one(par->info->device,
-                                               gpio->gpio, flags,
-                                               par->info->device->driver->name);
-                               if (ret < 0) {
-                                       dev_err(par->info->device,
-                                               "%s: gpio_request_one('%s'=%d) failed with %d\n",
-                                               __func__, gpio->name,
-                                               gpio->gpio, ret);
-                                       return ret;
-                               }
-                               fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par,
-                                       "%s: '%s' = GPIO%d\n",
-                                       __func__, gpio->name, gpio->gpio);
+       if (!(pdata && pdata->gpios))
+               return 0;
+
+       gpio = pdata->gpios;
+       while (gpio->name[0]) {
+               flags = FBTFT_GPIO_NO_MATCH;
+               /* if driver provides match function, try it first,
+                  if no match use our own */
+               if (par->fbtftops.request_gpios_match)
+                       flags = par->fbtftops.request_gpios_match(par, gpio);
+               if (flags == FBTFT_GPIO_NO_MATCH)
+                       flags = fbtft_request_gpios_match(par, gpio);
+               if (flags != FBTFT_GPIO_NO_MATCH) {
+                       ret = devm_gpio_request_one(par->info->device,
+                                       gpio->gpio, flags,
+                                       par->info->device->driver->name);
+                       if (ret < 0) {
+                               dev_err(par->info->device,
+                                       "%s: gpio_request_one('%s'=%d) failed with %d\n",
+                                       __func__, gpio->name,
+                                       gpio->gpio, ret);
+                               return ret;
                        }
-                       gpio++;
+                       fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par,
+                               "%s: '%s' = GPIO%d\n",
+                               __func__, gpio->name, gpio->gpio);
                }
+               gpio++;
        }
 
        return 0;