From ee9d9b0cd2f645a3dae539909175ce29a262c8b6 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 18 May 2018 10:54:20 -0700 Subject: gpu: nvgpu: Cast unsigned arith to signed for abs() Before passing in an unsigned value to abs() cast the result of the subtraction to signed. In Linux this happens automatically but on non-Linux platforms abs() does not necessarily do this. clang flags this case as a pointless operation: abs(x) obviously must equal x for any unsigned x. This change should hopefully preserve the Linux behavior but avoid the compiler warning from clang. JIRA NVGPU-525 Change-Id: I71320964c0922f1e4890c8b25d801f17e54ed3c0 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1724093 Reviewed-by: svc-mobile-coverity Reviewed-by: Aleksandr Frid GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gm20b/clk_gm20b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c index 223166d1..e5cc6352 100644 --- a/drivers/gpu/nvgpu/gm20b/clk_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/clk_gm20b.c @@ -204,7 +204,7 @@ static int clk_config_pll(struct clk_gk20a *clk, struct pll *pll, if (vco_f >= min_vco_f && vco_f <= max_vco_f) { lwv = (vco_f + (nvgpu_pl_to_div(pl) / 2)) / nvgpu_pl_to_div(pl); - delta = abs(lwv - target_clk_f); + delta = abs((s32)(lwv - target_clk_f)); if (delta < best_delta) { best_delta = delta; -- cgit v1.2.2