[PATCH v4 1/4] platform/x86: bitland-mifs-wmi: Allow per-model hwmon configuration
From: Bozhen Peng
Date: Tue Dec 01 2026 - 23:01:20 EST
The WUJIE15 PRO HPT has two fans and no CPU temperature reading.
Move the hwmon chip info and fan labels into a per-model configuration
so its sensor layout can be added separately. Keep the current layout
as the default.
No functional change intended.
Signed-off-by: Bozhen Peng <bozhenpeng93@xxxxxxxxx>
---
drivers/platform/x86/bitland-mifs-wmi.c | 43 +++++++++++++++++++------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
index 7bad8942249d43bd378d7adf8da26261fd684df7..04125c602f3bde13426fa463415cdafe0b0d07fe 100644
--- a/drivers/platform/x86/bitland-mifs-wmi.c
+++ b/drivers/platform/x86/bitland-mifs-wmi.c
@@ -94,9 +94,18 @@ struct bitland_profile_entry {
bool battery; /* Set in place of the AC entry while on battery */
};
+struct bitland_hwmon_config {
+ const struct hwmon_chip_info *chip_info;
+ const char * const *fan_labels;
+ size_t num_fans;
+};
+
+static const struct bitland_hwmon_config default_hwmon_config;
+
struct bitland_mifs_quirks {
const struct bitland_profile_entry *profile_entries;
size_t num_profile_entries;
+ const struct bitland_hwmon_config *hwmon;
bool return_code_at_end;
bool skip_ac_type_check;
@@ -552,12 +561,18 @@ static const struct platform_profile_ops laptop_profile_ops = {
.profile_set = laptop_profile_set,
};
-static const char *const fan_labels[] = {
+static const char * const default_fan_labels[] = {
"CPU", /* 0 */
"GPU", /* 1 */
"SYS", /* 2 */
};
+static const struct bitland_hwmon_config *
+bitland_hwmon_config(const struct bitland_mifs_wmi_data *data)
+{
+ return data->quirks->hwmon ?: &default_hwmon_config;
+}
+
static int laptop_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
@@ -603,13 +618,15 @@ static int laptop_hwmon_read_string(struct device *dev,
enum hwmon_sensor_types type, u32 attr,
int channel, const char **str)
{
- if (type == hwmon_fan && attr == hwmon_fan_label) {
- if (channel >= 0 && channel < ARRAY_SIZE(fan_labels)) {
- *str = fan_labels[channel];
- return 0;
- }
- }
- return -EINVAL;
+ struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
+ const struct bitland_hwmon_config *config = bitland_hwmon_config(data);
+
+ if (type != hwmon_fan || attr != hwmon_fan_label ||
+ channel < 0 || channel >= config->num_fans)
+ return -EINVAL;
+
+ *str = config->fan_labels[channel];
+ return 0;
}
static const struct hwmon_channel_info *laptop_hwmon_info[] = {
@@ -631,6 +648,12 @@ static const struct hwmon_chip_info laptop_chip_info = {
.info = laptop_hwmon_info,
};
+static const struct bitland_hwmon_config default_hwmon_config = {
+ .chip_info = &laptop_chip_info,
+ .fan_labels = default_fan_labels,
+ .num_fans = ARRAY_SIZE(default_fan_labels),
+};
+
static int laptop_kbd_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
@@ -900,6 +923,7 @@ static int bitland_notifier_callback(struct notifier_block *nb,
static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)
{
+ const struct bitland_hwmon_config *hwmon;
struct bitland_mifs_wmi_data *drv_data;
enum bitland_wmi_device_type dev_type =
(enum bitland_wmi_device_type)(unsigned long)context;
@@ -971,10 +995,11 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context)
}
/* Register hwmon */
+ hwmon = bitland_hwmon_config(drv_data);
drv_data->hwmon_dev = devm_hwmon_device_register_with_info(&wdev->dev,
"bitland_mifs",
drv_data,
- &laptop_chip_info,
+ hwmon->chip_info,
NULL);
if (IS_ERR(drv_data->hwmon_dev))
return PTR_ERR(drv_data->hwmon_dev);