summaryrefslogtreecommitdiff
path: root/drivers/hwmon/aquacomputer_d5next.c
diff options
context:
space:
mode:
authorLeonard Anderweit <leonard.anderweit@gmail.com>2023-02-15 01:02:17 +0300
committerGuenter Roeck <linux@roeck-us.net>2023-04-19 17:08:32 +0300
commit4d09d155a5d1aa984cba70e52609a3587149a911 (patch)
treef08f9f26d8bcfceef81af1970bf777fab51d443a /drivers/hwmon/aquacomputer_d5next.c
parentd0450fc1e3960ef2cd9aeea1b525bb513ee387bb (diff)
downloadlinux-4d09d155a5d1aa984cba70e52609a3587149a911.tar.xz
hwmon: (aquacomputer_d5next) Support writing multiple control values at once
Add new function aqc_set_ctrl_vals() to support changing multiple control values at once while sending only one control report. Signed-off-by: Leonard Anderweit <leonard.anderweit@gmail.com> Link: https://lore.kernel.org/r/20230214220221.15003-3-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/aquacomputer_d5next.c')
-rw-r--r--drivers/hwmon/aquacomputer_d5next.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/hwmon/aquacomputer_d5next.c b/drivers/hwmon/aquacomputer_d5next.c
index babfd998e70c..f0c036d38e91 100644
--- a/drivers/hwmon/aquacomputer_d5next.c
+++ b/drivers/hwmon/aquacomputer_d5next.c
@@ -574,9 +574,9 @@ unlock_and_return:
return ret;
}
-static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type)
+static int aqc_set_ctrl_vals(struct aqc_data *priv, int *offsets, long *vals, int *types, int len)
{
- int ret;
+ int ret, i;
mutex_lock(&priv->mutex);
@@ -584,15 +584,17 @@ static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int typ
if (ret < 0)
goto unlock_and_return;
- switch (type) {
- case AQC_BE16:
- put_unaligned_be16((s16)val, priv->buffer + offset);
- break;
- case AQC_8:
- priv->buffer[offset] = (u8)val;
- break;
- default:
- ret = -EINVAL;
+ for (i = 0; i < len; i++) {
+ switch (types[i]) {
+ case AQC_BE16:
+ put_unaligned_be16((s16)vals[i], priv->buffer + offsets[i]);
+ break;
+ case AQC_8:
+ priv->buffer[offsets[i]] = (u8)vals[i];
+ break;
+ default:
+ ret = -EINVAL;
+ }
}
if (ret < 0)
@@ -605,6 +607,11 @@ unlock_and_return:
return ret;
}
+static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type)
+{
+ return aqc_set_ctrl_vals(priv, &offset, &val, &type, 1);
+}
+
static umode_t aqc_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, int channel)
{
const struct aqc_data *priv = data;