lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220713145655.3844109-3-carlos.bilbao@amd.com>
Date:   Wed, 13 Jul 2022 09:56:56 -0500
From:   Carlos Bilbao <carlos.bilbao@....com>
To:     <bjorn.andersson@...aro.org>, <amitk@...nel.org>,
        <thara.gopinath@...il.com>, <konrad.dybcio@...ainline.org>
CC:     <agross@...nel.org>, <david.brown@...aro.org>,
        <linux-pm@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <bilbao@...edu>,
        Carlos Bilbao <carlos.bilbao@....com>
Subject: [PATCH 2/4] thermal/drivers/qcom: Simplify function code_to_degc()

Simplify code_to_degc() so we don't need a third variable.

Signed-off-by: Carlos Bilbao <carlos.bilbao@....com>
---
 drivers/thermal/qcom/tsens-common.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index 528df8801254..492b0e9cc2a2 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -66,21 +66,18 @@ void compute_intercept_slope(struct tsens_priv *priv, u32 *p1,
 
 static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
 {
-	int degc, num, den;
+	int num, den;
 
 	num = (adc_code * SLOPE_FACTOR) - s->offset;
 	den = s->slope;
 
+	if (!num)
+		return 0;
+
 	if (num > 0)
-		degc = num + (den / 2);
-	else if (num < 0)
-		degc = num - (den / 2);
+		return (num + (den / 2)) / den;
 	else
-		degc = num;
-
-	degc /= den;
-
-	return degc;
+		return (num - (den / 2)) / den;
 }
 
 int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp)
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ