leds: aw200xx: Fix write to DIM parameter
authorMartin Kurbanov <mmkurbanov@salutedevices.com>
Sat, 25 Nov 2023 20:05:09 +0000 (23:05 +0300)
committerLee Jones <lee@kernel.org>
Wed, 13 Dec 2023 11:28:53 +0000 (11:28 +0000)
If write only DIM value to the page 4, LED brightness will not be
updated, as both DIM and FADE need to be written to the page 4.
Therefore, write DIM to the page 1.

Fixes: 36a87f371b7a ("leds: Add AW20xx driver")
Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20231125200519.1750-2-ddrokosov@salutedevices.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-aw200xx.c

index 14ca236ce29e59fb65c4fedb026ec3df5405a5cf..f3bed4f05b34f58c049adf86a236adeefb9c75eb 100644 (file)
 #define AW200XX_LED2REG(x, columns) \
        ((x) + (((x) / (columns)) * (AW200XX_DSIZE_COLUMNS_MAX - (columns))))
 
+/* DIM current configuration register on page 1 */
+#define AW200XX_REG_DIM_PAGE1(x, columns) \
+       AW200XX_REG(AW200XX_PAGE1, AW200XX_LED2REG(x, columns))
+
 /*
  * DIM current configuration register (page 4).
  * The even address for current DIM configuration.
@@ -153,7 +157,8 @@ static ssize_t dim_store(struct device *dev, struct device_attribute *devattr,
 
        if (dim >= 0) {
                ret = regmap_write(chip->regmap,
-                                  AW200XX_REG_DIM(led->num, columns), dim);
+                                  AW200XX_REG_DIM_PAGE1(led->num, columns),
+                                  dim);
                if (ret)
                        goto out_unlock;
        }