···3535 * state for this trip point3636 * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling3737 * state for this trip point3838+ * c. if the trend is THERMAL_TREND_RAISE_FULL, use upper limit3939+ * for this trip point4040+ * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit4141+ * for this trip point4242+ * If the temperature is lower than a trip point,4343+ * a. if the trend is THERMAL_TREND_RAISING, do nothing4444+ * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling4545+ * state for this trip point, if the cooling state already4646+ * equals lower limit, deactivate the thermal instance4747+ * c. if the trend is THERMAL_TREND_RAISE_FULL, do nothing4848+ * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit,4949+ * if the cooling state already equals lower limit,5050+ * deactive the thermal instance3851 */3952static unsigned long get_target_state(struct thermal_instance *instance,4040- enum thermal_trend trend)5353+ enum thermal_trend trend, bool throttle)4154{4255 struct thermal_cooling_device *cdev = instance->cdev;4356 unsigned long cur_state;44574558 cdev->ops->get_cur_state(cdev, &cur_state);46594747- if (trend == THERMAL_TREND_RAISING) {4848- cur_state = cur_state < instance->upper ?4949- (cur_state + 1) : instance->upper;5050- } else if (trend == THERMAL_TREND_DROPPING) {5151- cur_state = cur_state > instance->lower ?5252- (cur_state - 1) : instance->lower;6060+ switch (trend) {6161+ case THERMAL_TREND_RAISING:6262+ if (throttle)6363+ cur_state = cur_state < instance->upper ?6464+ (cur_state + 1) : instance->upper;6565+ break;6666+ case THERMAL_TREND_RAISE_FULL:6767+ if (throttle)6868+ cur_state = instance->upper;6969+ break;7070+ case THERMAL_TREND_DROPPING:7171+ if (cur_state == instance->lower) {7272+ if (!throttle)7373+ cur_state = -1;7474+ } else7575+ cur_state -= 1;7676+ break;7777+ case THERMAL_TREND_DROP_FULL:7878+ if (cur_state == instance->lower) {7979+ if (!throttle)8080+ cur_state = -1;8181+ } else8282+ cur_state = instance->lower;8383+ break;8484+ default:8585+ break;5386 }54875588 return cur_state;···10976 if (instance->trip != trip)11077 continue;11178112112- instance->target = get_target_state(instance, trend);7979+ instance->target = get_target_state(instance, trend, true);1138011481 /* Activate a passive thermal instance */11582 if (instance->target == THERMAL_NO_TARGET)···12087}1218812289static void update_instance_for_dethrottle(struct thermal_zone_device *tz,123123- int trip, enum thermal_trip_type trip_type)9090+ int trip, enum thermal_trip_type trip_type,9191+ enum thermal_trend trend)12492{12593 struct thermal_instance *instance;126126- struct thermal_cooling_device *cdev;127127- unsigned long cur_state;1289412995 list_for_each_entry(instance, &tz->thermal_instances, tz_node) {13096 if (instance->trip != trip ||13197 instance->target == THERMAL_NO_TARGET)13298 continue;13399134134- cdev = instance->cdev;135135- cdev->ops->get_cur_state(cdev, &cur_state);136136-137137- instance->target = cur_state > instance->lower ?138138- (cur_state - 1) : THERMAL_NO_TARGET;100100+ instance->target = get_target_state(instance, trend, false);139101140102 /* Deactivate a passive thermal instance */141103 if (instance->target == THERMAL_NO_TARGET)142104 update_passive_instance(tz, trip_type, -1);143105144144- cdev->updated = false; /* cdev needs update */106106+ instance->cdev->updated = false; /* cdev needs update */145107 }146108}147109···161133 if (tz->temperature >= trip_temp)162134 update_instance_for_throttle(tz, trip, trip_type, trend);163135 else164164- update_instance_for_dethrottle(tz, trip, trip_type);136136+ update_instance_for_dethrottle(tz, trip, trip_type, trend);165137166138 mutex_unlock(&tz->lock);167139}