Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/core: Remove thermal_bind_params structure

Remove struct thermal_bind_params because no one is using it for thermal
binding now.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230330104526.3196-1-rui.zhang@intel.com

authored by

Zhang Rui and committed by
Daniel Lezcano
ded2d383 cdd6076b

+11 -196
-40
Documentation/driver-api/thermal/sysfs-api.rst
··· 306 306 307 307 :: 308 308 309 - struct thermal_bind_params 310 - 311 - This structure defines the following parameters that are used to bind 312 - a zone with a cooling device for a particular trip point. 313 - 314 - .cdev: 315 - The cooling device pointer 316 - .weight: 317 - The 'influence' of a particular cooling device on this 318 - zone. This is relative to the rest of the cooling 319 - devices. For example, if all cooling devices have a 320 - weight of 1, then they all contribute the same. You can 321 - use percentages if you want, but it's not mandatory. A 322 - weight of 0 means that this cooling device doesn't 323 - contribute to the cooling of this zone unless all cooling 324 - devices have a weight of 0. If all weights are 0, then 325 - they all contribute the same. 326 - .trip_mask: 327 - This is a bit mask that gives the binding relation between 328 - this thermal zone and cdev, for a particular trip point. 329 - If nth bit is set, then the cdev and thermal zone are bound 330 - for trip point n. 331 - .binding_limits: 332 - This is an array of cooling state limits. Must have 333 - exactly 2 * thermal_zone.number_of_trip_points. It is an 334 - array consisting of tuples <lower-state upper-state> of 335 - state limits. Each trip will be associated with one state 336 - limit tuple when binding. A NULL pointer means 337 - <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> on all trips. 338 - These limits are used when binding a cdev to a trip point. 339 - .match: 340 - This call back returns success(0) if the 'tz and cdev' need to 341 - be bound, as per platform data. 342 - 343 - :: 344 - 345 309 struct thermal_zone_params 346 310 347 311 This structure defines the platform level parameters for a thermal zone. ··· 321 357 will be created. when no_hwmon == true, nothing will be done. 322 358 In case the thermal_zone_params is NULL, the hwmon interface 323 359 will be created (for backward compatibility). 324 - .num_tbps: 325 - Number of thermal_bind_params entries for this zone 326 - .tbp: 327 - thermal_bind_params entries 328 360 329 361 2. sysfs attributes structure 330 362 =============================
+11 -118
drivers/thermal/thermal_core.c
··· 794 794 tz->type, cdev->type, ret); 795 795 } 796 796 797 - static void __bind(struct thermal_zone_device *tz, int mask, 798 - struct thermal_cooling_device *cdev, 799 - unsigned long *limits, 800 - unsigned int weight) 801 - { 802 - int i, ret; 803 - 804 - for (i = 0; i < tz->num_trips; i++) { 805 - if (mask & (1 << i)) { 806 - unsigned long upper, lower; 807 - 808 - upper = THERMAL_NO_LIMIT; 809 - lower = THERMAL_NO_LIMIT; 810 - if (limits) { 811 - lower = limits[i * 2]; 812 - upper = limits[i * 2 + 1]; 813 - } 814 - ret = thermal_zone_bind_cooling_device(tz, i, cdev, 815 - upper, lower, 816 - weight); 817 - if (ret) 818 - print_bind_err_msg(tz, cdev, ret); 819 - } 820 - } 821 - } 822 - 823 797 static void bind_cdev(struct thermal_cooling_device *cdev) 824 798 { 825 - int i, ret; 826 - const struct thermal_zone_params *tzp; 799 + int ret; 827 800 struct thermal_zone_device *pos = NULL; 828 801 829 802 list_for_each_entry(pos, &thermal_tz_list, node) { 830 - if (!pos->tzp && !pos->ops->bind) 831 - continue; 832 - 833 803 if (pos->ops->bind) { 834 804 ret = pos->ops->bind(pos, cdev); 835 805 if (ret) 836 806 print_bind_err_msg(pos, cdev, ret); 837 - continue; 838 - } 839 - 840 - tzp = pos->tzp; 841 - if (!tzp || !tzp->tbp) 842 - continue; 843 - 844 - for (i = 0; i < tzp->num_tbps; i++) { 845 - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) 846 - continue; 847 - if (tzp->tbp[i].match(pos, cdev)) 848 - continue; 849 - tzp->tbp[i].cdev = cdev; 850 - __bind(pos, tzp->tbp[i].trip_mask, cdev, 851 - tzp->tbp[i].binding_limits, 852 - tzp->tbp[i].weight); 853 807 } 854 808 } 855 809 } ··· 1088 1134 } 1089 1135 EXPORT_SYMBOL_GPL(thermal_cooling_device_update); 1090 1136 1091 - static void __unbind(struct thermal_zone_device *tz, int mask, 1092 - struct thermal_cooling_device *cdev) 1093 - { 1094 - int i; 1095 - 1096 - for (i = 0; i < tz->num_trips; i++) 1097 - if (mask & (1 << i)) 1098 - thermal_zone_unbind_cooling_device(tz, i, cdev); 1099 - } 1100 - 1101 1137 /** 1102 1138 * thermal_cooling_device_unregister - removes a thermal cooling device 1103 1139 * @cdev: the thermal cooling device to remove. ··· 1097 1153 */ 1098 1154 void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) 1099 1155 { 1100 - int i; 1101 - const struct thermal_zone_params *tzp; 1102 1156 struct thermal_zone_device *tz; 1103 1157 1104 1158 if (!cdev) ··· 1113 1171 1114 1172 /* Unbind all thermal zones associated with 'this' cdev */ 1115 1173 list_for_each_entry(tz, &thermal_tz_list, node) { 1116 - if (tz->ops->unbind) { 1174 + if (tz->ops->unbind) 1117 1175 tz->ops->unbind(tz, cdev); 1118 - continue; 1119 - } 1120 - 1121 - if (!tz->tzp || !tz->tzp->tbp) 1122 - continue; 1123 - 1124 - tzp = tz->tzp; 1125 - for (i = 0; i < tzp->num_tbps; i++) { 1126 - if (tzp->tbp[i].cdev == cdev) { 1127 - __unbind(tz, tzp->tbp[i].trip_mask, cdev); 1128 - tzp->tbp[i].cdev = NULL; 1129 - } 1130 - } 1131 1176 } 1132 1177 1133 1178 mutex_unlock(&thermal_list_lock); ··· 1125 1196 1126 1197 static void bind_tz(struct thermal_zone_device *tz) 1127 1198 { 1128 - int i, ret; 1199 + int ret; 1129 1200 struct thermal_cooling_device *pos = NULL; 1130 - const struct thermal_zone_params *tzp = tz->tzp; 1131 1201 1132 - if (!tzp && !tz->ops->bind) 1202 + if (!tz->ops->bind) 1133 1203 return; 1134 1204 1135 1205 mutex_lock(&thermal_list_lock); 1136 1206 1137 - /* If there is ops->bind, try to use ops->bind */ 1138 - if (tz->ops->bind) { 1139 - list_for_each_entry(pos, &thermal_cdev_list, node) { 1140 - ret = tz->ops->bind(tz, pos); 1141 - if (ret) 1142 - print_bind_err_msg(tz, pos, ret); 1143 - } 1144 - goto exit; 1145 - } 1146 - 1147 - if (!tzp || !tzp->tbp) 1148 - goto exit; 1149 - 1150 1207 list_for_each_entry(pos, &thermal_cdev_list, node) { 1151 - for (i = 0; i < tzp->num_tbps; i++) { 1152 - if (tzp->tbp[i].cdev || !tzp->tbp[i].match) 1153 - continue; 1154 - if (tzp->tbp[i].match(tz, pos)) 1155 - continue; 1156 - tzp->tbp[i].cdev = pos; 1157 - __bind(tz, tzp->tbp[i].trip_mask, pos, 1158 - tzp->tbp[i].binding_limits, 1159 - tzp->tbp[i].weight); 1160 - } 1208 + ret = tz->ops->bind(tz, pos); 1209 + if (ret) 1210 + print_bind_err_msg(tz, pos, ret); 1161 1211 } 1162 - exit: 1212 + 1163 1213 mutex_unlock(&thermal_list_lock); 1164 1214 } 1165 1215 ··· 1395 1487 */ 1396 1488 void thermal_zone_device_unregister(struct thermal_zone_device *tz) 1397 1489 { 1398 - int i, tz_id; 1399 - const struct thermal_zone_params *tzp; 1490 + int tz_id; 1400 1491 struct thermal_cooling_device *cdev; 1401 1492 struct thermal_zone_device *pos = NULL; 1402 1493 1403 1494 if (!tz) 1404 1495 return; 1405 1496 1406 - tzp = tz->tzp; 1407 1497 tz_id = tz->id; 1408 1498 1409 1499 mutex_lock(&thermal_list_lock); ··· 1416 1510 list_del(&tz->node); 1417 1511 1418 1512 /* Unbind all cdevs associated with 'this' thermal zone */ 1419 - list_for_each_entry(cdev, &thermal_cdev_list, node) { 1420 - if (tz->ops->unbind) { 1513 + list_for_each_entry(cdev, &thermal_cdev_list, node) 1514 + if (tz->ops->unbind) 1421 1515 tz->ops->unbind(tz, cdev); 1422 - continue; 1423 - } 1424 - 1425 - if (!tzp || !tzp->tbp) 1426 - break; 1427 - 1428 - for (i = 0; i < tzp->num_tbps; i++) { 1429 - if (tzp->tbp[i].cdev == cdev) { 1430 - __unbind(tz, tzp->tbp[i].trip_mask, cdev); 1431 - tzp->tbp[i].cdev = NULL; 1432 - } 1433 - } 1434 - } 1435 1516 1436 1517 mutex_unlock(&thermal_list_lock); 1437 1518
-38
include/linux/thermal.h
··· 207 207 struct list_head governor_list; 208 208 }; 209 209 210 - /* Structure that holds binding parameters for a zone */ 211 - struct thermal_bind_params { 212 - struct thermal_cooling_device *cdev; 213 - 214 - /* 215 - * This is a measure of 'how effectively these devices can 216 - * cool 'this' thermal zone. It shall be determined by 217 - * platform characterization. This value is relative to the 218 - * rest of the weights so a cooling device whose weight is 219 - * double that of another cooling device is twice as 220 - * effective. See Documentation/driver-api/thermal/sysfs-api.rst for more 221 - * information. 222 - */ 223 - int weight; 224 - 225 - /* 226 - * This is a bit mask that gives the binding relation between this 227 - * thermal zone and cdev, for a particular trip point. 228 - * See Documentation/driver-api/thermal/sysfs-api.rst for more information. 229 - */ 230 - int trip_mask; 231 - 232 - /* 233 - * This is an array of cooling state limits. Must have exactly 234 - * 2 * thermal_zone.number_of_trip_points. It is an array consisting 235 - * of tuples <lower-state upper-state> of state limits. Each trip 236 - * will be associated with one state limit tuple when binding. 237 - * A NULL pointer means <THERMAL_NO_LIMITS THERMAL_NO_LIMITS> 238 - * on all trips. 239 - */ 240 - unsigned long *binding_limits; 241 - int (*match) (struct thermal_zone_device *tz, 242 - struct thermal_cooling_device *cdev); 243 - }; 244 - 245 210 /* Structure to define Thermal Zone parameters */ 246 211 struct thermal_zone_params { 247 212 char governor_name[THERMAL_NAME_LENGTH]; ··· 217 252 * will be created. when no_hwmon == true, nothing will be done 218 253 */ 219 254 bool no_hwmon; 220 - 221 - int num_tbps; /* Number of tbp entries */ 222 - struct thermal_bind_params *tbp; 223 255 224 256 /* 225 257 * Sustainable power (heat) that this thermal zone can dissipate in