summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-05-18 13:54:20 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-24 07:37:48 -0400
commitee9d9b0cd2f645a3dae539909175ce29a262c8b6 (patch)
tree053ab5f50355f3ae58e29f39d37f569fd05b6e98 /drivers
parent2788943d3871cd84ada8cfe1dc56ce4f5a1ae6ab (diff)
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 <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1724093 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Aleksandr Frid <afrid@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gm20b/clk_gm20b.c2
1 files changed, 1 insertions, 1 deletions
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,
204 if (vco_f >= min_vco_f && vco_f <= max_vco_f) { 204 if (vco_f >= min_vco_f && vco_f <= max_vco_f) {
205 lwv = (vco_f + (nvgpu_pl_to_div(pl) / 2)) 205 lwv = (vco_f + (nvgpu_pl_to_div(pl) / 2))
206 / nvgpu_pl_to_div(pl); 206 / nvgpu_pl_to_div(pl);
207 delta = abs(lwv - target_clk_f); 207 delta = abs((s32)(lwv - target_clk_f));
208 208
209 if (delta < best_delta) { 209 if (delta < best_delta) {
210 best_delta = delta; 210 best_delta = delta;