From: Joe Perches <joe@perches.com>
To: Mark Brown <broonie@kernel.org>, hubiaoyong <hubiaoyong@gmail.com>
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org, hby2003@163.com
Subject: Re: [PATCH] regulator/core.c: remove the else statement
Date: Tue, 18 Apr 2017 09:28:41 -0700 [thread overview]
Message-ID: <1492532921.8661.42.camel@perches.com> (raw)
In-Reply-To: <20170418154947.tuom2jg5hwcpzje2@sirena.org.uk>
On Tue, 2017-04-18 at 16:49 +0100, Mark Brown wrote:
> On Tue, Apr 18, 2017 at 11:39:34PM +0800, hubiaoyong wrote:
> > in the function regulator_ena_gpio_free, the if branch contains
> > the return statement, so remove the else statement.
>
> Why is it a benefit to make this change?
In general, reducing source code indentation is a good thing.
The logic today is:
/* Free the GPIO only in case of no use */
list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) {
if (pin->gpiod == rdev->ena_pin->gpiod) {
if (pin->request_count <= 1) {
pin->request_count = 0;
gpiod_put(pin->gpiod);
list_del(&pin->list);
kfree(pin);
rdev->ena_pin = NULL;
return;
} else {
pin->request_count--;
}
}
}
Perhaps it's better written as:
/* Free the GPIO only in case of no use */
list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) {
if (pin->gpiod != rdev->ena_pin->gpiod)
continue;
if (pin->request_count <= 1) {
pin->request_count = 0;
gpiod_put(pin->gpiod);
list_del(&pin->list);
kfree(pin);
rdev->ena_pin = NULL;
return;
}
pin->request_count--;
}
next prev parent reply other threads:[~2017-04-18 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-18 15:39 [PATCH] regulator/core.c: remove the else statement hubiaoyong
2017-04-18 15:49 ` Mark Brown
2017-04-18 16:28 ` Joe Perches [this message]
[not found] ` <CAJPOojYT0Mk-+_Enmtz6C1ZRGDmMcnQLMAOXvGwKAs+bM67tMg@mail.gmail.com>
2017-04-19 16:26 ` Mark Brown
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=1492532921.8661.42.camel@perches.com \
--to=joe@perches.com \
--cc=broonie@kernel.org \
--cc=hby2003@163.com \
--cc=hubiaoyong@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).