]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: leds-lp55xx: Generalize turn_off_channels function
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 26 Jun 2024 16:00:18 +0000 (18:00 +0200)
committerLee Jones <lee@kernel.org>
Wed, 26 Jun 2024 16:08:31 +0000 (17:08 +0100)
Generalize turn_off_channels function as the implementation is the same for
most of the lp55xx based LED driver.

Suggested-by: Lee Jones <lee@kernel.org>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240626160027.19703-14-ansuelsmth@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp55xx-common.h
drivers/leds/leds-lp8501.c

index 3030a44958088e5e4459420c7ffb246af82412cb..4a4463cb44a4b206750496e4fae942912299157c 100644 (file)
@@ -167,20 +167,12 @@ static void lp5523_stop_engine(struct lp55xx_chip *chip)
        lp5523_wait_opmode_done();
 }
 
-static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
-{
-       int i;
-
-       for (i = 0; i < LP5523_MAX_LEDS; i++)
-               lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0);
-}
-
 static void lp5523_run_engine(struct lp55xx_chip *chip, bool start)
 {
        /* stop engine */
        if (!start) {
                lp5523_stop_engine(chip);
-               lp5523_turn_off_channels(chip);
+               lp55xx_turn_off_channels(chip);
                return;
        }
 
index d17538ebfcf97ee4fddaa515a625b2a7fba4cae7..58121f27f17bb5418eadcae96609f37d08393e53 100644 (file)
@@ -288,6 +288,16 @@ void lp55xx_set_led_current(struct lp55xx_led *led, u8 led_current)
 }
 EXPORT_SYMBOL_GPL(lp55xx_set_led_current);
 
+void lp55xx_turn_off_channels(struct lp55xx_chip *chip)
+{
+       const struct lp55xx_device_config *cfg = chip->cfg;
+       int i;
+
+       for (i = 0; i < cfg->max_channel; i++)
+               lp55xx_write(chip, cfg->reg_led_pwm_base.addr + i, 0);
+}
+EXPORT_SYMBOL_GPL(lp55xx_turn_off_channels);
+
 static void lp55xx_reset_device(struct lp55xx_chip *chip)
 {
        const struct lp55xx_device_config *cfg = chip->cfg;
index e638049d929795d846cce4d6d549065c83dd8217..531fbb0acb2e040ff64fba5612f57d4d99adaf86 100644 (file)
@@ -220,6 +220,7 @@ extern void lp55xx_firmware_loaded_cb(struct lp55xx_chip *chip);
 extern int lp55xx_led_brightness(struct lp55xx_led *led);
 extern int lp55xx_multicolor_brightness(struct lp55xx_led *led);
 extern void lp55xx_set_led_current(struct lp55xx_led *led, u8 led_current);
+extern void lp55xx_turn_off_channels(struct lp55xx_chip *chip);
 
 /* common probe/remove function */
 extern int lp55xx_probe(struct i2c_client *client);
index d924572e4533a3c5e2933adfdb2c390165ed585c..1fb876f64cb7b51eef026a8ee3673f0d5fa8650a 100644 (file)
@@ -110,20 +110,12 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip)
                                LP8501_PWR_CONFIG_M, chip->pdata->pwr_sel);
 }
 
-static void lp8501_turn_off_channels(struct lp55xx_chip *chip)
-{
-       int i;
-
-       for (i = 0; i < LP8501_MAX_LEDS; i++)
-               lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + i, 0);
-}
-
 static void lp8501_run_engine(struct lp55xx_chip *chip, bool start)
 {
        /* stop engine */
        if (!start) {
                lp55xx_stop_all_engine(chip);
-               lp8501_turn_off_channels(chip);
+               lp55xx_turn_off_channels(chip);
                return;
        }