[PATCH v12 6/6] platform/x86: bitland-mifs-wmi: Fallback to balanced platform profile if last performance profile is not available
From: Mingyou Chen
Date: Mon Oct 12 2026 - 09:47:26 EST
On Bitland laptops, performance profiles require an external power
supply. If the system enters suspend in a performance profile and the AC
adapter is unplugged while the machine is asleep, laptop_profile_set()
fails with -EOPNOTSUPP during resume when attempting to re-apply
saved_profile.
Returning an error from the resume callback simply because the power
cable was removed during sleep is undesirable, as the device is
otherwise
fully functional.
Gracefully handle this condition by falling back to
PLATFORM_PROFILE_BALANCED
whenever restoring the saved profile returns -EOPNOTSUPP. Update
saved_profile accordingly and notify user space via
platform_profile_notify() so daemons such as power-profiles-daemon stay
in sync with the actual hardware state.
Signed-off-by: Mingyou Chen <qby140326@xxxxxxxxx>
---
drivers/platform/x86/bitland-mifs-wmi.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
index fac1cdbbd778..44b16b7b4034 100644
--- a/drivers/platform/x86/bitland-mifs-wmi.c
+++ b/drivers/platform/x86/bitland-mifs-wmi.c
@@ -392,13 +392,27 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
static int bitland_mifs_wmi_resume(struct device *dev)
{
struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
+ int ret;
/* Skip event device */
if (!data->pp_dev)
return 0;
+ ret = laptop_profile_set(dev, data->saved_profile);
+
+ if (ret == -EOPNOTSUPP && data->saved_profile != PLATFORM_PROFILE_BALANCED) {
+ dev_dbg(dev, "Cannot restore profile %d (likely on battery), falling back to balanced\n",
+ data->saved_profile);
+
+ ret = laptop_profile_set(dev, PLATFORM_PROFILE_BALANCED);
+ if (!ret) {
+ data->saved_profile = PLATFORM_PROFILE_BALANCED;
+ platform_profile_notify(data->pp_dev);
+ }
+ }
+
dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
- return laptop_profile_set(dev, data->saved_profile);
+ return ret;
}
static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,
--
2.55.0