Skip to content

Commit ad53060

Browse files
Wer-Wolfgregkh
authored andcommitted
hwmon: (dell-smm) Speed up setting of fan speed
commit c0d7998 upstream. When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(), causing an unnecessary SMM call since from the two users of this function, only i8k_ioctl_unlocked() needs to know the new fan status while dell_smm_write() ignores the new fan status. Since SMM calls can be very slow while also making error reporting difficult for dell_smm_write(), remove the function call from i8k_set_fan() and call it separately in i8k_ioctl_unlocked(). Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Reviewed-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20211021190531.17379-6-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3c75d10 commit ad53060

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎drivers/hwmon/dell-smm-hwmon.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static int i8k_enable_fan_auto_mode(bool enable)
317317
}
318318

319319
/*
320-
* Set the fan speed (off, low, high). Returns the new fan status.
320+
* Set the fan speed (off, low, high, ...).
321321
*/
322322
static int i8k_set_fan(int fan, int speed)
323323
{
@@ -329,7 +329,7 @@ static int i8k_set_fan(int fan, int speed)
329329
speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed);
330330
regs.ebx = (fan & 0xff) | (speed << 8);
331331

332-
return i8k_smm(&regs) ? : i8k_get_fan_status(fan);
332+
return i8k_smm(&regs);
333333
}
334334

335335
static int i8k_get_temp_type(int sensor)
@@ -443,7 +443,7 @@ static int
443443
i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
444444
{
445445
int val = 0;
446-
int speed;
446+
int speed, err;
447447
unsigned char buff[16];
448448
int __user *argp = (int __user *)arg;
449449

@@ -504,7 +504,11 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
504504
if (copy_from_user(&speed, argp + 1, sizeof(int)))
505505
return -EFAULT;
506506

507-
val = i8k_set_fan(val, speed);
507+
err = i8k_set_fan(val, speed);
508+
if (err < 0)
509+
return err;
510+
511+
val = i8k_get_fan_status(val);
508512
break;
509513

510514
default:

0 commit comments

Comments
 (0)