Skip to content

Commit 28c9266

Browse files
Milo Kimcooloney
authored andcommitted
leds: lp5521/5523: Fix multiple engine usage bug
Whenever the engine is loaded by the user-application, the operation mode is reset first. But it has a problem in case of multiple engine used because previous engine settings are cleared. The driver should update not whole 8bits but each engine bit by masking. On the other hands, whole engines should be reset when the driver is unloaded and on initializing the LP5523 driver. So, new functions are used for this handling - lp5521/5523_stop_all_engines(). Cc: Pali Rohár <pali.rohar@gmail.com> Signed-off-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
1 parent 1f431af commit 28c9266

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

‎drivers/leds/leds-lp5521.c‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,26 @@ static void lp5521_load_engine(struct lp55xx_chip *chip)
152152
lp5521_wait_opmode_done();
153153
}
154154

155-
static void lp5521_stop_engine(struct lp55xx_chip *chip)
155+
static void lp5521_stop_all_engines(struct lp55xx_chip *chip)
156156
{
157157
lp55xx_write(chip, LP5521_REG_OP_MODE, 0);
158158
lp5521_wait_opmode_done();
159159
}
160160

161+
static void lp5521_stop_engine(struct lp55xx_chip *chip)
162+
{
163+
enum lp55xx_engine_index idx = chip->engine_idx;
164+
u8 mask[] = {
165+
[LP55XX_ENGINE_1] = LP5521_MODE_R_M,
166+
[LP55XX_ENGINE_2] = LP5521_MODE_G_M,
167+
[LP55XX_ENGINE_3] = LP5521_MODE_B_M,
168+
};
169+
170+
lp55xx_update_bits(chip, LP5521_REG_OP_MODE, mask[idx], 0);
171+
172+
lp5521_wait_opmode_done();
173+
}
174+
161175
static void lp5521_run_engine(struct lp55xx_chip *chip, bool start)
162176
{
163177
int ret;
@@ -568,7 +582,7 @@ static int lp5521_remove(struct i2c_client *client)
568582
struct lp55xx_led *led = i2c_get_clientdata(client);
569583
struct lp55xx_chip *chip = led->chip;
570584

571-
lp5521_stop_engine(chip);
585+
lp5521_stop_all_engines(chip);
572586
lp55xx_unregister_sysfs(chip);
573587
lp55xx_unregister_leds(led, chip);
574588
lp55xx_deinit_device(chip);

‎drivers/leds/leds-lp5523.c‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,26 @@ static void lp5523_load_engine_and_select_page(struct lp55xx_chip *chip)
187187
lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]);
188188
}
189189

190-
static void lp5523_stop_engine(struct lp55xx_chip *chip)
190+
static void lp5523_stop_all_engines(struct lp55xx_chip *chip)
191191
{
192192
lp55xx_write(chip, LP5523_REG_OP_MODE, 0);
193193
lp5523_wait_opmode_done();
194194
}
195195

196+
static void lp5523_stop_engine(struct lp55xx_chip *chip)
197+
{
198+
enum lp55xx_engine_index idx = chip->engine_idx;
199+
u8 mask[] = {
200+
[LP55XX_ENGINE_1] = LP5523_MODE_ENG1_M,
201+
[LP55XX_ENGINE_2] = LP5523_MODE_ENG2_M,
202+
[LP55XX_ENGINE_3] = LP5523_MODE_ENG3_M,
203+
};
204+
205+
lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0);
206+
207+
lp5523_wait_opmode_done();
208+
}
209+
196210
static void lp5523_turn_off_channels(struct lp55xx_chip *chip)
197211
{
198212
int i;
@@ -303,7 +317,7 @@ static int lp5523_init_program_engine(struct lp55xx_chip *chip)
303317
}
304318

305319
out:
306-
lp5523_stop_engine(chip);
320+
lp5523_stop_all_engines(chip);
307321
return ret;
308322
}
309323

@@ -778,7 +792,7 @@ static int lp5523_remove(struct i2c_client *client)
778792
struct lp55xx_led *led = i2c_get_clientdata(client);
779793
struct lp55xx_chip *chip = led->chip;
780794

781-
lp5523_stop_engine(chip);
795+
lp5523_stop_all_engines(chip);
782796
lp55xx_unregister_sysfs(chip);
783797
lp55xx_unregister_leds(led, chip);
784798
lp55xx_deinit_device(chip);

0 commit comments

Comments
 (0)