On Fri, 2025-09-05 at 17:58 +0300, Ville Syrjala wrote: > From: Ville Syrjälä <ville.syrj...@linux.intel.com> > > Flatten the loop inside sanitize_wm_latency() a bit > by using 'continue'. > > Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com> > --- > drivers/gpu/drm/i915/display/skl_watermark.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c > b/drivers/gpu/drm/i915/display/skl_watermark.c > index e3305a399ddf..e11ba1a822f4 100644 > --- a/drivers/gpu/drm/i915/display/skl_watermark.c > +++ b/drivers/gpu/drm/i915/display/skl_watermark.c > @@ -3228,13 +3228,13 @@ static void sanitize_wm_latency(struct intel_display > *display) > * of the punit to satisfy this requirement. > */ > for (level = 1; level < num_levels; level++) { > - if (wm[level] == 0) { > - int i; > + if (wm[level] != 0) > + continue; > > - for (i = level + 1; i < num_levels; i++) > - wm[i] = 0; > - return; > - } > + for (level = level + 1; level < num_levels; level++) > + wm[level] = 0; > + > + return; > } > } >
This looks a bit clumsy, overwriting level in the second loop. Can't the loops be separate, somehing like: /* Find the first zero watermark */ for (level = 1; level < num_levels; level++) { if (wm[level] == 0) break; } /* Zero all remaining watermarks (if any) */ for (level = level + 1; level < num_levels; level ++) wm[level] = 0; If nothing is found, the level + 1 in the second loop will be greater than num_levels, so it will just skip. -- Cheers, Luca.