summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5562.c
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2024-06-26 18:00:10 +0200
committerLee Jones <lee@kernel.org>2024-06-26 18:08:30 +0200
commit4d310b96f2db602830c40f82a75ede799b243cce (patch)
tree2143ccdbc7a3a20485a5299042e5489349cb598e /drivers/leds/leds-lp5562.c
parentleds: leds-lp55xx: Generalize probe/remove functions (diff)
downloadlinux-4d310b96f2db602830c40f82a75ede799b243cce.tar.xz
linux-4d310b96f2db602830c40f82a75ede799b243cce.zip
leds: leds-lp55xx: Generalize load_engine function
LED driver based on lp55xx have all a very similar implementation for load_engine function. Move the function to lp55xx-common and rework the define to be more dynamic instead of having to declare a temp array for them. Engine mask are the same for every LED based on lp55xx. Suggested-by: Lee Jones <lee@kernel.org> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Link: https://lore.kernel.org/r/20240626160027.19703-6-ansuelsmth@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-lp5562.c')
-rw-r--r--drivers/leds/leds-lp5562.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c
index 65a6a05c3848..5e26a52f534f 100644
--- a/drivers/leds/leds-lp5562.c
+++ b/drivers/leds/leds-lp5562.c
@@ -124,26 +124,6 @@ static void lp5562_set_led_current(struct lp55xx_led *led, u8 led_current)
lp55xx_write(led->chip, addr[led->chan_nr], led_current);
}
-static void lp5562_load_engine(struct lp55xx_chip *chip)
-{
- enum lp55xx_engine_index idx = chip->engine_idx;
- static const u8 mask[] = {
- [LP55XX_ENGINE_1] = LP5562_MODE_ENG1_M,
- [LP55XX_ENGINE_2] = LP5562_MODE_ENG2_M,
- [LP55XX_ENGINE_3] = LP5562_MODE_ENG3_M,
- };
-
- static const u8 val[] = {
- [LP55XX_ENGINE_1] = LP5562_LOAD_ENG1,
- [LP55XX_ENGINE_2] = LP5562_LOAD_ENG2,
- [LP55XX_ENGINE_3] = LP5562_LOAD_ENG3,
- };
-
- lp55xx_update_bits(chip, LP5562_REG_OP_MODE, mask[idx], val[idx]);
-
- lp5562_wait_opmode_done();
-}
-
static void lp5562_run_engine(struct lp55xx_chip *chip, bool start)
{
int ret;
@@ -270,7 +250,7 @@ static void lp5562_firmware_loaded(struct lp55xx_chip *chip)
* 2) write firmware data into program memory
*/
- lp5562_load_engine(chip);
+ lp55xx_load_engine(chip);
lp5562_update_firmware(chip, fw->data, fw->size);
}
@@ -371,7 +351,7 @@ static int lp5562_run_predef_led_pattern(struct lp55xx_chip *chip, int mode)
/* Load engines */
for (i = LP55XX_ENGINE_1; i <= LP55XX_ENGINE_3; i++) {
chip->engine_idx = i;
- lp5562_load_engine(chip);
+ lp55xx_load_engine(chip);
}
/* Clear program registers */