From: Mike Rapoport <mike.rapoport@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Mike Rapoport" <mike.rapoport@gmail.com>,
"Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>,
"Noralf Trønnes" <noralf@tronnes.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/5] staging: fbtft: fbtft_request_gpios: reduce nesting
Date: Sun, 16 Aug 2015 23:36:35 +0300 [thread overview]
Message-ID: <1439757397-2304-4-git-send-email-mike.rapoport@gmail.com> (raw)
In-Reply-To: <1439757397-2304-1-git-send-email-mike.rapoport@gmail.com>
Returning immediately if no platform_data or platform_data->gpios is
specified reduceis code nesting
Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
---
drivers/staging/fbtft/fbtft-core.c | 51 +++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 81ba416..f55936a 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -127,33 +127,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;
--
1.8.3.1
next prev parent reply other threads:[~2015-08-16 20:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-16 20:36 [PATCH 0/5] staging: fbtft: some checpatch.pl cleanups Mike Rapoport
2015-08-16 20:36 ` [PATCH 1/5] staging: fbtft: remove unused bl_ops from fbtft_unregister_backlight Mike Rapoport
2015-09-03 1:08 ` Greg Kroah-Hartman
2015-08-16 20:36 ` [PATCH 2/5] staging: fbtft: fbtft-core: define backlight_ops statically Mike Rapoport
2015-08-16 20:36 ` Mike Rapoport [this message]
2015-08-16 20:36 ` [PATCH 4/5] staging: fbtft: fb_ssd1351: " Mike Rapoport
2015-08-16 20:36 ` [PATCH 5/5] staging: fbtft: fb_watterott: " Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439757397-2304-4-git-send-email-mike.rapoport@gmail.com \
--to=mike.rapoport@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noralf@tronnes.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox