backlight: lm3630a: Use backlight_get_brightness helper in update_status
authorLuca Weiss <luca@z3ntu.xyz>
Mon, 19 Feb 2024 23:11:21 +0000 (00:11 +0100)
committerLee Jones <lee@kernel.org>
Thu, 7 Mar 2024 09:03:29 +0000 (09:03 +0000)
As per documentation "drivers are expected to use this function in their
update_status() operation to get the brightness value.".

With this we can also drop the manual backlight_is_blank() handling
since backlight_get_brightness() is already handling this correctly.

Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20240220-lm3630a-fixups-v1-3-9ca62f7e4a33@z3ntu.xyz
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/lm3630a_bl.c

index 26ff4178cc1612ac6c43118150fa9df813cdc4b9..e6c0916ec88bb5ac1aa5af4424010a5faa3d6e13 100644 (file)
@@ -189,10 +189,11 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
        int ret;
        struct lm3630a_chip *pchip = bl_get_data(bl);
        enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
+       int brightness = backlight_get_brightness(bl);
 
        /* pwm control */
        if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0)
-               return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
+               return lm3630a_pwm_ctrl(pchip, brightness,
                                        bl->props.max_brightness);
 
        /* disable sleep */
@@ -201,9 +202,9 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
                goto out_i2c_err;
        usleep_range(1000, 2000);
        /* minimum brightness is 0x04 */
-       ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness);
+       ret = lm3630a_write(pchip, REG_BRT_A, brightness);
 
-       if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4))
+       if (brightness < 0x4)
                /* turn the string off  */
                ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0);
        else
@@ -263,10 +264,11 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
        int ret;
        struct lm3630a_chip *pchip = bl_get_data(bl);
        enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
+       int brightness = backlight_get_brightness(bl);
 
        /* pwm control */
        if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0)
-               return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
+               return lm3630a_pwm_ctrl(pchip, brightness,
                                        bl->props.max_brightness);
 
        /* disable sleep */
@@ -275,9 +277,9 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
                goto out_i2c_err;
        usleep_range(1000, 2000);
        /* minimum brightness is 0x04 */
-       ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness);
+       ret = lm3630a_write(pchip, REG_BRT_B, brightness);
 
-       if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4))
+       if (brightness < 0x4)
                /* turn the string off  */
                ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0);
        else