Skip to content

Commit e35bc5d

Browse files
Ansuellag-linaro
authored andcommitted
leds: leds-lp55xx: Generalize turn_off_channels function
Generalize turn_off_channels function as the implementation is the same for most of the lp55xx based LED driver. Suggested-by: Lee Jones <[email protected]> Signed-off-by: Christian Marangi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 01e0290 commit e35bc5d

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

drivers/leds/leds-lp5523.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,12 @@ static void lp5523_stop_engine(struct lp55xx_chip *chip)
167167
lp5523_wait_opmode_done();
168168
}
169169

170-
static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
171-
{
172-
int i;
173-
174-
for (i = 0; i < LP5523_MAX_LEDS; i++)
175-
lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0);
176-
}
177-
178170
static void lp5523_run_engine(struct lp55xx_chip *chip, bool start)
179171
{
180172
/* stop engine */
181173
if (!start) {
182174
lp5523_stop_engine(chip);
183-
lp5523_turn_off_channels(chip);
175+
lp55xx_turn_off_channels(chip);
184176
return;
185177
}
186178

drivers/leds/leds-lp55xx-common.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ void lp55xx_set_led_current(struct lp55xx_led *led, u8 led_current)
288288
}
289289
EXPORT_SYMBOL_GPL(lp55xx_set_led_current);
290290

291+
void lp55xx_turn_off_channels(struct lp55xx_chip *chip)
292+
{
293+
const struct lp55xx_device_config *cfg = chip->cfg;
294+
int i;
295+
296+
for (i = 0; i < cfg->max_channel; i++)
297+
lp55xx_write(chip, cfg->reg_led_pwm_base.addr + i, 0);
298+
}
299+
EXPORT_SYMBOL_GPL(lp55xx_turn_off_channels);
300+
291301
static void lp55xx_reset_device(struct lp55xx_chip *chip)
292302
{
293303
const struct lp55xx_device_config *cfg = chip->cfg;

drivers/leds/leds-lp55xx-common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ extern void lp55xx_firmware_loaded_cb(struct lp55xx_chip *chip);
220220
extern int lp55xx_led_brightness(struct lp55xx_led *led);
221221
extern int lp55xx_multicolor_brightness(struct lp55xx_led *led);
222222
extern void lp55xx_set_led_current(struct lp55xx_led *led, u8 led_current);
223+
extern void lp55xx_turn_off_channels(struct lp55xx_chip *chip);
223224

224225
/* common probe/remove function */
225226
extern int lp55xx_probe(struct i2c_client *client);

drivers/leds/leds-lp8501.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,12 @@ static int lp8501_post_init_device(struct lp55xx_chip *chip)
110110
LP8501_PWR_CONFIG_M, chip->pdata->pwr_sel);
111111
}
112112

113-
static void lp8501_turn_off_channels(struct lp55xx_chip *chip)
114-
{
115-
int i;
116-
117-
for (i = 0; i < LP8501_MAX_LEDS; i++)
118-
lp55xx_write(chip, LP8501_REG_LED_PWM_BASE + i, 0);
119-
}
120-
121113
static void lp8501_run_engine(struct lp55xx_chip *chip, bool start)
122114
{
123115
/* stop engine */
124116
if (!start) {
125117
lp55xx_stop_all_engine(chip);
126-
lp8501_turn_off_channels(chip);
118+
lp55xx_turn_off_channels(chip);
127119
return;
128120
}
129121

0 commit comments

Comments
 (0)