From 274103718a763e50679061f44ad693aadd260e85 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Mon, 24 Apr 2023 10:51:35 -0700 Subject: common/tablet: Fix printing the tablet mode table_mode is not just a boolean, it stores the cause(s) for getting in tablet mode. Fixes: c1f6b2a249250 ("common/tablet: Allow getting out of tablet mode when sensors are broken") BUG=b:279135356 TEST=Compile Change-Id: I4a50118004285da2f7ba4229e537d6cd8d7b07d1 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4468727 Reviewed-by: Douglas Anderson Reviewed-by: Daisuke Nojiri (cherry picked from commit 375ed4452465e6858e62b77b3927be4c7b678477) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4471507 Commit-Queue: Douglas Anderson Tested-by: Sue Chen Reviewed-by: Sue Chen --- common/tablet_mode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/tablet_mode.c b/common/tablet_mode.c index 93b7ff8a55..949989dcd9 100644 --- a/common/tablet_mode.c +++ b/common/tablet_mode.c @@ -19,7 +19,11 @@ /* * Other code modules assume that notebook mode (i.e. tablet_mode = 0) at - * startup + * startup. + * tablet_mode is mask, one bit for each source that can trigger a change to + * tablet mode: + * - TABLET_TRIGGER_LID: the lid angle is over the threshold. + * - TABLET_TRIGGER_BASE: the detachable keyboard is disconnected. */ static uint32_t tablet_mode; @@ -45,6 +49,7 @@ static const char *const tablet_mode_names[] = { "clamshell", "tablet", }; +BUILD_ASSERT(ARRAY_SIZE(tablet_mode_names) == 2); int tablet_get_mode(void) { @@ -53,7 +58,7 @@ int tablet_get_mode(void) static inline void print_tablet_mode(void) { - CPRINTS("%s mode", tablet_mode_names[tablet_mode]); + CPRINTS("%s mode", tablet_mode_names[tablet_get_mode()]); } static void notify_tablet_mode_change(void) -- cgit v1.2.1