lkml.org 
[lkml]   [2023]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectdrm/nouveau: fan:
Hi,

static analysis with cppcheck has detected an issue in function
nvkm_fan_update() in drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c as
follows:

/* schedule next fan update, if not at target speed already */
if (target != duty) {
u16 bump_period = fan->bios.bump_period;
u16 slow_down_period = fan->bios.slow_down_period;
u64 delay;

if (duty > target)
delay = slow_down_period;
else if (duty == target)
delay = min(bump_period, slow_down_period) ;
else
delay = bump_period;

nvkm_timer_alarm(tmr, delay * 1000 * 1000, &fan->alarm);
}

Checking drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c ...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c:93:17: warning: Opposite
inner 'if' condition leads to a dead code block. [oppositeInnerCondition]
else if (duty == target)
^

The first if statement checks if target != duty, however inside the code
block there is a check if duty == target which can never be true. Either
the logic is wrong, or the duty == target can be safely removed.

Colin

\
 
 \ /
  Last update: 2023-07-28 10:10    [W:0.022 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site