Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hwmon: (dell-smm) Move clamping of fan speed out of i8k_set_fan()

Currently i8k_set_fan() clamps the fan speed before performing the
SMM call to ensure that the speed is not negative and not greater than
i8k_fan_max. This however is mostly unnecessary as the hwmon and
thermal interfaces alread ensure this. Only the legacy ioctl interface
does not ensure that the fan speed passed to i8k_set_fan() does meet
the above criteria.

Move the clamping out of i8k_set_fan() and into the legacy ioctl
handler to prepare for future changes.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20250917181036.10972-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Armin Wolf and committed by
Guenter Roeck
b3499883 ddb61e73

+3 -1
+3 -1
drivers/hwmon/dell-smm-hwmon.c
··· 24 24 #include <linux/init.h> 25 25 #include <linux/kconfig.h> 26 26 #include <linux/kernel.h> 27 + #include <linux/minmax.h> 27 28 #include <linux/module.h> 28 29 #include <linux/mutex.h> 29 30 #include <linux/platform_device.h> ··· 447 446 if (disallow_fan_support) 448 447 return -EINVAL; 449 448 450 - speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed); 451 449 regs.ebx = fan | (speed << 8); 452 450 453 451 return dell_smm_call(data->ops, &regs); ··· 636 636 637 637 if (copy_from_user(&speed, argp + 1, sizeof(int))) 638 638 return -EFAULT; 639 + 640 + speed = clamp_val(speed, 0, data->i8k_fan_max); 639 641 640 642 mutex_lock(&data->i8k_mutex); 641 643 err = i8k_set_fan(data, val, speed);