status = wmi_evaluate_method(ASUSWMI_MONITORING_GUID, 0,
method_id, &input, output); if (ACPI_FAILURE(status)) return -EIO;
return 0;
}
/* * Gets the version of the ASUS sensors interface implemented
*/ staticint asus_wmi_get_version(u32 *version)
{ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
u32 args[] = {0, 0, 0}; union acpi_object *obj; int err;
err = asus_wmi_call_method(ASUSWMI_METHODID_GET_VERSION, args, &output); if (err) return err;
staticint asus_wmi_update_values_for_source(u8 source, struct asus_wmi_sensors *sensor_data)
{ struct asus_wmi_sensor_info *sensor; long value = 0; int ret; int i;
for (i = 0; i < sensor_data->wmi.sensor_count; i++) {
sensor = sensor_data->wmi.info_by_id[i]; if (sensor && sensor->source == source) {
ret = asus_wmi_get_sensor_value(sensor->id, &value); if (ret) return ret;
sensor->cached_value = value;
}
}
return 0;
}
staticint asus_wmi_scale_sensor_value(u32 value, int data_type)
{ /* FAN_RPM and WATER_FLOW don't need scaling */ switch (data_type) { case VOLTAGE: /* value in microVolts */ return DIV_ROUND_CLOSEST(value, KILO); case TEMPERATURE_C: /* value in Celsius */ return value * MILLIDEGREE_PER_DEGREE; case CURRENT: /* value in Amperes */ return value * MILLI;
} return value;
}
staticint asus_wmi_get_cached_value_or_update(conststruct asus_wmi_sensor_info *sensor, struct asus_wmi_sensors *sensor_data,
u32 *value)
{ int ret = 0;
mutex_lock(&sensor_data->lock);
if (time_after(jiffies, sensor_data->wmi.source_last_updated[sensor->source] + HZ)) {
ret = asus_wmi_update_buffer(sensor->source); if (ret) goto unlock;
ret = asus_wmi_update_values_for_source(sensor->source, sensor_data); if (ret) goto unlock;
/* Now follow the functions that implement the hwmon interface */ staticint asus_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ conststruct asus_wmi_sensor_info *sensor;
u32 value = 0; int ret;
staticint asus_wmi_configure_sensor_setup(struct device *dev, struct asus_wmi_sensors *sensor_data)
{ conststruct hwmon_channel_info **ptr_asus_wmi_ci; struct hwmon_channel_info *asus_wmi_hwmon_chan; int nr_count[hwmon_max] = {}, nr_types = 0; struct asus_wmi_sensor_info *temp_sensor; conststruct hwmon_chip_info *chip_info; enum hwmon_sensor_types type; struct device *hwdev; int i, idx; int err;
for (i = 0; i < sensor_data->wmi.sensor_count; i++) { struct asus_wmi_sensor_info sensor;
err = asus_wmi_sensor_info(i, &sensor); if (err) return err;
switch (sensor.data_type) { case TEMPERATURE_C: case VOLTAGE: case CURRENT: case FAN_RPM: case WATER_FLOW:
type = asus_data_types[sensor.data_type]; if (!nr_count[type])
nr_types++;
nr_count[type]++; break;
}
}
if (nr_count[hwmon_temp])
nr_count[hwmon_chip]++, nr_types++;
asus_wmi_hwmon_chan = devm_kcalloc(dev, nr_types, sizeof(*asus_wmi_hwmon_chan),
GFP_KERNEL); if (!asus_wmi_hwmon_chan) return -ENOMEM;
for (i = sensor_data->wmi.sensor_count - 1; i >= 0; i--) {
temp_sensor = devm_kzalloc(dev, sizeof(*temp_sensor), GFP_KERNEL); if (!temp_sensor) return -ENOMEM;
err = asus_wmi_sensor_info(i, temp_sensor); if (err) continue;
switch (temp_sensor->data_type) { case TEMPERATURE_C: case VOLTAGE: case CURRENT: case FAN_RPM: case WATER_FLOW:
type = asus_data_types[temp_sensor->data_type];
idx = --nr_count[type];
*(sensor_data->wmi.info[type] + idx) = temp_sensor;
sensor_data->wmi.info_by_id[i] = temp_sensor; break;
}
}
dev_dbg(dev, "board has %d sensors",
sensor_data->wmi.sensor_count);
if (!dmi_check_system(asus_wmi_dmi_table)) return -ENODEV;
sensor_data = devm_kzalloc(dev, sizeof(*sensor_data), GFP_KERNEL); if (!sensor_data) return -ENOMEM;
if (asus_wmi_get_version(&version)) return -ENODEV;
if (asus_wmi_get_item_count(&sensor_data->wmi.sensor_count)) return -ENODEV;
if (sensor_data->wmi.sensor_count <= 0 || version < 2) {
dev_info(dev, "version: %u with %d sensors is unsupported\n",
version, sensor_data->wmi.sensor_count);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.