[PATCH 1/7] platform/x86: lenovo-ymc: Use enumeration to represent device posture
From: Rong Zhang
Date: Sun Nov 15 2026 - 14:28:36 EST
There are five known Yoga modes: unknown, laptop, tablet, drawing board,
and tent, but lacks symbolic representations for reuse.
Introduce an enumeration called ymc_posture to collect and represent
them. The lenovo_ymc_keymap is also refactored to use the enumeration.
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
Cc stable as the later fixes depend on this.
---
drivers/platform/x86/lenovo/ideapad-laptop.h | 9 +++++++++
drivers/platform/x86/lenovo/ymc.c | 14 +++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.h b/drivers/platform/x86/lenovo/ideapad-laptop.h
index 1e52f2aa0aac..e29f741ffbf3 100644
--- a/drivers/platform/x86/lenovo/ideapad-laptop.h
+++ b/drivers/platform/x86/lenovo/ideapad-laptop.h
@@ -15,6 +15,15 @@ enum ideapad_laptop_notifier_actions {
IDEAPAD_LAPTOP_YMC_EVENT,
};
+enum ymc_posture {
+ /* Some devices cannot recognize their postures on boot. */
+ YMC_POSTURE_UNKNOWN = 0,
+ YMC_POSTURE_LAPTOP = 1,
+ YMC_POSTURE_TABLET = 2,
+ YMC_POSTURE_DRAWING_BOARD = 3,
+ YMC_POSTURE_TENT = 4,
+};
+
int ideapad_laptop_register_notifier(struct notifier_block *nb);
int ideapad_laptop_unregister_notifier(struct notifier_block *nb);
void ideapad_laptop_call_notifier(unsigned long action, void *data);
diff --git a/drivers/platform/x86/lenovo/ymc.c b/drivers/platform/x86/lenovo/ymc.c
index 91de02d989a0..70f3ae20d3e3 100644
--- a/drivers/platform/x86/lenovo/ymc.c
+++ b/drivers/platform/x86/lenovo/ymc.c
@@ -64,15 +64,11 @@ struct lenovo_ymc_private {
static const struct key_entry lenovo_ymc_keymap[] = {
/* Ignore the uninitialized state */
- { KE_IGNORE, 0x00 },
- /* Laptop */
- { KE_SW, 0x01, { .sw = { SW_TABLET_MODE, 0 } } },
- /* Tablet */
- { KE_SW, 0x02, { .sw = { SW_TABLET_MODE, 1 } } },
- /* Drawing Board */
- { KE_SW, 0x03, { .sw = { SW_TABLET_MODE, 1 } } },
- /* Tent */
- { KE_SW, 0x04, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_IGNORE, YMC_POSTURE_UNKNOWN },
+ { KE_SW, YMC_POSTURE_LAPTOP, { .sw = { SW_TABLET_MODE, 0 } } },
+ { KE_SW, YMC_POSTURE_TABLET, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_SW, YMC_POSTURE_DRAWING_BOARD, { .sw = { SW_TABLET_MODE, 1 } } },
+ { KE_SW, YMC_POSTURE_TENT, { .sw = { SW_TABLET_MODE, 1 } } },
{ KE_END },
};
--
2.55.0