Commit fc3109a2 authored by Marcin Slusarz's avatar Marcin Slusarz Committed by Ben Skeggs

drm/nouveau/fan: fix selection of fan speed when fan->get returns an error

fan->get returns int, but we write it to unsigned variable, and then check
whether it's >= 0 (it always is)

Found by smatch:
drivers/gpu/drm/nouveau/core/subdev/therm/fan.c:61 nouveau_fan_update() warn: always true condition '(duty >= 0) => (0-u32max >= 0)'
Signed-off-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent cd897837
...@@ -39,7 +39,7 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) ...@@ -39,7 +39,7 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
struct nouveau_timer *ptimer = nouveau_timer(priv); struct nouveau_timer *ptimer = nouveau_timer(priv);
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
u32 duty; int duty;
/* update target fan speed, restricting to allowed range */ /* update target fan speed, restricting to allowed range */
spin_lock_irqsave(&fan->lock, flags); spin_lock_irqsave(&fan->lock, flags);
...@@ -64,9 +64,9 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) ...@@ -64,9 +64,9 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target)
* it is meant to bump the fan speed more incrementally * it is meant to bump the fan speed more incrementally
*/ */
if (duty < target) if (duty < target)
duty = min(duty + 3, (u32) target); duty = min(duty + 3, target);
else if (duty > target) else if (duty > target)
duty = max(duty - 3, (u32) target); duty = max(duty - 3, target);
} else { } else {
duty = target; duty = target;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment