[PATCH v3 2/4] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
From: Chris Taraszka
Date: Sun Nov 01 2026 - 11:18:58 EST
bitland_mifs_wmi_suspend() returns the laptop_profile_get() error to
the PM core, which aborts the whole system suspend. This happens on any
machine whose firmware reports a SystemPerMode value that is missing
from its profile table, and on such a laptop with the lid closed logind
keeps retrying the suspend, so the machine stays awake and drains its
battery.
bitland_mifs_wmi_resume() likewise returns any error other than
-EOPNOTSUPP from restoring the profile, so the resume is reported as
failed although the machine is fully usable.
Saving and restoring the platform profile is best effort. Warn and
continue instead of failing the system transition, and skip the restore
when nothing was saved, so resume does not write a stale or default
profile.
Fixes: dc1ec4fa86b2 ("platform/x86: bitland-mifs-wmi: Add new Bitland MIFS WMI driver")
Reviewed-by: Mingyou Chen <qby140326@xxxxxxxxx>
Signed-off-by: Chris Taraszka <chris@xxxxxxxxx>
---
Notes:
Unchanged since v2.
drivers/platform/x86/bitland-mifs-wmi.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
index 63fae12ebd83..0891dcc1e9b4 100644
--- a/drivers/platform/x86/bitland-mifs-wmi.c
+++ b/drivers/platform/x86/bitland-mifs-wmi.c
@@ -234,6 +234,7 @@ struct bitland_mifs_wmi_data {
struct device *pp_dev;
const struct bitland_mifs_quirks *quirks;
enum platform_profile_option saved_profile;
+ bool profile_saved;
};
static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
@@ -404,10 +405,15 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
return 0;
ret = laptop_profile_get(data->pp_dev, &profile);
- if (ret == 0)
- data->saved_profile = profile;
+ data->profile_saved = !ret;
+ if (ret) {
+ dev_warn(dev, "Failed to save platform profile: %d\n", ret);
+ return 0;
+ }
- return ret;
+ data->saved_profile = profile;
+
+ return 0;
}
static int bitland_mifs_wmi_resume(struct device *dev)
@@ -415,8 +421,8 @@ 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)
+ /* Skip event device, or nothing was saved on suspend */
+ if (!data->pp_dev || !data->profile_saved)
return 0;
ret = laptop_profile_set(dev, data->saved_profile);
@@ -432,8 +438,10 @@ static int bitland_mifs_wmi_resume(struct device *dev)
}
}
- dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
- return ret;
+ if (ret)
+ dev_warn(dev, "Failed to restore platform profile: %d\n", ret);
+
+ return 0;
}
static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,
--
2.56.0