From: Sebastian Reichel <sre@kernel.org>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: power: supply: Compress return logic into one line.
Date: Tue, 17 Jan 2017 00:42:19 +0100 [thread overview]
Message-ID: <20170116234219.nkwgpyb4wyuq4ozq@earth> (raw)
In-Reply-To: <20170112022935.GA22272@embeddedgus>
[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]
Hi,
On Wed, Jan 11, 2017 at 08:29:35PM -0600, Gustavo A. R. Silva wrote:
> Simplify return logic to avoid unnecessary variable assignments.
> These issues were detected using Coccinelle and the following semantic patch:
>
> @@
> local idexpression ret;
> expression e;
> @@
>
> -ret =
> +return
> e;
> -return ret;
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> drivers/power/supply/ab8500_btemp.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
> index 6ffdc18..9b01b52 100644
> --- a/drivers/power/supply/ab8500_btemp.c
> +++ b/drivers/power/supply/ab8500_btemp.c
> @@ -123,10 +123,7 @@ static LIST_HEAD(ab8500_btemp_list);
> */
> struct ab8500_btemp *ab8500_btemp_get(void)
> {
> - struct ab8500_btemp *btemp;
> - btemp = list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
> -
> - return btemp;
> + return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node);
> }
> EXPORT_SYMBOL(ab8500_btemp_get);
>
> @@ -470,7 +467,7 @@ static int ab8500_btemp_get_batctrl_res(struct ab8500_btemp *di)
> static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di,
> const struct abx500_res_to_temp *tbl, int tbl_size, int res)
> {
> - int i, temp;
> + int i;
> /*
> * Calculate the formula for the straight line
> * Simple interpolation if we are within
> @@ -488,9 +485,8 @@ static int ab8500_btemp_res_to_temp(struct ab8500_btemp *di,
> i++;
> }
>
> - temp = tbl[i].temp + ((tbl[i + 1].temp - tbl[i].temp) *
> + return tbl[i].temp + ((tbl[i + 1].temp - tbl[i].temp) *
> (res - tbl[i].resist)) / (tbl[i + 1].resist - tbl[i].resist);
> - return temp;
> }
>
> /**
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-01-16 23:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 2:29 [PATCH] drivers: power: supply: Compress return logic into one line Gustavo A. R. Silva
2017-01-16 23:42 ` Sebastian Reichel [this message]
2017-01-19 22:24 ` Gustavo A. R. Silva
2017-01-12 2:45 Gustavo A. R. Silva
2017-01-16 23:42 ` Sebastian Reichel
2017-01-19 22:25 ` Gustavo A. R. Silva
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=20170116234219.nkwgpyb4wyuq4ozq@earth \
--to=sre@kernel.org \
--cc=garsilva@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@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).