From: Marcin Slusarz Date: Sun, 27 Jan 2013 14:51:09 +0000 (+0100) Subject: drm/nouveau/fan: fix selection of fan speed when fan->get returns an error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc3109a2cb294335bcf3c5db5e16ae5fe68849f2;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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: Marcin Slusarz Signed-off-by: Ben Skeggs --- diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c index b179655e639c..c728380d3d62 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c @@ -39,7 +39,7 @@ nouveau_fan_update(struct nouveau_fan *fan, bool immediate, int target) struct nouveau_timer *ptimer = nouveau_timer(priv); unsigned long flags; int ret = 0; - u32 duty; + int duty; /* update target fan speed, restricting to allowed range */ spin_lock_irqsave(&fan->lock, flags); @@ -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 */ if (duty < target) - duty = min(duty + 3, (u32) target); + duty = min(duty + 3, target); else if (duty > target) - duty = max(duty - 3, (u32) target); + duty = max(duty - 3, target); } else { duty = target; }