From: "Pali Rohár" <pali@kernel.org>
To: Armin Wolf <W_Armin@gmx.de>
Cc: jdelvare@suse.com, linux@roeck-us.net,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (dell-smm) Unify i8k_ioctl() and i8k_ioctl_unlocked()
Date: Tue, 23 Nov 2021 17:04:31 +0100 [thread overview]
Message-ID: <20211123160431.6tegq2jdoifecivd@pali> (raw)
In-Reply-To: <20211120170319.72369-3-W_Armin@gmx.de>
On Saturday 20 November 2021 18:03:19 Armin Wolf wrote:
> The only purpose of i8k_ioctl() is to call i8k_ioctl_unlocked()
> with i8k_mutex held. Judging from the hwmon code, this mutex
> only needs to be held when setting the fan speed/mode.
> Unify both functions and reduce the locking of i8k_mutex
> to I8K_SET_FAN.
>
> Tested on a Dell Inspiron 3505.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Maybe some more information in commit message could be useful, but now
it is in this email thread.
Anyway, change is correct, so:
Reviewed-by: Pali Rohár <pali@kernel.org>
> ---
> drivers/hwmon/dell-smm-hwmon.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index b5d1703faa62..e2d388f7360e 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -449,12 +449,12 @@ static int i8k_get_power_status(void)
> * Procfs interface
> */
>
> -static int
> -i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd, unsigned long arg)
> +static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
> {
> - int val = 0;
> - int speed, err;
> + struct dell_smm_data *data = PDE_DATA(file_inode(fp));
> int __user *argp = (int __user *)arg;
> + int speed, err;
> + int val = 0;
>
> if (!argp)
> return -EINVAL;
> @@ -516,11 +516,14 @@ 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;
>
> + mutex_lock(&data->i8k_mutex);
> err = i8k_set_fan(data, val, speed);
> - if (err < 0)
> + if (err < 0) {
> + mutex_unlock(&data->i8k_mutex);
> return err;
> -
> + }
> val = i8k_get_fan_status(data, val);
> + mutex_unlock(&data->i8k_mutex);
> break;
>
> default:
> @@ -536,18 +539,6 @@ i8k_ioctl_unlocked(struct file *fp, struct dell_smm_data *data, unsigned int cmd
> return 0;
> }
>
> -static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
> -{
> - struct dell_smm_data *data = PDE_DATA(file_inode(fp));
> - long ret;
> -
> - mutex_lock(&data->i8k_mutex);
> - ret = i8k_ioctl_unlocked(fp, data, cmd, arg);
> - mutex_unlock(&data->i8k_mutex);
> -
> - return ret;
> -}
> -
> /*
> * Print the information for /proc/i8k.
> */
> --
> 2.30.2
>
prev parent reply other threads:[~2021-11-23 16:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-20 17:03 [PATCH 0/2] hwmon: (dell-smm) Improve ioctl handler Armin Wolf
2021-11-20 17:03 ` [PATCH 1/2] hwmon: (dell-smm) Simplify " Armin Wolf
2021-11-23 16:13 ` Pali Rohár
2021-11-29 20:57 ` Armin Wolf
2021-12-09 16:52 ` Pali Rohár
2021-11-20 17:03 ` [PATCH 2/2] hwmon: (dell-smm) Unify i8k_ioctl() and i8k_ioctl_unlocked() Armin Wolf
2021-11-22 16:01 ` Pali Rohár
2021-11-22 17:55 ` Guenter Roeck
2021-11-22 18:50 ` Armin Wolf
2021-11-22 19:10 ` Pali Rohár
2021-11-22 19:28 ` Guenter Roeck
2021-11-22 19:43 ` Pali Rohár
2021-11-23 16:00 ` Guenter Roeck
2021-11-23 16:02 ` Pali Rohár
2021-11-23 16:04 ` Pali Rohár [this message]
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=20211123160431.6tegq2jdoifecivd@pali \
--to=pali@kernel.org \
--cc=W_Armin@gmx.de \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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