/** * __thermal_zone_get_temp() - returns the temperature of a thermal zone * @tz: a valid pointer to a struct thermal_zone_device * @temp: a valid pointer to where to store the resulting temperature. * * When a valid thermal zone reference is passed, it will fetch its * temperature and fill @temp. * * Both tz and tz->ops must be valid pointers when calling this function, * and the tz->ops.get_temp callback must be provided. * The function must be called under tz->lock. * * Return: On success returns 0, an error code otherwise
*/ int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
{ conststruct thermal_trip_desc *td; int crit_temp = INT_MAX; int ret = -EINVAL;
/* * Only allow emulating a temperature when the real temperature * is below the critical temperature so that the emulation code * cannot hide critical conditions.
*/ if (!ret && *temp < crit_temp)
*temp = tz->emul_temperature;
}
if (ret)
dev_dbg(&tz->device, "Failed to get temperature: %d\n", ret);
return ret;
}
/** * thermal_zone_get_temp() - returns the temperature of a thermal zone * @tz: a valid pointer to a struct thermal_zone_device * @temp: a valid pointer to where to store the resulting temperature. * * When a valid thermal zone reference is passed, it will fetch its * temperature and fill @temp. * * Return: On success returns 0, an error code otherwise
*/ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
{ int ret;
if (IS_ERR_OR_NULL(tz)) return -EINVAL;
guard(thermal_zone)(tz);
if (!tz->ops.get_temp) return -EINVAL;
ret = __thermal_zone_get_temp(tz, temp); if (!ret && *temp <= THERMAL_TEMP_INVALID) return -ENODATA;
staticint thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, int state)
{ int ret;
/* * No check is needed for the ops->set_cur_state as the * registering function checked the ops are correctly set
*/
ret = cdev->ops->set_cur_state(cdev, state); if (ret) return ret;
/* Make sure cdev enters the deepest cooling state */
list_for_each_entry(instance, &cdev->thermal_instances, cdev_node) { if (instance->target == THERMAL_NO_TARGET) continue; if (instance->target > target)
target = instance->target;
}
thermal_cdev_set_cur_state(cdev, target);
trace_cdev_update(cdev, target);
dev_dbg(&cdev->device, "set to state %lu\n", target);
}
/** * thermal_cdev_update - update cooling device state if needed * @cdev: pointer to struct thermal_cooling_device * * Update the cooling device state if there is a need.
*/ void thermal_cdev_update(struct thermal_cooling_device *cdev)
{
guard(cooling_dev)(cdev);
if (!cdev->updated) {
__thermal_cdev_update(cdev);
cdev->updated = true;
}
}
/** * thermal_zone_get_slope - return the slope attribute of the thermal zone * @tz: thermal zone device with the slope attribute * * Return: If the thermal zone device has a slope attribute, return it, else * return 1.
*/ int thermal_zone_get_slope(struct thermal_zone_device *tz)
{ if (tz && tz->tzp) return tz->tzp->slope; return 1;
}
EXPORT_SYMBOL_GPL(thermal_zone_get_slope);
/** * thermal_zone_get_offset - return the offset attribute of the thermal zone * @tz: thermal zone device with the offset attribute * * Return: If the thermal zone device has a offset attribute, return it, else * return 0.
*/ int thermal_zone_get_offset(struct thermal_zone_device *tz)
{ if (tz && tz->tzp) return tz->tzp->offset; return 0;
}
EXPORT_SYMBOL_GPL(thermal_zone_get_offset);
Messung V0.5
¤ Dauer der Verarbeitung: 0.22 Sekunden
(vorverarbeitet)
¤
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.