diff options
author | Kurt Borja <kuurtb@gmail.com> | 2025-04-25 12:45:07 -0300 |
---|---|---|
committer | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2025-04-30 14:05:58 +0300 |
commit | 4b4da10b1f7eda3c698b924ce2051d3e56e652fe (patch) | |
tree | 9c98e97260011ed9a617941ed0b6fa26c4fb7bb5 | |
parent | 1fe9596a70d40b017f698db42621ec96da3a0cac (diff) |
platform/x86: alienware-wmi-wmax: Fix awcc_hwmon_fans_init() label logic
To avoid passing an uninitialized `temp_id` to awcc_get_fan_label(),
pass the `fan_temps` bitmap instead, to work only on set bits.
Additionally, awcc_get_fan_label() leaves `dev` unused, so remove it
from it's signature and it does not fail, so remove error handling.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202504250521.HEkFK1Jy-lkp@intel.com/
Fixes: d69990783495 ("platform/x86: alienware-wmi-wmax: Add HWMON support")
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250425-temp-id-fix-v1-2-372d71f732bf@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
-rw-r--r-- | drivers/platform/x86/dell/alienware-wmi-wmax.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c index 27e5b0b23c27..f3ad47c9edfa 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -958,15 +958,19 @@ static int awcc_hwmon_temps_init(struct wmi_device *wdev) return 0; } -static char *awcc_get_fan_label(struct device *dev, u32 temp_count, u8 temp_id) +static char *awcc_get_fan_label(unsigned long *fan_temps) { + unsigned int temp_count = bitmap_weight(fan_temps, AWCC_ID_BITMAP_SIZE); char *label; + u8 temp_id; switch (temp_count) { case 0: label = "Independent Fan"; break; case 1: + temp_id = find_first_bit(fan_temps, AWCC_ID_BITMAP_SIZE); + switch (temp_id) { case AWCC_TEMP_SENSOR_CPU: label = "Processor Fan"; @@ -996,7 +1000,6 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev) u32 min_rpm, max_rpm, temp_count, temp_id; struct awcc_fan_data *fan_data; unsigned int i, j; - char *label; int ret; u8 id; @@ -1039,14 +1042,10 @@ static int awcc_hwmon_fans_init(struct wmi_device *wdev) __set_bit(temp_id, fan_temps); } - label = awcc_get_fan_label(&wdev->dev, temp_count, temp_id); - if (!label) - return -ENOMEM; - fan_data->id = id; fan_data->min_rpm = min_rpm; fan_data->max_rpm = max_rpm; - fan_data->label = label; + fan_data->label = awcc_get_fan_label(fan_temps); bitmap_gather(gather, fan_temps, priv->temp_sensors, AWCC_ID_BITMAP_SIZE); bitmap_copy(&fan_data->auto_channels_temp, gather, BITS_PER_LONG); priv->fan_data[i] = fan_data; |