> Subject: Re: [PATCH] drm/i915/backlight: Fix divide by 0 error in > i9xx_set_backlight > > On Tue, 19 Aug 2025, Suraj Kandpal <[email protected]> wrote: > > pwm_level_max maybe 0 we do throw a warning but move ahead with > > execution which may later cause a /0 error. > > This is not supposed to happen, so don't overcomplicate. > > if (warn on) > return >
Sure will return from here Regards, Suraj Kandpal > > > > Signed-off-by: Suraj Kandpal <[email protected]> > > --- > > drivers/gpu/drm/i915/display/intel_backlight.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c > > b/drivers/gpu/drm/i915/display/intel_backlight.c > > index e007380e9a63..d0e9de8ab834 100644 > > --- a/drivers/gpu/drm/i915/display/intel_backlight.c > > +++ b/drivers/gpu/drm/i915/display/intel_backlight.c > > @@ -234,6 +234,7 @@ static void i9xx_set_backlight(const struct > drm_connector_state *conn_state, u32 > > struct intel_connector *connector = to_intel_connector(conn_state- > >connector); > > struct intel_display *display = to_intel_display(connector); > > struct intel_panel *panel = &connector->panel; > > + u32 max_level = panel->backlight.pwm_level_max ?: 1; > > u32 tmp, mask; > > > > drm_WARN_ON(display->drm, panel->backlight.pwm_level_max == 0); > @@ > > -242,7 +243,7 @@ static void i9xx_set_backlight(const struct > drm_connector_state *conn_state, u32 > > struct pci_dev *pdev = to_pci_dev(display->drm->dev); > > u8 lbpc; > > > > - lbpc = level * 0xfe / panel->backlight.pwm_level_max + 1; > > + lbpc = level * 0xfe / max_level + 1; > > level /= lbpc; > > pci_write_config_byte(pdev, LBPC, lbpc); > > } > > -- > Jani Nikula, Intel
