diff options
author | Gustavo A. R. Silva <silvagustavosilva@gmail.com> | 2017-01-11 20:29:35 -0600 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2017-01-17 00:28:38 +0100 |
commit | 33237fb8f01e525e2677ca7658bea11545446be8 (patch) | |
tree | 1c95fac375ee1fa3800ec9fc0655f103859f81d5 | |
parent | c0d21f73ae44fd85102ec684b58d9e4f9e78d485 (diff) | |
download | linux-stable-33237fb8f01e525e2677ca7658bea11545446be8.tar.gz linux-stable-33237fb8f01e525e2677ca7658bea11545446be8.tar.bz2 linux-stable-33237fb8f01e525e2677ca7658bea11545446be8.zip |
power: supply: ab8500_btemp: Compress return logic into one line.
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>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r-- | drivers/power/supply/ab8500_btemp.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c index ae0a84f0b0a7..f7a35ebfbab2 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; } /** |