Skip to content

Commit c0d7998

Browse files
Wer-Wolfgroeck
authored andcommitted
hwmon: (dell-smm) Speed up setting of fan speed
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 <[email protected]> Reviewed-by: Pali Rohár <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 927d89e commit c0d7998

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/hwmon/dell-smm-hwmon.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enabl
327327
}
328328

329329
/*
330-
* Set the fan speed (off, low, high). Returns the new fan status.
330+
* Set the fan speed (off, low, high, ...).
331331
*/
332332
static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed)
333333
{
@@ -339,7 +339,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed)
339339
speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed);
340340
regs.ebx = (fan & 0xff) | (speed << 8);
341341

342-
return i8k_smm(&regs) ? : i8k_get_fan_status(data, fan);
342+
return i8k_smm(&regs);
343343
}
344344

345345
static int __init i8k_get_temp_type(int sensor)
@@ -453,7 +453,7 @@ static int
453453
i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd, unsigned long arg)
454454
{
455455
int val = 0;
456-
int speed;
456+
int speed, err;
457457
unsigned char buff[16];
458458
int __user *argp = (int __user *)arg;
459459

@@ -513,7 +513,11 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd
513513
if (copy_from_user(&speed, argp + 1, sizeof(int)))
514514
return -EFAULT;
515515

516-
val = i8k_set_fan(data, val, speed);
516+
err = i8k_set_fan(data, val, speed);
517+
if (err < 0)
518+
return err;
519+
520+
val = i8k_get_fan_status(data, val);
517521
break;
518522

519523
default:

0 commit comments

Comments
 (0)