Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f733cad authored by Milo Kim's avatar Milo Kim Committed by Bryan Wu
Browse files

leds: lp5523: remove unnecessary writing commands



This patch reduces the number of programming commands.

(Count of sending commands)
Old code: 32 + program size (32 counts for clearing program memory)
New code: 32

Pattern buffer is initialized to 0 in this function.
Just update new program data and remaining buffers are filled with 0.
So it's needless to clear whole area.

Signed-off-by: default avatarMilo Kim <milo.kim@ti.com>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
parent 45e611bf
Loading
Loading
Loading
Loading
+3 −11
Original line number Original line Diff line number Diff line
@@ -312,17 +312,11 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
	u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
	u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
	unsigned cmd;
	unsigned cmd;
	char c[3];
	char c[3];
	int update_size;
	int nrchars;
	int nrchars;
	int offset = 0;
	int ret;
	int ret;
	int i;
	int offset = 0;

	int i = 0;
	/* clear program memory before updating */
	for (i = 0; i < LP5523_PROGRAM_LENGTH; i++)
		lp55xx_write(chip, LP5523_REG_PROG_MEM + i, 0);


	i = 0;
	while ((offset < size - 1) && (i < LP5523_PROGRAM_LENGTH)) {
	while ((offset < size - 1) && (i < LP5523_PROGRAM_LENGTH)) {
		/* separate sscanfs because length is working only for %s */
		/* separate sscanfs because length is working only for %s */
		ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
		ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
@@ -342,11 +336,9 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
	if (i % 2)
	if (i % 2)
		goto err;
		goto err;


	update_size = i;

	mutex_lock(&chip->lock);
	mutex_lock(&chip->lock);


	for (i = 0; i < update_size; i++) {
	for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
		ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
		ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
		if (ret) {
		if (ret) {
			mutex_unlock(&chip->lock);
			mutex_unlock(&chip->lock);