From: W_Armin@gmx.de
To: pali@kernel.org
Cc: linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org
Subject: [PATCH 5/5] hwmon: (dell-smm) Speed up setting of fan speed
Date: Thu, 21 Oct 2021 19:54:47 +0200 [thread overview]
Message-ID: <20211021175447.5380-6-W_Armin@gmx.de> (raw)
In-Reply-To: <20211021175447.5380-1-W_Armin@gmx.de>
From: Armin Wolf <W_Armin@gmx.de>
When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(),
causing an unnecessary smm call which can be very slow while also
making error handling difficult.
Fix that by removing the function call from i8k_set_fan() and
call it separately when needed.
Tested on a Dell Inspiron 3505.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/hwmon/dell-smm-hwmon.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 2579dd646b20..62f087f67925 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -327,7 +327,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enabl
}
/*
- * Set the fan speed (off, low, high). Returns the new fan status.
+ * Set the fan speed (off, low, high, ...).
*/
static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed)
{
@@ -339,7 +339,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, int fan, int speed)
speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed);
regs.ebx = (fan & 0xff) | (speed << 8);
- return i8k_smm(®s) ? : i8k_get_fan_status(data, fan);
+ return i8k_smm(®s);
}
static int __init i8k_get_temp_type(int sensor)
@@ -453,7 +453,7 @@ static int
i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd, unsigned long arg)
{
int val = 0;
- int speed;
+ int speed, err;
unsigned char buff[16];
int __user *argp = (int __user *)arg;
@@ -513,7 +513,11 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd
if (copy_from_user(&speed, argp + 1, sizeof(int)))
return -EFAULT;
- val = i8k_set_fan(data, val, speed);
+ err = i8k_set_fan(data, val, speed);
+ if (err < 0)
+ return err;
+
+ val = i8k_get_fan_status(data, val);
break;
default:
--
2.20.1
next prev parent reply other threads:[~2021-10-21 17:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 17:54 [PATCH 0/5] hwmon: (dell-smm) Miscellaneous Improvments W_Armin
2021-10-21 17:54 ` [PATCH 1/5] hwmon: (dell-smm) Sort includes in alphabetical order W_Armin
2021-10-21 18:16 ` Pali Rohár
2021-10-21 17:54 ` [PATCH 2/5] hwmon: (dell-smm) Use strscpy_pad() W_Armin
2021-10-21 18:17 ` Pali Rohár
2021-10-21 17:54 ` [PATCH 3/5] hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL W_Armin
2021-10-21 18:17 ` Pali Rohár
2021-10-21 17:54 ` [PATCH 4/5] hwmon: (dell-smm) Add Dell Inspiron 3505 config data W_Armin
2021-10-21 18:05 ` Pali Rohár
2021-10-21 18:36 ` Armin Wolf
2021-10-21 18:42 ` Pali Rohár
2021-10-21 17:54 ` W_Armin [this message]
2021-10-21 18:14 ` [PATCH 5/5] hwmon: (dell-smm) Speed up setting of fan speed Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211021175447.5380-6-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=pali@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox