for (i = 0; i < nb_sensors; i++) { enum cgbc_sensor_types type; unsignedint channel;
/* * No need to request data for the first sensor. * We got data for the first sensor when we ask the number of sensors to the Board * Controller.
*/ if (i) {
ret = cgbc_hwmon_cmd(cgbc, i, &data[0]); if (ret) return ret;
}
type = FIELD_GET(CGBC_HWMON_TYPE_MASK, data[1]);
channel = FIELD_GET(CGBC_HWMON_ID_MASK, data[1]) - 1;
if (type == CGBC_HWMON_TYPE_TEMP && channel < ARRAY_SIZE(cgbc_hwmon_labels_temp)) {
sensor->type = hwmon_temp;
sensor->label = cgbc_hwmon_labels_temp[channel];
} elseif (type == CGBC_HWMON_TYPE_IN &&
channel < ARRAY_SIZE(cgbc_hwmon_labels_in)) { /* * The Board Controller doesn't differentiate current and voltage sensors. * Get the sensor type from cgbc_hwmon_labels_in[channel].type instead.
*/
sensor->type = cgbc_hwmon_labels_in[channel].type;
sensor->label = cgbc_hwmon_labels_in[channel].label;
} elseif (type == CGBC_HWMON_TYPE_FAN &&
channel < ARRAY_SIZE(cgbc_hwmon_labels_fan)) {
sensor->type = hwmon_fan;
sensor->label = cgbc_hwmon_labels_fan[channel];
} else {
dev_warn(dev, "Board Controller returned an unknown sensor (type=%d, channel=%d), ignore it",
type, channel); continue;
}
staticstruct cgbc_hwmon_sensor *cgbc_hwmon_find_sensor(struct cgbc_hwmon_data *hwmon, enum hwmon_sensor_types type, int channel)
{ struct cgbc_hwmon_sensor *sensor = NULL; int i;
/* * The Board Controller doesn't differentiate current and voltage sensors. * The channel value (from the Board Controller point of view) shall be computed for current * sensors.
*/ if (type == hwmon_curr)
channel += CGBC_HWMON_NB_IN_SENSORS;
for (i = 0; i < hwmon->nb_sensors; i++) { if (hwmon->sensors[i].type == type && hwmon->sensors[i].channel == channel) {
sensor = &hwmon->sensors[i]; break;
}
}
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.