mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* drm/nouveau: fan:
@ 2023-07-28  8:09 Colin King (gmail)
  0 siblings, 0 replies; only message in thread
From: Colin King (gmail) @ 2023-07-28  8:09 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: dri-devel, ML nouveau, linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-28  8:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28  8:09 drm/nouveau: fan: Colin King (gmail)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®