Commit 4d09d155 authored by Leonard Anderweit's avatar Leonard Anderweit Committed by Guenter Roeck
Browse files

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: default avatarLeonard Anderweit <leonard.anderweit@gmail.com>
Link: https://lore.kernel.org/r/20230214220221.15003-3-leonard.anderweit@gmail.com


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent d0450fc1
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -574,9 +574,9 @@ static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val, int ty
	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,16 +584,18 @@ 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) {
	for (i = 0; i < len; i++) {
		switch (types[i]) {
		case AQC_BE16:
		put_unaligned_be16((s16)val, priv->buffer + offset);
			put_unaligned_be16((s16)vals[i], priv->buffer + offsets[i]);
			break;
		case AQC_8:
		priv->buffer[offset] = (u8)val;
			priv->buffer[offsets[i]] = (u8)vals[i];
			break;
		default:
			ret = -EINVAL;
		}
	}

	if (ret < 0)
		goto unlock_and_return;
@@ -605,6 +607,11 @@ static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int typ
	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;