Commit 794826b2 authored by Christian Marangi's avatar Christian Marangi Committed by Lee Jones

leds: leds-lp55xx: Generalize multicolor_brightness function

Generalize multicolor_brightness function as the implementation is the
same for most of the lp55xx based LED driver.
Suggested-by: default avatarLee Jones <lee@kernel.org>
Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Link: https://lore.kernel.org/r/20240626160027.19703-12-ansuelsmth@gmail.comSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent c63580b2
...@@ -222,25 +222,6 @@ static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf) ...@@ -222,25 +222,6 @@ static int lp5521_run_selftest(struct lp55xx_chip *chip, char *buf)
return 0; return 0;
} }
static int lp5521_multicolor_brightness(struct lp55xx_led *led)
{
struct lp55xx_chip *chip = led->chip;
int ret;
int i;
mutex_lock(&chip->lock);
for (i = 0; i < led->mc_cdev.num_colors; i++) {
ret = lp55xx_write(chip,
LP5521_REG_LED_PWM_BASE +
led->mc_cdev.subled_info[i].channel,
led->mc_cdev.subled_info[i].brightness);
if (ret)
break;
}
mutex_unlock(&chip->lock);
return ret;
}
static ssize_t show_engine_mode(struct device *dev, static ssize_t show_engine_mode(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf, int nr) char *buf, int nr)
...@@ -381,7 +362,7 @@ static struct lp55xx_device_config lp5521_cfg = { ...@@ -381,7 +362,7 @@ static struct lp55xx_device_config lp5521_cfg = {
.max_channel = LP5521_MAX_LEDS, .max_channel = LP5521_MAX_LEDS,
.post_init_device = lp5521_post_init_device, .post_init_device = lp5521_post_init_device,
.brightness_fn = lp55xx_led_brightness, .brightness_fn = lp55xx_led_brightness,
.multicolor_brightness_fn = lp5521_multicolor_brightness, .multicolor_brightness_fn = lp55xx_multicolor_brightness,
.set_led_current = lp5521_set_led_current, .set_led_current = lp5521_set_led_current,
.firmware_cb = lp55xx_firmware_loaded_cb, .firmware_cb = lp55xx_firmware_loaded_cb,
.run_engine = lp5521_run_engine, .run_engine = lp5521_run_engine,
......
...@@ -664,25 +664,6 @@ static ssize_t store_master_fader_leds(struct device *dev, ...@@ -664,25 +664,6 @@ static ssize_t store_master_fader_leds(struct device *dev,
return ret; return ret;
} }
static int lp5523_multicolor_brightness(struct lp55xx_led *led)
{
struct lp55xx_chip *chip = led->chip;
int ret;
int i;
mutex_lock(&chip->lock);
for (i = 0; i < led->mc_cdev.num_colors; i++) {
ret = lp55xx_write(chip,
LP5523_REG_LED_PWM_BASE +
led->mc_cdev.subled_info[i].channel,
led->mc_cdev.subled_info[i].brightness);
if (ret)
break;
}
mutex_unlock(&chip->lock);
return ret;
}
static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode); static LP55XX_DEV_ATTR_RW(engine1_mode, show_engine1_mode, store_engine1_mode);
static LP55XX_DEV_ATTR_RW(engine2_mode, show_engine2_mode, store_engine2_mode); static LP55XX_DEV_ATTR_RW(engine2_mode, show_engine2_mode, store_engine2_mode);
static LP55XX_DEV_ATTR_RW(engine3_mode, show_engine3_mode, store_engine3_mode); static LP55XX_DEV_ATTR_RW(engine3_mode, show_engine3_mode, store_engine3_mode);
...@@ -754,7 +735,7 @@ static struct lp55xx_device_config lp5523_cfg = { ...@@ -754,7 +735,7 @@ static struct lp55xx_device_config lp5523_cfg = {
.max_channel = LP5523_MAX_LEDS, .max_channel = LP5523_MAX_LEDS,
.post_init_device = lp5523_post_init_device, .post_init_device = lp5523_post_init_device,
.brightness_fn = lp55xx_led_brightness, .brightness_fn = lp55xx_led_brightness,
.multicolor_brightness_fn = lp5523_multicolor_brightness, .multicolor_brightness_fn = lp55xx_multicolor_brightness,
.set_led_current = lp5523_set_led_current, .set_led_current = lp5523_set_led_current,
.firmware_cb = lp55xx_firmware_loaded_cb, .firmware_cb = lp55xx_firmware_loaded_cb,
.run_engine = lp5523_run_engine, .run_engine = lp5523_run_engine,
......
...@@ -256,6 +256,27 @@ int lp55xx_led_brightness(struct lp55xx_led *led) ...@@ -256,6 +256,27 @@ int lp55xx_led_brightness(struct lp55xx_led *led)
} }
EXPORT_SYMBOL_GPL(lp55xx_led_brightness); EXPORT_SYMBOL_GPL(lp55xx_led_brightness);
int lp55xx_multicolor_brightness(struct lp55xx_led *led)
{
struct lp55xx_chip *chip = led->chip;
const struct lp55xx_device_config *cfg = chip->cfg;
int ret;
int i;
mutex_lock(&chip->lock);
for (i = 0; i < led->mc_cdev.num_colors; i++) {
ret = lp55xx_write(chip,
cfg->reg_led_pwm_base.addr +
led->mc_cdev.subled_info[i].channel,
led->mc_cdev.subled_info[i].brightness);
if (ret)
break;
}
mutex_unlock(&chip->lock);
return ret;
}
EXPORT_SYMBOL_GPL(lp55xx_multicolor_brightness);
static void lp55xx_reset_device(struct lp55xx_chip *chip) static void lp55xx_reset_device(struct lp55xx_chip *chip)
{ {
const struct lp55xx_device_config *cfg = chip->cfg; const struct lp55xx_device_config *cfg = chip->cfg;
......
...@@ -216,6 +216,7 @@ extern int lp55xx_update_program_memory(struct lp55xx_chip *chip, ...@@ -216,6 +216,7 @@ extern int lp55xx_update_program_memory(struct lp55xx_chip *chip,
const u8 *data, size_t size); const u8 *data, size_t size);
extern void lp55xx_firmware_loaded_cb(struct lp55xx_chip *chip); extern void lp55xx_firmware_loaded_cb(struct lp55xx_chip *chip);
extern int lp55xx_led_brightness(struct lp55xx_led *led); extern int lp55xx_led_brightness(struct lp55xx_led *led);
extern int lp55xx_multicolor_brightness(struct lp55xx_led *led);
/* common probe/remove function */ /* common probe/remove function */
extern int lp55xx_probe(struct i2c_client *client); extern int lp55xx_probe(struct i2c_client *client);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment