diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index f452d328997a..3ce3bade3b8d 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1627,7 +1627,6 @@ static int wled_configure_ovp_irq(struct wled *wled, struct platform_device *pdev) { int rc; - u32 val; wled->ovp_irq = platform_get_irq_byname(pdev, "ovp"); if (wled->ovp_irq < 0) { @@ -1643,13 +1642,8 @@ static int wled_configure_ovp_irq(struct wled *wled, return 0; } - rc = regmap_read(wled->regmap, wled->ctrl_addr + - WLED3_CTRL_REG_MOD_EN, &val); - if (rc < 0) - return rc; - - /* Keep OVP irq disabled until module is enabled */ - if (!(val & WLED3_CTRL_REG_MOD_EN_MASK)) + /* Keep the OVP irq disabled until the module is enabled */ + if (!wled->brightness) disable_irq(wled->ovp_irq); return 0; @@ -1665,6 +1659,7 @@ static int wled_probe(struct platform_device *pdev) struct backlight_device *bl; struct wled *wled; struct regmap *regmap; + u32 mod_en; u32 val; int rc; @@ -1735,6 +1730,24 @@ static int wled_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&wled->ovp_work, wled_ovp_work); + val = WLED_DEFAULT_BRIGHTNESS; + of_property_read_u32(pdev->dev.of_node, "default-brightness", &val); + + /* + * The module may already be enabled, either by a bootloader that left + * the backlight lit or by the setup above. Record that, so that the + * first brightness update does not enable an already enabled module, + * and so that the OVP irq is armed from probe rather than from that + * first update. + */ + rc = regmap_read(wled->regmap, wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, + &mod_en); + if (rc < 0) + return rc; + + if (mod_en & WLED3_CTRL_REG_MOD_EN_MASK) + wled->brightness = val; + rc = wled_configure_short_irq(wled, pdev); if (rc < 0) return rc; @@ -1743,9 +1756,6 @@ static int wled_probe(struct platform_device *pdev) if (rc < 0) return rc; - val = WLED_DEFAULT_BRIGHTNESS; - of_property_read_u32(pdev->dev.of_node, "default-brightness", &val); - memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.brightness = val;