summaryrefslogtreecommitdiff
path: root/common/rgb_keyboard.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2022-04-16 00:28:50 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-19 16:22:43 +0000
commit3bc00d59f3d5c288e258db73e7224af4cc861cff (patch)
tree308f3cd88d86f12e0163b06fe13a62f66995d329 /common/rgb_keyboard.c
parent1107b39af8ab3a6b73b5a40e489564c7e49bfa2a (diff)
downloadchrome-ec-3bc00d59f3d5c288e258db73e7224af4cc861cff.tar.gz
RGBKBD: Exit loop when reaching the end of LED group
Each LED group of LED mapping table is terminated by 0xff. Currently, this terminator isn't checked and causing set_color to return error. Though this produces the same result, it's confusing to see an error message on every EC_CMD_RGBKBD_SET_COLOR. This patch makes the command exit the loop when it encounters a terminator. BUG=b:229012657 BRANCH=None TEST=On Vell. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Change-Id: I4263b4d2e928cfc5e34a4a9bc18e68a5654a5a85 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3589194 Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Diffstat (limited to 'common/rgb_keyboard.c')
-rw-r--r--common/rgb_keyboard.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c
index c9987c5e5b..b5a8bfae40 100644
--- a/common/rgb_keyboard.c
+++ b/common/rgb_keyboard.c
@@ -403,12 +403,15 @@ static enum ec_status hc_rgbkbd_set_color(struct host_cmd_handler_args *args)
uint8_t j = rgbkbd_table[p->start_key + i];
union rgbkbd_coord_u8 led;
- if (j == RGBKBD_NONE || rgbkbd_map[j] == RGBKBD_DELM)
- /* Empty entry */
+ if (j == RGBKBD_NONE)
+ /* Null or uninitialized entry */
continue;
do {
led.u8 = rgbkbd_map[j++];
+ if (led.u8 == RGBKBD_DELM)
+ /* Reached end of the group. */
+ break;
if (set_color_single(p->color[i],
led.coord.x, led.coord.y))
return EC_RES_ERROR;