mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 13:34:30 +00:00
hwmon: (aquacomputer_d5next) Add structure for fan layout
Introduce structure for per device fan sensor offsets. This allows reading fan sensors in aqc_raw_event() from devices which use a different sensor layout in their status HID report. Currently only one version is implemented as all supported devices use the same structure. Signed-off-by: Leonard Anderweit <leonard.anderweit@gmail.com> Link: https://lore.kernel.org/r/20221218113131.3752-4-leonard.anderweit@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
a2ba7ee25c
commit
249c752110
@ -282,6 +282,21 @@ static const char *const label_highflownext_voltage[] = {
|
||||
"+5V USB voltage"
|
||||
};
|
||||
|
||||
struct aqc_fan_structure_offsets {
|
||||
u8 voltage;
|
||||
u8 curr;
|
||||
u8 power;
|
||||
u8 speed;
|
||||
};
|
||||
|
||||
/* Fan structure offsets for all devices except Aquaero */
|
||||
static struct aqc_fan_structure_offsets aqc_general_fan_structure = {
|
||||
.voltage = AQC_FAN_VOLTAGE_OFFSET,
|
||||
.curr = AQC_FAN_CURRENT_OFFSET,
|
||||
.power = AQC_FAN_POWER_OFFSET,
|
||||
.speed = AQC_FAN_SPEED_OFFSET
|
||||
};
|
||||
|
||||
struct aqc_data {
|
||||
struct hid_device *hdev;
|
||||
struct device *hwmon_dev;
|
||||
@ -308,6 +323,7 @@ struct aqc_data {
|
||||
int num_flow_sensors;
|
||||
u8 flow_sensors_start_offset;
|
||||
u8 flow_pulses_ctrl_offset;
|
||||
struct aqc_fan_structure_offsets *fan_structure;
|
||||
|
||||
/* General info, same across all devices */
|
||||
u32 serial_number[2];
|
||||
@ -822,15 +838,17 @@ static int aqc_raw_event(struct hid_device *hdev, struct hid_report *report, u8
|
||||
/* Fan speed and related readings */
|
||||
for (i = 0; i < priv->num_fans; i++) {
|
||||
priv->speed_input[i] =
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] + AQC_FAN_SPEED_OFFSET);
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] +
|
||||
priv->fan_structure->speed);
|
||||
priv->power_input[i] =
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] +
|
||||
AQC_FAN_POWER_OFFSET) * 10000;
|
||||
priv->fan_structure->power) * 10000;
|
||||
priv->voltage_input[i] =
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] +
|
||||
AQC_FAN_VOLTAGE_OFFSET) * 10;
|
||||
priv->fan_structure->voltage) * 10;
|
||||
priv->current_input[i] =
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] + AQC_FAN_CURRENT_OFFSET);
|
||||
get_unaligned_be16(data + priv->fan_sensor_offsets[i] +
|
||||
priv->fan_structure->curr);
|
||||
}
|
||||
|
||||
/* Flow sensor readings */
|
||||
@ -1078,6 +1096,8 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
break;
|
||||
}
|
||||
|
||||
priv->fan_structure = &aqc_general_fan_structure;
|
||||
|
||||
if (priv->buffer_size != 0) {
|
||||
priv->checksum_start = 0x01;
|
||||
priv->checksum_length = priv->buffer_size - 3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user