diff options
author | Christian Marangi <ansuelsmth@gmail.com> | 2024-06-26 18:00:15 +0200 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2024-06-26 17:08:31 +0100 |
commit | c63580b27a2c638cbae2fc26484b0bf29f303134 (patch) | |
tree | 2c08eae93689cff746021a5f6c6a33cba8201772 /drivers/leds/leds-lp5521.c | |
parent | a3df1906fb9aa9ff45149e0a3c6434b2cef4f6e7 (diff) |
leds: leds-lp55xx: Generalize led_brightness function
Generalize led_brightness function as the implementation is the same for
most of the lp55xx based LED driver.
Introduce a new option in device_config, reg_led_pwm_base since the reg
value is not the same for every LED chip.
Suggested-by: Lee Jones <lee@kernel.org>
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240626160027.19703-11-ansuelsmth@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r-- | drivers/leds/leds-lp5521.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 722b5cd9236e..e4d0dcdbf11b 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -241,19 +241,6 @@ static int lp5521_multicolor_brightness(struct lp55xx_led *led) return ret; } -static int lp5521_led_brightness(struct lp55xx_led *led) -{ - struct lp55xx_chip *chip = led->chip; - int ret; - - mutex_lock(&chip->lock); - ret = lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr, - led->brightness); - mutex_unlock(&chip->lock); - - return ret; -} - static ssize_t show_engine_mode(struct device *dev, struct device_attribute *attr, char *buf, int nr) @@ -388,9 +375,12 @@ static struct lp55xx_device_config lp5521_cfg = { .prog_mem_base = { .addr = LP5521_REG_R_PROG_MEM, }, + .reg_led_pwm_base = { + .addr = LP5521_REG_LED_PWM_BASE, + }, .max_channel = LP5521_MAX_LEDS, .post_init_device = lp5521_post_init_device, - .brightness_fn = lp5521_led_brightness, + .brightness_fn = lp55xx_led_brightness, .multicolor_brightness_fn = lp5521_multicolor_brightness, .set_led_current = lp5521_set_led_current, .firmware_cb = lp55xx_firmware_loaded_cb, |