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

Merge tag 'thermal-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki:
"These start a rework of the handling of trip points in the thermal
core, improve the cpufreq/devfreq cooling device handling, update some
thermal control drivers and the tmon utility and clean up code.

Specifics:

- Consolidate the thermal core code by beginning to move the thermal
trip structure from the thermal OF code as a generic structure to
be used by the different sensors when registering a thermal zone
(Daniel Lezcano).

- Make per cpufreq / devfreq cooling device ops instead of using a
global variable, fix comments and rework the trace information
(Lukasz Luba).

- Add the include/dt-bindings/thermal.h under the area covered by the
thermal maintainer in the MAINTAINERS file (Lukas Bulwahn).

- Improve the error output by giving the sensor identification when a
thermal zone failed to initialize, the DT bindings by changing the
positive logic and adding the r8a779f0 support on the rcar3
(Wolfram Sang).

- Convert the QCom tsens DT binding to the dtsformat format
(Krzysztof Kozlowski).

- Remove the pointless get_trend() function in the QCom, Ux500 and
tegra thermal drivers, along with the unused DROP_FULL and
RAISE_FULL trends definitions. Simplify the code by using clamp()
macros (Daniel Lezcano).

- Fix ref_table memory leak at probe time on the k3_j72xx bandgap
(Bryan Brattlof).

- Fix array underflow in prep_lookup_table (Dan Carpenter).

- Add static annotation to the k3_j72xx_bandgap_j7* data structure
(Jin Xiaoyun).

- Fix typos in comments detected on sun8i by Coccinelle (Julia
Lawall).

- Fix typos in comments on rzg2l (Biju Das).

- Remove as unnecessary call to dev_err() as the error is already
printed by the failing function on u8500 (Yang Li).

- Register the thermal zones as hwmon sensors for the Qcom thermal
sensors (Dmitry Baryshkov).

- Fix 'tmon' tool compilation issue by adding phtread.h include
(Markus Mayer).

- Fix typo in the comments for the 'tmon' tool (Slark Xiao).

- Make the thermal core use ida_alloc()/free() directly instead of
ida_simple_get()/ida_simple_remove() that have been deprecated
(keliu).

- Drop ACPI_FADT_LOW_POWER_S0 check from the Intel PCH thermal
control driver (Rafael Wysocki)"

* tag 'thermal-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (39 commits)
thermal/of: Initialize trip points separately
thermal/of: Use thermal trips stored in the thermal zone
thermal/core: Add thermal_trip in thermal_zone
thermal/core: Rename 'trips' to 'num_trips'
thermal/core: Move thermal_set_delay_jiffies to static
thermal/core: Remove unneeded EXPORT_SYMBOLS
thermal/of: Move thermal_trip structure to thermal.h
thermal/of: Remove the device node pointer for thermal_trip
thermal/of: Replace device node match with device node search
thermal/core: Remove duplicate information when an error occurs
thermal/core: Avoid calling ->get_trip_temp() unnecessarily
thermal/tools/tmon: Fix typo 'the the' in comment
thermal/tools/tmon: Include pthread and time headers in tmon.h
thermal/ti-soc-thermal: Fix comment typo
thermal/drivers/qcom/spmi-adc-tm5: Register thermal zones as hwmon sensors
thermal/drivers/qcom/temp-alarm: Register thermal zones as hwmon sensors
thermal/drivers/u8500: Remove unnecessary print function dev_err()
thermal/drivers/rzg2l: Fix comments
thermal/drivers/sun8i: Fix typo in comment
thermal/drivers/k3_j72xx_bandgap: Make k3_j72xx_bandgap_j721e_data and k3_j72xx_bandgap_j7200_data static
...

+401 -452
+85
Documentation/devicetree/bindings/thermal/qcom,spmi-temp-alarm.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/thermal/qcom,spmi-temp-alarm.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm QPNP PMIC Temperature Alarm 8 + 9 + maintainers: 10 + - Bjorn Andersson <bjorn.andersson@linaro.org> 11 + 12 + description: 13 + QPNP temperature alarm peripherals are found inside of Qualcomm PMIC chips 14 + that utilize the Qualcomm SPMI implementation. These peripherals provide an 15 + interrupt signal and status register to identify high PMIC die temperature. 16 + 17 + allOf: 18 + - $ref: thermal-sensor.yaml# 19 + 20 + properties: 21 + compatible: 22 + const: qcom,spmi-temp-alarm 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + io-channels: 31 + items: 32 + - description: ADC channel, which reports chip die temperature 33 + 34 + io-channel-names: 35 + items: 36 + - const: thermal 37 + 38 + '#thermal-sensor-cells': 39 + const: 0 40 + 41 + required: 42 + - compatible 43 + - reg 44 + - interrupts 45 + - '#thermal-sensor-cells' 46 + 47 + additionalProperties: false 48 + 49 + examples: 50 + - | 51 + #include <dt-bindings/interrupt-controller/arm-gic.h> 52 + 53 + pmic { 54 + #address-cells = <1>; 55 + #size-cells = <0>; 56 + 57 + pm8350_temp_alarm: temperature-sensor@a00 { 58 + compatible = "qcom,spmi-temp-alarm"; 59 + reg = <0xa00>; 60 + interrupts = <0x1 0xa 0x0 IRQ_TYPE_EDGE_BOTH>; 61 + #thermal-sensor-cells = <0>; 62 + }; 63 + }; 64 + 65 + thermal-zones { 66 + pm8350_thermal: pm8350c-thermal { 67 + polling-delay-passive = <100>; 68 + polling-delay = <0>; 69 + thermal-sensors = <&pm8350_temp_alarm>; 70 + 71 + trips { 72 + pm8350_trip0: trip0 { 73 + temperature = <95000>; 74 + hysteresis = <0>; 75 + type = "passive"; 76 + }; 77 + 78 + pm8350_crit: pm8350c-crit { 79 + temperature = <115000>; 80 + hysteresis = <0>; 81 + type = "critical"; 82 + }; 83 + }; 84 + }; 85 + };
-51
Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
··· 1 - Qualcomm QPNP PMIC Temperature Alarm 2 - 3 - QPNP temperature alarm peripherals are found inside of Qualcomm PMIC chips 4 - that utilize the Qualcomm SPMI implementation. These peripherals provide an 5 - interrupt signal and status register to identify high PMIC die temperature. 6 - 7 - Required properties: 8 - - compatible: Should contain "qcom,spmi-temp-alarm". 9 - - reg: Specifies the SPMI address. 10 - - interrupts: PMIC temperature alarm interrupt. 11 - - #thermal-sensor-cells: Should be 0. See Documentation/devicetree/bindings/thermal/thermal-sensor.yaml for a description. 12 - 13 - Optional properties: 14 - - io-channels: Should contain IIO channel specifier for the ADC channel, 15 - which report chip die temperature. 16 - - io-channel-names: Should contain "thermal". 17 - 18 - Example: 19 - 20 - pm8941_temp: thermal-alarm@2400 { 21 - compatible = "qcom,spmi-temp-alarm"; 22 - reg = <0x2400>; 23 - interrupts = <0 0x24 0 IRQ_TYPE_EDGE_RISING>; 24 - #thermal-sensor-cells = <0>; 25 - 26 - io-channels = <&pm8941_vadc VADC_DIE_TEMP>; 27 - io-channel-names = "thermal"; 28 - }; 29 - 30 - thermal-zones { 31 - pm8941 { 32 - polling-delay-passive = <250>; 33 - polling-delay = <1000>; 34 - 35 - thermal-sensors = <&pm8941_temp>; 36 - 37 - trips { 38 - stage1 { 39 - temperature = <105000>; 40 - hysteresis = <2000>; 41 - type = "passive"; 42 - }; 43 - stage2 { 44 - temperature = <125000>; 45 - hysteresis = <2000>; 46 - type = "critical"; 47 - }; 48 - }; 49 - }; 50 - }; 51 -
+27 -19
Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.yaml
··· 8 8 title: Renesas R-Car Gen3 Thermal Sensor 9 9 10 10 description: 11 - On R-Car Gen3 SoCs, the thermal sensor controllers (TSC) control the thermal 12 - sensors (THS) which are the analog circuits for measuring temperature (Tj) 13 - inside the LSI. 11 + On most R-Car Gen3 and later SoCs, the thermal sensor controllers (TSC) 12 + control the thermal sensors (THS) which are the analog circuits for 13 + measuring temperature (Tj) inside the LSI. 14 14 15 15 maintainers: 16 16 - Niklas Söderlund <niklas.soderlund@ragnatech.se> ··· 27 27 - renesas,r8a77965-thermal # R-Car M3-N 28 28 - renesas,r8a77980-thermal # R-Car V3H 29 29 - renesas,r8a779a0-thermal # R-Car V3U 30 + - renesas,r8a779f0-thermal # R-Car S4-8 30 31 31 32 reg: true 32 33 ··· 58 57 - "#thermal-sensor-cells" 59 58 60 59 if: 61 - not: 62 - properties: 63 - compatible: 64 - contains: 65 - enum: 66 - - renesas,r8a779a0-thermal 67 - then: 68 60 properties: 69 - reg: 70 - minItems: 2 71 - items: 72 - - description: TSC1 registers 73 - - description: TSC2 registers 74 - - description: TSC3 registers 75 - required: 76 - - interrupts 77 - else: 61 + compatible: 62 + contains: 63 + enum: 64 + - renesas,r8a779a0-thermal 65 + then: 78 66 properties: 79 67 reg: 80 68 items: ··· 72 82 - description: TSC2 registers 73 83 - description: TSC3 registers 74 84 - description: TSC4 registers 85 + else: 86 + properties: 87 + reg: 88 + minItems: 2 89 + items: 90 + - description: TSC1 registers 91 + - description: TSC2 registers 92 + - description: TSC3 registers 93 + if: 94 + not: 95 + properties: 96 + compatible: 97 + contains: 98 + enum: 99 + - renesas,r8a779f0-thermal 100 + then: 101 + required: 102 + - interrupts 75 103 76 104 additionalProperties: false 77 105
+1
MAINTAINERS
··· 19949 19949 F: Documentation/devicetree/bindings/thermal/ 19950 19950 F: Documentation/driver-api/thermal/ 19951 19951 F: drivers/thermal/ 19952 + F: include/dt-bindings/thermal/ 19952 19953 F: include/linux/cpu_cooling.h 19953 19954 F: include/linux/thermal.h 19954 19955 F: include/uapi/linux/thermal.h
+24 -51
drivers/thermal/cpufreq_cooling.c
··· 60 60 * @cdev: thermal_cooling_device pointer to keep track of the 61 61 * registered cooling device. 62 62 * @policy: cpufreq policy. 63 + * @cooling_ops: cpufreq callbacks to thermal cooling device ops 63 64 * @idle_time: idle time stats 64 65 * @qos_req: PM QoS contraint to apply 65 66 * ··· 73 72 unsigned int max_level; 74 73 struct em_perf_domain *em; 75 74 struct cpufreq_policy *policy; 75 + struct thermal_cooling_device_ops cooling_ops; 76 76 #ifndef CONFIG_SMP 77 77 struct time_in_idle *idle_time; 78 78 #endif ··· 213 211 * complex code may be needed if experiments show that it's not 214 212 * accurate enough. 215 213 * 216 - * Return: 0 on success, -E* if getting the static power failed. 214 + * Return: 0 on success, this function doesn't fail. 217 215 */ 218 216 static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, 219 217 u32 *power) ··· 223 221 u32 total_load = 0; 224 222 struct cpufreq_cooling_device *cpufreq_cdev = cdev->devdata; 225 223 struct cpufreq_policy *policy = cpufreq_cdev->policy; 226 - u32 *load_cpu = NULL; 227 224 228 225 freq = cpufreq_quick_get(policy->cpu); 229 - 230 - if (trace_thermal_power_cpu_get_power_enabled()) { 231 - u32 ncpus = cpumask_weight(policy->related_cpus); 232 - 233 - load_cpu = kcalloc(ncpus, sizeof(*load_cpu), GFP_KERNEL); 234 - } 235 226 236 227 for_each_cpu(cpu, policy->related_cpus) { 237 228 u32 load; ··· 235 240 load = 0; 236 241 237 242 total_load += load; 238 - if (load_cpu) 239 - load_cpu[i] = load; 240 - 241 - i++; 242 243 } 243 244 244 245 cpufreq_cdev->last_load = total_load; 245 246 246 247 *power = get_dynamic_power(cpufreq_cdev, freq); 247 248 248 - if (load_cpu) { 249 - trace_thermal_power_cpu_get_power(policy->related_cpus, freq, 250 - load_cpu, i, *power); 251 - 252 - kfree(load_cpu); 253 - } 249 + trace_thermal_power_cpu_get_power_simple(policy->cpu, *power); 254 250 255 251 return 0; 256 252 } ··· 256 270 * milliwatts assuming 100% load. Store the calculated power in 257 271 * @power. 258 272 * 259 - * Return: 0 on success, -EINVAL if the cooling device state could not 260 - * be converted into a frequency or other -E* if there was an error 261 - * when calculating the static power. 273 + * Return: 0 on success, -EINVAL if the cooling device state is bigger 274 + * than maximum allowed. 262 275 */ 263 276 static int cpufreq_state2power(struct thermal_cooling_device *cdev, 264 277 unsigned long state, u32 *power) ··· 287 302 * Calculate a cooling device state for the cpus described by @cdev 288 303 * that would allow them to consume at most @power mW and store it in 289 304 * @state. Note that this calculation depends on external factors 290 - * such as the cpu load or the current static power. Calling this 291 - * function with the same power as input can yield different cooling 292 - * device states depending on those external factors. 305 + * such as the CPUs load. Calling this function with the same power 306 + * as input can yield different cooling device states depending on those 307 + * external factors. 293 308 * 294 - * Return: 0 on success, -ENODEV if no cpus are online or -EINVAL if 295 - * the calculated frequency could not be converted to a valid state. 296 - * The latter should not happen unless the frequencies available to 297 - * cpufreq have changed since the initialization of the cpu cooling 298 - * device. 309 + * Return: 0 on success, this function doesn't fail. 299 310 */ 300 311 static int cpufreq_power2state(struct thermal_cooling_device *cdev, 301 312 u32 power, unsigned long *state) ··· 403 422 * Callback for the thermal cooling device to return the cpufreq 404 423 * max cooling state. 405 424 * 406 - * Return: 0 on success, an error code otherwise. 425 + * Return: 0 on success, this function doesn't fail. 407 426 */ 408 427 static int cpufreq_get_max_state(struct thermal_cooling_device *cdev, 409 428 unsigned long *state) ··· 422 441 * Callback for the thermal cooling device to return the cpufreq 423 442 * current cooling state. 424 443 * 425 - * Return: 0 on success, an error code otherwise. 444 + * Return: 0 on success, this function doesn't fail. 426 445 */ 427 446 static int cpufreq_get_cur_state(struct thermal_cooling_device *cdev, 428 447 unsigned long *state) ··· 473 492 return ret; 474 493 } 475 494 476 - /* Bind cpufreq callbacks to thermal cooling device ops */ 477 - 478 - static struct thermal_cooling_device_ops cpufreq_cooling_ops = { 479 - .get_max_state = cpufreq_get_max_state, 480 - .get_cur_state = cpufreq_get_cur_state, 481 - .set_cur_state = cpufreq_set_cur_state, 482 - }; 483 - 484 495 /** 485 496 * __cpufreq_cooling_register - helper function to create cpufreq cooling device 486 497 * @np: a valid struct device_node to the cooling device device tree node ··· 481 508 * @em: Energy Model of the cpufreq policy 482 509 * 483 510 * This interface function registers the cpufreq cooling device with the name 484 - * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 511 + * "cpufreq-%s". This API can support multiple instances of cpufreq 485 512 * cooling devices. It also gives the opportunity to link the cooling device 486 513 * with a device tree node, in order to bind it via the thermal DT code. 487 514 * ··· 534 561 /* max_level is an index, not a counter */ 535 562 cpufreq_cdev->max_level = i - 1; 536 563 537 - cooling_ops = &cpufreq_cooling_ops; 564 + cooling_ops = &cpufreq_cdev->cooling_ops; 565 + cooling_ops->get_max_state = cpufreq_get_max_state; 566 + cooling_ops->get_cur_state = cpufreq_get_cur_state; 567 + cooling_ops->set_cur_state = cpufreq_set_cur_state; 538 568 539 569 #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR 540 570 if (em_is_sane(cpufreq_cdev, em)) { ··· 592 616 * @policy: cpufreq policy 593 617 * 594 618 * This interface function registers the cpufreq cooling device with the name 595 - * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 596 - * cooling devices. 619 + * "cpufreq-%s". This API can support multiple instances of cpufreq cooling 620 + * devices. 597 621 * 598 622 * Return: a valid struct thermal_cooling_device pointer on success, 599 623 * on failure, it returns a corresponding ERR_PTR(). ··· 610 634 * @policy: cpufreq policy 611 635 * 612 636 * This interface function registers the cpufreq cooling device with the name 613 - * "thermal-cpufreq-%x". This api can support multiple instances of cpufreq 614 - * cooling devices. Using this API, the cpufreq cooling device will be 615 - * linked to the device tree node provided. 637 + * "cpufreq-%s". This API can support multiple instances of cpufreq cooling 638 + * devices. Using this API, the cpufreq cooling device will be linked to the 639 + * device tree node provided. 616 640 * 617 641 * Using this function, the cooling device will implement the power 618 - * extensions by using a simple cpu power model. The cpus must have 642 + * extensions by using the Energy Model (if present). The cpus must have 619 643 * registered their OPPs using the OPP library. 620 - * 621 - * It also takes into account, if property present in policy CPU node, the 622 - * static power consumed by the cpu. 623 644 * 624 645 * Return: a valid struct thermal_cooling_device pointer on success, 625 646 * and NULL on failure. ··· 653 680 * cpufreq_cooling_unregister - function to remove cpufreq cooling device. 654 681 * @cdev: thermal cooling device pointer. 655 682 * 656 - * This interface function unregisters the "thermal-cpufreq-%x" cooling device. 683 + * This interface function unregisters the "cpufreq-%x" cooling device. 657 684 */ 658 685 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev) 659 686 {
+6 -28
drivers/thermal/db8500_thermal.c
··· 53 53 54 54 struct db8500_thermal_zone { 55 55 struct thermal_zone_device *tz; 56 - enum thermal_trend trend; 57 56 unsigned long interpolated_temp; 58 57 unsigned int cur_index; 59 58 }; ··· 72 73 return 0; 73 74 } 74 75 75 - /* Callback to get temperature changing trend */ 76 - static int db8500_thermal_get_trend(void *data, int trip, enum thermal_trend *trend) 77 - { 78 - struct db8500_thermal_zone *th = data; 79 - 80 - *trend = th->trend; 81 - 82 - return 0; 83 - } 84 - 85 76 static struct thermal_zone_of_device_ops thdev_ops = { 86 77 .get_temp = db8500_thermal_get_temp, 87 - .get_trend = db8500_thermal_get_trend, 88 78 }; 89 79 90 80 static void db8500_thermal_update_config(struct db8500_thermal_zone *th, 91 81 unsigned int idx, 92 - enum thermal_trend trend, 93 82 unsigned long next_low, 94 83 unsigned long next_high) 95 84 { ··· 85 98 86 99 th->cur_index = idx; 87 100 th->interpolated_temp = (next_low + next_high)/2; 88 - th->trend = trend; 89 101 90 102 /* 91 103 * The PRCMU accept absolute temperatures in celsius so divide ··· 113 127 } 114 128 idx -= 1; 115 129 116 - db8500_thermal_update_config(th, idx, THERMAL_TREND_DROPPING, 117 - next_low, next_high); 130 + db8500_thermal_update_config(th, idx, next_low, next_high); 118 131 dev_dbg(&th->tz->device, 119 132 "PRCMU set max %ld, min %ld\n", next_high, next_low); 120 133 ··· 134 149 next_low = db8500_thermal_points[idx]; 135 150 idx += 1; 136 151 137 - db8500_thermal_update_config(th, idx, THERMAL_TREND_RAISING, 138 - next_low, next_high); 152 + db8500_thermal_update_config(th, idx, next_low, next_high); 139 153 140 154 dev_dbg(&th->tz->device, 141 155 "PRCMU set max %ld, min %ld\n", next_high, next_low); ··· 158 174 return -ENOMEM; 159 175 160 176 low_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_LOW"); 161 - if (low_irq < 0) { 162 - dev_err(dev, "Get IRQ_HOTMON_LOW failed\n"); 177 + if (low_irq < 0) 163 178 return low_irq; 164 - } 165 179 166 180 ret = devm_request_threaded_irq(dev, low_irq, NULL, 167 181 prcmu_low_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, ··· 170 188 } 171 189 172 190 high_irq = platform_get_irq_byname(pdev, "IRQ_HOTMON_HIGH"); 173 - if (high_irq < 0) { 174 - dev_err(dev, "Get IRQ_HOTMON_HIGH failed\n"); 191 + if (high_irq < 0) 175 192 return high_irq; 176 - } 177 193 178 194 ret = devm_request_threaded_irq(dev, high_irq, NULL, 179 195 prcmu_high_irq_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, ··· 190 210 dev_info(dev, "thermal zone sensor registered\n"); 191 211 192 212 /* Start measuring at the lowest point */ 193 - db8500_thermal_update_config(th, 0, THERMAL_TREND_STABLE, 194 - PRCMU_DEFAULT_LOW_TEMP, 213 + db8500_thermal_update_config(th, 0, PRCMU_DEFAULT_LOW_TEMP, 195 214 db8500_thermal_points[0]); 196 215 197 216 platform_set_drvdata(pdev, th); ··· 211 232 struct db8500_thermal_zone *th = platform_get_drvdata(pdev); 212 233 213 234 /* Resume and start measuring at the lowest point */ 214 - db8500_thermal_update_config(th, 0, THERMAL_TREND_STABLE, 215 - PRCMU_DEFAULT_LOW_TEMP, 235 + db8500_thermal_update_config(th, 0, PRCMU_DEFAULT_LOW_TEMP, 216 236 db8500_thermal_points[0]); 217 237 218 238 return 0;
+9 -18
drivers/thermal/devfreq_cooling.c
··· 28 28 * struct devfreq_cooling_device - Devfreq cooling device 29 29 * devfreq_cooling_device registered. 30 30 * @cdev: Pointer to associated thermal cooling device. 31 + * @cooling_ops: devfreq callbacks to thermal cooling device ops 31 32 * @devfreq: Pointer to associated devfreq device. 32 33 * @cooling_state: Current cooling state. 33 34 * @freq_table: Pointer to a table with the frequencies sorted in descending ··· 49 48 */ 50 49 struct devfreq_cooling_device { 51 50 struct thermal_cooling_device *cdev; 51 + struct thermal_cooling_device_ops cooling_ops; 52 52 struct devfreq *devfreq; 53 53 unsigned long cooling_state; 54 54 u32 *freq_table; ··· 303 301 return 0; 304 302 } 305 303 306 - static struct thermal_cooling_device_ops devfreq_cooling_ops = { 307 - .get_max_state = devfreq_cooling_get_max_state, 308 - .get_cur_state = devfreq_cooling_get_cur_state, 309 - .set_cur_state = devfreq_cooling_set_cur_state, 310 - }; 311 - 312 304 /** 313 305 * devfreq_cooling_gen_tables() - Generate frequency table. 314 306 * @dfc: Pointer to devfreq cooling device. ··· 370 374 char *name; 371 375 int err, num_opps; 372 376 373 - ops = kmemdup(&devfreq_cooling_ops, sizeof(*ops), GFP_KERNEL); 374 - if (!ops) 375 - return ERR_PTR(-ENOMEM); 376 377 377 378 dfc = kzalloc(sizeof(*dfc), GFP_KERNEL); 378 - if (!dfc) { 379 - err = -ENOMEM; 380 - goto free_ops; 381 - } 379 + if (!dfc) 380 + return ERR_PTR(-ENOMEM); 382 381 383 382 dfc->devfreq = df; 383 + 384 + ops = &dfc->cooling_ops; 385 + ops->get_max_state = devfreq_cooling_get_max_state; 386 + ops->get_cur_state = devfreq_cooling_get_cur_state; 387 + ops->set_cur_state = devfreq_cooling_set_cur_state; 384 388 385 389 em = em_pd_get(dev); 386 390 if (em && !em_is_artificial(em)) { ··· 444 448 kfree(dfc->freq_table); 445 449 free_dfc: 446 450 kfree(dfc); 447 - free_ops: 448 - kfree(ops); 449 451 450 452 return ERR_PTR(err); 451 453 } ··· 525 531 void devfreq_cooling_unregister(struct thermal_cooling_device *cdev) 526 532 { 527 533 struct devfreq_cooling_device *dfc; 528 - const struct thermal_cooling_device_ops *ops; 529 534 struct device *dev; 530 535 531 536 if (IS_ERR_OR_NULL(cdev)) 532 537 return; 533 538 534 - ops = cdev->ops; 535 539 dfc = cdev->devdata; 536 540 dev = dfc->devfreq->dev.parent; 537 541 ··· 540 548 541 549 kfree(dfc->freq_table); 542 550 kfree(dfc); 543 - kfree(ops); 544 551 } 545 552 EXPORT_SYMBOL_GPL(devfreq_cooling_unregister);
+3 -3
drivers/thermal/gov_fair_share.c
··· 25 25 int trip_temp; 26 26 enum thermal_trip_type trip_type; 27 27 28 - if (tz->trips == 0 || !tz->ops->get_trip_temp) 28 + if (tz->num_trips == 0 || !tz->ops->get_trip_temp) 29 29 return 0; 30 30 31 - for (count = 0; count < tz->trips; count++) { 31 + for (count = 0; count < tz->num_trips; count++) { 32 32 tz->ops->get_trip_temp(tz, count, &trip_temp); 33 33 if (tz->temperature < trip_temp) 34 34 break; ··· 53 53 54 54 cdev->ops->get_max_state(cdev, &max_state); 55 55 56 - return (long)(percentage * level * max_state) / (100 * tz->trips); 56 + return (long)(percentage * level * max_state) / (100 * tz->num_trips); 57 57 } 58 58 59 59 /**
+2 -2
drivers/thermal/gov_power_allocator.c
··· 527 527 last_active = INVALID_TRIP; 528 528 last_passive = INVALID_TRIP; 529 529 530 - for (i = 0; i < tz->trips; i++) { 530 + for (i = 0; i < tz->num_trips; i++) { 531 531 enum thermal_trip_type type; 532 532 int ret; 533 533 ··· 668 668 669 669 get_governor_trips(tz, params); 670 670 671 - if (tz->trips > 0) { 671 + if (tz->num_trips > 0) { 672 672 ret = tz->ops->get_trip_temp(tz, 673 673 params->trip_max_desired_temperature, 674 674 &control_temp);
+4 -22
drivers/thermal/gov_step_wise.c
··· 11 11 */ 12 12 13 13 #include <linux/thermal.h> 14 + #include <linux/minmax.h> 14 15 #include <trace/events/thermal.h> 15 16 16 17 #include "thermal_core.h" ··· 53 52 54 53 if (!instance->initialized) { 55 54 if (throttle) { 56 - next_target = (cur_state + 1) >= instance->upper ? 57 - instance->upper : 58 - ((cur_state + 1) < instance->lower ? 59 - instance->lower : (cur_state + 1)); 55 + next_target = clamp((cur_state + 1), instance->lower, instance->upper); 60 56 } else { 61 57 next_target = THERMAL_NO_TARGET; 62 58 } ··· 64 66 switch (trend) { 65 67 case THERMAL_TREND_RAISING: 66 68 if (throttle) { 67 - next_target = cur_state < instance->upper ? 68 - (cur_state + 1) : instance->upper; 69 - if (next_target < instance->lower) 70 - next_target = instance->lower; 69 + next_target = clamp((cur_state + 1), instance->lower, instance->upper); 71 70 } 72 - break; 73 - case THERMAL_TREND_RAISE_FULL: 74 - if (throttle) 75 - next_target = instance->upper; 76 71 break; 77 72 case THERMAL_TREND_DROPPING: 78 73 if (cur_state <= instance->lower) { ··· 73 82 next_target = THERMAL_NO_TARGET; 74 83 } else { 75 84 if (!throttle) { 76 - next_target = cur_state - 1; 77 - if (next_target > instance->upper) 78 - next_target = instance->upper; 85 + next_target = clamp((cur_state - 1), instance->lower, instance->upper); 79 86 } 80 87 } 81 - break; 82 - case THERMAL_TREND_DROP_FULL: 83 - if (cur_state == instance->lower) { 84 - if (!throttle) 85 - next_target = THERMAL_NO_TARGET; 86 - } else 87 - next_target = instance->lower; 88 88 break; 89 89 default: 90 90 break;
-8
drivers/thermal/intel/intel_pch_thermal.c
··· 207 207 return 0; 208 208 } 209 209 210 - /* Do not check temperature if it is not a S0ix capable platform */ 211 - #ifdef CONFIG_ACPI 212 - if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) 213 - return 0; 214 - #else 215 - return 0; 216 - #endif 217 - 218 210 /* Do not check temperature if it is not s2idle */ 219 211 if (pm_suspend_via_firmware()) 220 212 return 0;
+1 -1
drivers/thermal/intel/x86_pkg_temp_thermal.c
··· 105 105 } 106 106 107 107 /* 108 - * tj-max is is interesting because threshold is set relative to this 108 + * tj-max is interesting because threshold is set relative to this 109 109 * temperature. 110 110 */ 111 111 static int get_tj_max(int cpu, u32 *tj_max)
+7 -6
drivers/thermal/k3_j72xx_bandgap.c
··· 151 151 /* 300 milli celsius steps */ 152 152 while (i--) 153 153 derived_table[i] = derived_table[i + 1] - 300; 154 - /* case 0 */ 155 - derived_table[i] = derived_table[i + 1] - 300; 156 154 } 157 155 158 156 /* ··· 431 433 GFP_KERNEL); 432 434 if (!derived_table) { 433 435 ret = -ENOMEM; 434 - goto err_alloc; 436 + goto err_free_ref_table; 435 437 } 436 438 437 439 /* Workaround not needed if bit30/bit31 is set even for J721e */ ··· 481 483 if (IS_ERR(ti_thermal)) { 482 484 dev_err(bgp->dev, "thermal zone device is NULL\n"); 483 485 ret = PTR_ERR(ti_thermal); 484 - goto err_alloc; 486 + goto err_free_ref_table; 485 487 } 486 488 } 487 489 ··· 512 514 513 515 return 0; 514 516 517 + err_free_ref_table: 518 + kfree(ref_table); 519 + 515 520 err_alloc: 516 521 pm_runtime_put_sync(&pdev->dev); 517 522 pm_runtime_disable(&pdev->dev); ··· 530 529 return 0; 531 530 } 532 531 533 - const struct k3_j72xx_bandgap_data k3_j72xx_bandgap_j721e_data = { 532 + static const struct k3_j72xx_bandgap_data k3_j72xx_bandgap_j721e_data = { 534 533 .has_errata_i2128 = 1, 535 534 }; 536 535 537 - const struct k3_j72xx_bandgap_data k3_j72xx_bandgap_j7200_data = { 536 + static const struct k3_j72xx_bandgap_data k3_j72xx_bandgap_j7200_data = { 538 537 .has_errata_i2128 = 0, 539 538 }; 540 539
+5
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
··· 20 20 #include <linux/thermal.h> 21 21 #include <asm-generic/unaligned.h> 22 22 23 + #include "../thermal_hwmon.h" 24 + 23 25 /* 24 26 * Thermal monitoring block consists of 8 (ADC_TM5_NUM_CHANNELS) channels. Each 25 27 * channel is programmed to use one of ADC channels for voltage comparison. ··· 689 687 return PTR_ERR(tzd); 690 688 } 691 689 adc_tm->channels[i].tzd = tzd; 690 + if (devm_thermal_add_hwmon_sysfs(tzd)) 691 + dev_warn(adc_tm->dev, 692 + "Failed to add hwmon sysfs attributes\n"); 692 693 } 693 694 694 695 return 0;
+5
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
··· 16 16 #include <linux/thermal.h> 17 17 18 18 #include "../thermal_core.h" 19 + #include "../thermal_hwmon.h" 19 20 20 21 #define QPNP_TM_REG_DIG_MAJOR 0x01 21 22 #define QPNP_TM_REG_TYPE 0x04 ··· 458 457 dev_err(&pdev->dev, "init failed\n"); 459 458 return ret; 460 459 } 460 + 461 + if (devm_thermal_add_hwmon_sysfs(chip->tz_dev)) 462 + dev_warn(&pdev->dev, 463 + "Failed to add hwmon sysfs attributes\n"); 461 464 462 465 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr, 463 466 IRQF_ONESHOT, node->name, chip);
-12
drivers/thermal/qcom/tsens.c
··· 933 933 return priv->ops->get_temp(s, temp); 934 934 } 935 935 936 - static int tsens_get_trend(void *data, int trip, enum thermal_trend *trend) 937 - { 938 - struct tsens_sensor *s = data; 939 - struct tsens_priv *priv = s->priv; 940 - 941 - if (priv->ops->get_trend) 942 - return priv->ops->get_trend(s, trend); 943 - 944 - return -ENOTSUPP; 945 - } 946 - 947 936 static int __maybe_unused tsens_suspend(struct device *dev) 948 937 { 949 938 struct tsens_priv *priv = dev_get_drvdata(dev); ··· 993 1004 994 1005 static const struct thermal_zone_of_device_ops tsens_of_ops = { 995 1006 .get_temp = tsens_get_temp, 996 - .get_trend = tsens_get_trend, 997 1007 .set_trips = tsens_set_trips, 998 1008 }; 999 1009
-2
drivers/thermal/qcom/tsens.h
··· 65 65 * @disable: Function to disable the tsens device 66 66 * @suspend: Function to suspend the tsens device 67 67 * @resume: Function to resume the tsens device 68 - * @get_trend: Function to get the thermal/temp trend 69 68 */ 70 69 struct tsens_ops { 71 70 /* mandatory callbacks */ ··· 76 77 void (*disable)(struct tsens_priv *priv); 77 78 int (*suspend)(struct tsens_priv *priv); 78 79 int (*resume)(struct tsens_priv *priv); 79 - int (*get_trend)(struct tsens_sensor *s, enum thermal_trend *trend); 80 80 }; 81 81 82 82 #define REG_FIELD_FOR_EACH_SENSOR11(_name, _offset, _startbit, _stopbit) \
+2 -2
drivers/thermal/rcar_gen3_thermal.c
··· 511 511 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, 512 512 &rcar_gen3_tz_of_ops); 513 513 if (IS_ERR(zone)) { 514 - dev_err(dev, "Can't register thermal zone\n"); 514 + dev_err(dev, "Sensor %u: Can't register thermal zone\n", i); 515 515 ret = PTR_ERR(zone); 516 516 goto error_unregister; 517 517 } ··· 533 533 if (ret < 0) 534 534 goto error_unregister; 535 535 536 - dev_info(dev, "TSC%u: Loaded %d trip points\n", i, ret); 536 + dev_info(dev, "Sensor %u: Loaded %d trip points\n", i, ret); 537 537 } 538 538 539 539 if (!priv->num_tscs) {
+11 -7
drivers/thermal/rzg2l_thermal.c
··· 47 47 48 48 #define TS_CODE_AVE_SCALE(x) ((x) * 1000000) 49 49 #define MCELSIUS(temp) ((temp) * MILLIDEGREE_PER_DEGREE) 50 - #define TS_CODE_CAP_TIMES 8 /* Capture times */ 50 + #define TS_CODE_CAP_TIMES 8 /* Total number of ADC data samples */ 51 51 52 52 #define RZG2L_THERMAL_GRAN 500 /* milli Celsius */ 53 53 #define RZG2L_TSU_SS_TIMEOUT_US 1000 ··· 80 80 int val, i; 81 81 82 82 for (i = 0; i < TS_CODE_CAP_TIMES ; i++) { 83 - /* TSU repeats measurement at 20 microseconds intervals and 83 + /* 84 + * TSU repeats measurement at 20 microseconds intervals and 84 85 * automatically updates the results of measurement. As per 85 86 * the HW manual for measuring temperature we need to read 8 86 87 * values consecutively and then take the average. ··· 93 92 94 93 ts_code_ave = result / TS_CODE_CAP_TIMES; 95 94 96 - /* Calculate actual sensor value by applying curvature correction formula 95 + /* 96 + * Calculate actual sensor value by applying curvature correction formula 97 97 * dsensor = ts_code_ave / (1 + ts_code_ave * 0.000013). Here we are doing 98 98 * integer calculation by scaling all the values by 1000000. 99 99 */ 100 100 dsensor = TS_CODE_AVE_SCALE(ts_code_ave) / 101 101 (TS_CODE_AVE_SCALE(1) + (ts_code_ave * CURVATURE_CORRECTION_CONST)); 102 102 103 - /* The temperature Tj is calculated by the formula 103 + /* 104 + * The temperature Tj is calculated by the formula 104 105 * Tj = (dsensor − calib1) * 165/ (calib0 − calib1) − 40 105 - * where calib0 and calib1 are the caliberation values. 106 + * where calib0 and calib1 are the calibration values. 106 107 */ 107 108 val = ((dsensor - priv->calib1) * (MCELSIUS(165) / 108 109 (priv->calib0 - priv->calib1))) - MCELSIUS(40); ··· 125 122 rzg2l_thermal_write(priv, TSU_SM, TSU_SM_NORMAL_MODE); 126 123 rzg2l_thermal_write(priv, TSU_ST, 0); 127 124 128 - /* Before setting the START bit, TSU should be in normal operating 125 + /* 126 + * Before setting the START bit, TSU should be in normal operating 129 127 * mode. As per the HW manual, it will take 60 µs to place the TSU 130 128 * into normal operating mode. 131 129 */ ··· 221 217 if (ret) 222 218 goto err; 223 219 224 - dev_dbg(dev, "TSU probed with %s caliberation values", 220 + dev_dbg(dev, "TSU probed with %s calibration values", 225 221 rzg2l_thermal_read(priv, OTPTSUTRIM_REG(0)) ? "hw" : "sw"); 226 222 227 223 return 0;
+1 -1
drivers/thermal/sun8i_thermal.c
··· 237 237 * The calibration data on the H6 is the ambient temperature and 238 238 * sensor values that are filled during the factory test stage. 239 239 * 240 - * The unit of stored FT temperature is 0.1 degreee celusis. 240 + * The unit of stored FT temperature is 0.1 degree celsius. 241 241 * 242 242 * We need to calculate a delta between measured and caluclated 243 243 * register values and this will become a calibration offset.
-32
drivers/thermal/tegra/soctherm.c
··· 633 633 return 0; 634 634 } 635 635 636 - static int tegra_thermctl_get_trend(void *data, int trip, 637 - enum thermal_trend *trend) 638 - { 639 - struct tegra_thermctl_zone *zone = data; 640 - struct thermal_zone_device *tz = zone->tz; 641 - int trip_temp, temp, last_temp, ret; 642 - 643 - if (!tz) 644 - return -EINVAL; 645 - 646 - ret = tz->ops->get_trip_temp(zone->tz, trip, &trip_temp); 647 - if (ret) 648 - return ret; 649 - 650 - temp = READ_ONCE(tz->temperature); 651 - last_temp = READ_ONCE(tz->last_temperature); 652 - 653 - if (temp > trip_temp) { 654 - if (temp >= last_temp) 655 - *trend = THERMAL_TREND_RAISING; 656 - else 657 - *trend = THERMAL_TREND_STABLE; 658 - } else if (temp < trip_temp) { 659 - *trend = THERMAL_TREND_DROPPING; 660 - } else { 661 - *trend = THERMAL_TREND_STABLE; 662 - } 663 - 664 - return 0; 665 - } 666 - 667 636 static void thermal_irq_enable(struct tegra_thermctl_zone *zn) 668 637 { 669 638 u32 r; ··· 685 716 static const struct thermal_zone_of_device_ops tegra_of_thermal_ops = { 686 717 .get_temp = tegra_thermctl_get_temp, 687 718 .set_trip_temp = tegra_thermctl_set_trip_temp, 688 - .get_trend = tegra_thermctl_get_trend, 689 719 .set_trips = tegra_thermctl_set_trips, 690 720 }; 691 721
+1 -1
drivers/thermal/tegra/tegra30-tsensor.c
··· 316 316 *hot_trip = 85000; 317 317 *crit_trip = 90000; 318 318 319 - for (i = 0; i < tzd->trips; i++) { 319 + for (i = 0; i < tzd->num_trips; i++) { 320 320 enum thermal_trip_type type; 321 321 int trip_temp; 322 322
+47 -32
drivers/thermal/thermal_core.c
··· 340 340 EXPORT_SYMBOL(thermal_zone_device_critical); 341 341 342 342 static void handle_critical_trips(struct thermal_zone_device *tz, 343 - int trip, enum thermal_trip_type trip_type) 343 + int trip, int trip_temp, enum thermal_trip_type trip_type) 344 344 { 345 - int trip_temp; 346 - 347 - tz->ops->get_trip_temp(tz, trip, &trip_temp); 348 - 349 345 /* If we have not crossed the trip_temp, we do not care. */ 350 346 if (trip_temp <= 0 || tz->temperature < trip_temp) 351 347 return; ··· 380 384 } 381 385 382 386 if (type == THERMAL_TRIP_CRITICAL || type == THERMAL_TRIP_HOT) 383 - handle_critical_trips(tz, trip, type); 387 + handle_critical_trips(tz, trip, trip_temp, type); 384 388 else 385 389 handle_non_critical_trips(tz, trip); 386 390 /* ··· 501 505 502 506 tz->notify_event = event; 503 507 504 - for (count = 0; count < tz->trips; count++) 508 + for (count = 0; count < tz->num_trips; count++) 505 509 handle_thermal_trip(tz, count); 506 510 } 507 511 EXPORT_SYMBOL_GPL(thermal_zone_device_update); ··· 626 630 unsigned long max_state; 627 631 int result, ret; 628 632 629 - if (trip >= tz->trips || trip < 0) 633 + if (trip >= tz->num_trips || trip < 0) 630 634 return -EINVAL; 631 635 632 636 list_for_each_entry(pos1, &thermal_tz_list, node) { ··· 663 667 dev->target = THERMAL_NO_TARGET; 664 668 dev->weight = weight; 665 669 666 - result = ida_simple_get(&tz->ida, 0, 0, GFP_KERNEL); 670 + result = ida_alloc(&tz->ida, GFP_KERNEL); 667 671 if (result < 0) 668 672 goto free_mem; 669 673 ··· 717 721 remove_symbol_link: 718 722 sysfs_remove_link(&tz->device.kobj, dev->name); 719 723 release_ida: 720 - ida_simple_remove(&tz->ida, dev->id); 724 + ida_free(&tz->ida, dev->id); 721 725 free_mem: 722 726 kfree(dev); 723 727 return result; ··· 764 768 device_remove_file(&tz->device, &pos->weight_attr); 765 769 device_remove_file(&tz->device, &pos->attr); 766 770 sysfs_remove_link(&tz->device.kobj, pos->name); 767 - ida_simple_remove(&tz->ida, pos->id); 771 + ida_free(&tz->ida, pos->id); 768 772 kfree(pos); 769 773 return 0; 770 774 } ··· 807 811 { 808 812 int i, ret; 809 813 810 - for (i = 0; i < tz->trips; i++) { 814 + for (i = 0; i < tz->num_trips; i++) { 811 815 if (mask & (1 << i)) { 812 816 unsigned long upper, lower; 813 817 ··· 897 901 if (!cdev) 898 902 return ERR_PTR(-ENOMEM); 899 903 900 - ret = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL); 904 + ret = ida_alloc(&thermal_cdev_ida, GFP_KERNEL); 901 905 if (ret < 0) 902 906 goto out_kfree_cdev; 903 907 cdev->id = ret; ··· 948 952 put_device(&cdev->device); 949 953 cdev = NULL; 950 954 out_ida_remove: 951 - ida_simple_remove(&thermal_cdev_ida, id); 955 + ida_free(&thermal_cdev_ida, id); 952 956 out_kfree_cdev: 953 957 kfree(cdev); 954 958 return ERR_PTR(ret); ··· 1053 1057 { 1054 1058 int i; 1055 1059 1056 - for (i = 0; i < tz->trips; i++) 1060 + for (i = 0; i < tz->num_trips; i++) 1057 1061 if (mask & (1 << i)) 1058 1062 thermal_zone_unbind_cooling_device(tz, i, cdev); 1059 1063 } ··· 1107 1111 1108 1112 mutex_unlock(&thermal_list_lock); 1109 1113 1110 - ida_simple_remove(&thermal_cdev_ida, cdev->id); 1114 + ida_free(&thermal_cdev_ida, cdev->id); 1111 1115 device_del(&cdev->device); 1112 1116 thermal_cooling_device_destroy_sysfs(cdev); 1113 1117 kfree(cdev->type); ··· 1155 1159 mutex_unlock(&thermal_list_lock); 1156 1160 } 1157 1161 1162 + static void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) 1163 + { 1164 + *delay_jiffies = msecs_to_jiffies(delay_ms); 1165 + if (delay_ms > 1000) 1166 + *delay_jiffies = round_jiffies(*delay_jiffies); 1167 + } 1168 + 1158 1169 /** 1159 - * thermal_zone_device_register() - register a new thermal zone device 1170 + * thermal_zone_device_register_with_trips() - register a new thermal zone device 1160 1171 * @type: the thermal zone device type 1161 - * @trips: the number of trip points the thermal zone support 1172 + * @trips: a pointer to an array of thermal trips 1173 + * @num_trips: the number of trip points the thermal zone support 1162 1174 * @mask: a bit string indicating the writeablility of trip points 1163 1175 * @devdata: private device data 1164 1176 * @ops: standard thermal zone device callbacks ··· 1188 1184 * IS_ERR*() helpers. 1189 1185 */ 1190 1186 struct thermal_zone_device * 1191 - thermal_zone_device_register(const char *type, int trips, int mask, 1192 - void *devdata, struct thermal_zone_device_ops *ops, 1193 - struct thermal_zone_params *tzp, int passive_delay, 1194 - int polling_delay) 1187 + thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *trips, int num_trips, int mask, 1188 + void *devdata, struct thermal_zone_device_ops *ops, 1189 + struct thermal_zone_params *tzp, int passive_delay, 1190 + int polling_delay) 1195 1191 { 1196 1192 struct thermal_zone_device *tz; 1197 1193 enum thermal_trip_type trip_type; ··· 1202 1198 struct thermal_governor *governor; 1203 1199 1204 1200 if (!type || strlen(type) == 0) { 1205 - pr_err("Error: No thermal zone type defined\n"); 1201 + pr_err("No thermal zone type defined\n"); 1206 1202 return ERR_PTR(-EINVAL); 1207 1203 } 1208 1204 1209 1205 if (type && strlen(type) >= THERMAL_NAME_LENGTH) { 1210 - pr_err("Error: Thermal zone name (%s) too long, should be under %d chars\n", 1206 + pr_err("Thermal zone name (%s) too long, should be under %d chars\n", 1211 1207 type, THERMAL_NAME_LENGTH); 1212 1208 return ERR_PTR(-EINVAL); 1213 1209 } 1214 1210 1215 - if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) { 1216 - pr_err("Error: Incorrect number of thermal trips\n"); 1211 + if (num_trips > THERMAL_MAX_TRIPS || num_trips < 0 || mask >> num_trips) { 1212 + pr_err("Incorrect number of thermal trips\n"); 1217 1213 return ERR_PTR(-EINVAL); 1218 1214 } 1219 1215 1220 1216 if (!ops) { 1221 - pr_err("Error: Thermal zone device ops not defined\n"); 1217 + pr_err("Thermal zone device ops not defined\n"); 1222 1218 return ERR_PTR(-EINVAL); 1223 1219 } 1224 1220 1225 - if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) 1221 + if (num_trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) 1226 1222 return ERR_PTR(-EINVAL); 1227 1223 1228 1224 tz = kzalloc(sizeof(*tz), GFP_KERNEL); ··· 1232 1228 INIT_LIST_HEAD(&tz->thermal_instances); 1233 1229 ida_init(&tz->ida); 1234 1230 mutex_init(&tz->lock); 1235 - id = ida_simple_get(&thermal_tz_ida, 0, 0, GFP_KERNEL); 1231 + id = ida_alloc(&thermal_tz_ida, GFP_KERNEL); 1236 1232 if (id < 0) { 1237 1233 result = id; 1238 1234 goto free_tz; ··· 1253 1249 tz->device.class = &thermal_class; 1254 1250 tz->devdata = devdata; 1255 1251 tz->trips = trips; 1252 + tz->num_trips = num_trips; 1256 1253 1257 1254 thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay); 1258 1255 thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay); ··· 1271 1266 if (result) 1272 1267 goto release_device; 1273 1268 1274 - for (count = 0; count < trips; count++) { 1269 + for (count = 0; count < num_trips; count++) { 1275 1270 if (tz->ops->get_trip_type(tz, count, &trip_type) || 1276 1271 tz->ops->get_trip_temp(tz, count, &trip_temp) || 1277 1272 !trip_temp) ··· 1324 1319 put_device(&tz->device); 1325 1320 tz = NULL; 1326 1321 remove_id: 1327 - ida_simple_remove(&thermal_tz_ida, id); 1322 + ida_free(&thermal_tz_ida, id); 1328 1323 free_tz: 1329 1324 kfree(tz); 1330 1325 return ERR_PTR(result); 1326 + } 1327 + 1328 + struct thermal_zone_device *thermal_zone_device_register(const char *type, int ntrips, int mask, 1329 + void *devdata, struct thermal_zone_device_ops *ops, 1330 + struct thermal_zone_params *tzp, int passive_delay, 1331 + int polling_delay) 1332 + { 1333 + return thermal_zone_device_register_with_trips(type, NULL, ntrips, mask, 1334 + devdata, ops, tzp, 1335 + passive_delay, polling_delay); 1331 1336 } 1332 1337 EXPORT_SYMBOL_GPL(thermal_zone_device_register); 1333 1338 ··· 1394 1379 thermal_set_governor(tz, NULL); 1395 1380 1396 1381 thermal_remove_hwmon_sysfs(tz); 1397 - ida_simple_remove(&thermal_tz_ida, tz->id); 1382 + ida_free(&thermal_tz_ida, tz->id); 1398 1383 ida_destroy(&tz->ida); 1399 1384 mutex_destroy(&tz->lock); 1400 1385 device_unregister(&tz->device);
-15
drivers/thermal/thermal_core.h
··· 68 68 void thermal_cdev_update(struct thermal_cooling_device *); 69 69 void __thermal_cdev_update(struct thermal_cooling_device *cdev); 70 70 71 - /** 72 - * struct thermal_trip - representation of a point in temperature domain 73 - * @np: pointer to struct device_node that this trip point was created from 74 - * @temperature: temperature value in miliCelsius 75 - * @hysteresis: relative hysteresis in miliCelsius 76 - * @type: trip point type 77 - */ 78 - struct thermal_trip { 79 - struct device_node *np; 80 - int temperature; 81 - int hysteresis; 82 - enum thermal_trip_type type; 83 - }; 84 - 85 71 int get_tz_trend(struct thermal_zone_device *tz, int trip); 86 72 87 73 struct thermal_instance * ··· 112 126 113 127 /* Helpers */ 114 128 void thermal_zone_set_trips(struct thermal_zone_device *tz); 115 - void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms); 116 129 117 130 /* sysfs I/F */ 118 131 int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
+2 -11
drivers/thermal/thermal_helpers.c
··· 39 39 40 40 return trend; 41 41 } 42 - EXPORT_SYMBOL(get_tz_trend); 43 42 44 43 struct thermal_instance * 45 44 get_thermal_instance(struct thermal_zone_device *tz, ··· 89 90 ret = tz->ops->get_temp(tz, temp); 90 91 91 92 if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) { 92 - for (count = 0; count < tz->trips; count++) { 93 + for (count = 0; count < tz->num_trips; count++) { 93 94 ret = tz->ops->get_trip_type(tz, count, &type); 94 95 if (!ret && type == THERMAL_TRIP_CRITICAL) { 95 96 ret = tz->ops->get_trip_temp(tz, count, ··· 137 138 if (!tz->ops->set_trips || !tz->ops->get_trip_hyst) 138 139 goto exit; 139 140 140 - for (i = 0; i < tz->trips; i++) { 141 + for (i = 0; i < tz->num_trips; i++) { 141 142 int trip_low; 142 143 143 144 tz->ops->get_trip_temp(tz, i, &trip_temp); ··· 172 173 173 174 exit: 174 175 mutex_unlock(&tz->lock); 175 - } 176 - 177 - void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms) 178 - { 179 - *delay_jiffies = msecs_to_jiffies(delay_ms); 180 - if (delay_ms > 1000) 181 - *delay_jiffies = round_jiffies(*delay_jiffies); 182 176 } 183 177 184 178 static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev, ··· 220 228 } 221 229 mutex_unlock(&cdev->lock); 222 230 } 223 - EXPORT_SYMBOL(thermal_cdev_update); 224 231 225 232 /** 226 233 * thermal_zone_get_slope - return the slope attribute of the thermal zone
+1 -1
drivers/thermal/thermal_netlink.c
··· 469 469 470 470 mutex_lock(&tz->lock); 471 471 472 - for (i = 0; i < tz->trips; i++) { 472 + for (i = 0; i < tz->num_trips; i++) { 473 473 474 474 enum thermal_trip_type type; 475 475 int temp, hyst = 0;
+111 -90
drivers/thermal/thermal_of.c
··· 118 118 */ 119 119 int of_thermal_get_ntrips(struct thermal_zone_device *tz) 120 120 { 121 - struct __thermal_zone *data = tz->devdata; 122 - 123 - if (!data || IS_ERR(data)) 124 - return -ENODEV; 125 - 126 - return data->ntrips; 121 + return tz->num_trips; 127 122 } 128 123 EXPORT_SYMBOL_GPL(of_thermal_get_ntrips); 129 124 ··· 134 139 */ 135 140 bool of_thermal_is_trip_valid(struct thermal_zone_device *tz, int trip) 136 141 { 137 - struct __thermal_zone *data = tz->devdata; 138 - 139 - if (!data || trip >= data->ntrips || trip < 0) 142 + if (trip >= tz->num_trips || trip < 0) 140 143 return false; 141 144 142 145 return true; ··· 154 161 const struct thermal_trip * 155 162 of_thermal_get_trip_points(struct thermal_zone_device *tz) 156 163 { 157 - struct __thermal_zone *data = tz->devdata; 158 - 159 - if (!data) 160 - return NULL; 161 - 162 - return data->trips; 164 + return tz->trips; 163 165 } 164 166 EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); 165 167 ··· 269 281 static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip, 270 282 enum thermal_trip_type *type) 271 283 { 272 - struct __thermal_zone *data = tz->devdata; 273 - 274 - if (trip >= data->ntrips || trip < 0) 284 + if (trip >= tz->num_trips || trip < 0) 275 285 return -EDOM; 276 286 277 - *type = data->trips[trip].type; 287 + *type = tz->trips[trip].type; 278 288 279 289 return 0; 280 290 } ··· 280 294 static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip, 281 295 int *temp) 282 296 { 283 - struct __thermal_zone *data = tz->devdata; 284 - 285 - if (trip >= data->ntrips || trip < 0) 297 + if (trip >= tz->num_trips || trip < 0) 286 298 return -EDOM; 287 299 288 - *temp = data->trips[trip].temperature; 300 + *temp = tz->trips[trip].temperature; 289 301 290 302 return 0; 291 303 } ··· 293 309 { 294 310 struct __thermal_zone *data = tz->devdata; 295 311 296 - if (trip >= data->ntrips || trip < 0) 312 + if (trip >= tz->num_trips || trip < 0) 297 313 return -EDOM; 298 314 299 315 if (data->ops && data->ops->set_trip_temp) { ··· 305 321 } 306 322 307 323 /* thermal framework should take care of data->mask & (1 << trip) */ 308 - data->trips[trip].temperature = temp; 324 + tz->trips[trip].temperature = temp; 309 325 310 326 return 0; 311 327 } ··· 313 329 static int of_thermal_get_trip_hyst(struct thermal_zone_device *tz, int trip, 314 330 int *hyst) 315 331 { 316 - struct __thermal_zone *data = tz->devdata; 317 - 318 - if (trip >= data->ntrips || trip < 0) 332 + if (trip >= tz->num_trips || trip < 0) 319 333 return -EDOM; 320 334 321 - *hyst = data->trips[trip].hysteresis; 335 + *hyst = tz->trips[trip].hysteresis; 322 336 323 337 return 0; 324 338 } ··· 324 342 static int of_thermal_set_trip_hyst(struct thermal_zone_device *tz, int trip, 325 343 int hyst) 326 344 { 327 - struct __thermal_zone *data = tz->devdata; 328 - 329 - if (trip >= data->ntrips || trip < 0) 345 + if (trip >= tz->num_trips || trip < 0) 330 346 return -EDOM; 331 347 332 348 /* thermal framework should take care of data->mask & (1 << trip) */ 333 - data->trips[trip].hysteresis = hyst; 349 + tz->trips[trip].hysteresis = hyst; 334 350 335 351 return 0; 336 352 } ··· 336 356 static int of_thermal_get_crit_temp(struct thermal_zone_device *tz, 337 357 int *temp) 338 358 { 339 - struct __thermal_zone *data = tz->devdata; 340 359 int i; 341 360 342 - for (i = 0; i < data->ntrips; i++) 343 - if (data->trips[i].type == THERMAL_TRIP_CRITICAL) { 344 - *temp = data->trips[i].temperature; 361 + for (i = 0; i < tz->num_trips; i++) 362 + if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) { 363 + *temp = tz->trips[i].temperature; 345 364 return 0; 346 365 } 347 366 ··· 650 671 651 672 /*** functions parsing device tree nodes ***/ 652 673 674 + static int of_find_trip_id(struct device_node *np, struct device_node *trip) 675 + { 676 + struct device_node *trips; 677 + struct device_node *t; 678 + int i = 0; 679 + 680 + trips = of_get_child_by_name(np, "trips"); 681 + if (!trips) { 682 + pr_err("Failed to find 'trips' node\n"); 683 + return -EINVAL; 684 + } 685 + 686 + /* 687 + * Find the trip id point associated with the cooling device map 688 + */ 689 + for_each_child_of_node(trips, t) { 690 + 691 + if (t == trip) 692 + goto out; 693 + i++; 694 + } 695 + 696 + i = -ENXIO; 697 + out: 698 + of_node_put(trips); 699 + 700 + return i; 701 + } 702 + 653 703 /** 654 704 * thermal_of_populate_bind_params - parse and fill cooling map data 655 705 * @np: DT node containing a cooling-map node ··· 693 685 * 694 686 * Return: 0 on success, proper error code otherwise 695 687 */ 696 - static int thermal_of_populate_bind_params(struct device_node *np, 697 - struct __thermal_bind_params *__tbp, 698 - struct thermal_trip *trips, 699 - int ntrips) 688 + static int thermal_of_populate_bind_params(struct device_node *tz_np, 689 + struct device_node *np, 690 + struct __thermal_bind_params *__tbp) 700 691 { 701 692 struct of_phandle_args cooling_spec; 702 693 struct __thermal_cooling_bind_param *__tcbp; 703 694 struct device_node *trip; 704 695 int ret, i, count; 696 + int trip_id; 705 697 u32 prop; 706 698 707 699 /* Default weight. Usage is optional */ ··· 716 708 return -ENODEV; 717 709 } 718 710 719 - /* match using device_node */ 720 - for (i = 0; i < ntrips; i++) 721 - if (trip == trips[i].np) { 722 - __tbp->trip_id = i; 723 - break; 724 - } 725 - 726 - if (i == ntrips) { 727 - ret = -ENODEV; 711 + trip_id = of_find_trip_id(tz_np, trip); 712 + if (trip_id < 0) { 713 + ret = trip_id; 728 714 goto end; 729 715 } 716 + 717 + __tbp->trip_id = trip_id; 730 718 731 719 count = of_count_phandle_with_args(np, "cooling-device", 732 720 "#cooling-cells"); ··· 847 843 return ret; 848 844 } 849 845 850 - /* Required for cooling map matching */ 851 - trip->np = np; 852 - of_node_get(np); 853 - 854 846 return 0; 847 + } 848 + 849 + static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips) 850 + { 851 + struct thermal_trip *tt; 852 + struct device_node *trips, *trip; 853 + int ret, count; 854 + 855 + trips = of_get_child_by_name(np, "trips"); 856 + if (!trips) { 857 + pr_err("Failed to find 'trips' node\n"); 858 + return ERR_PTR(-EINVAL); 859 + } 860 + 861 + count = of_get_child_count(trips); 862 + if (!count) { 863 + pr_err("No trip point defined\n"); 864 + ret = -EINVAL; 865 + goto out_of_node_put; 866 + } 867 + 868 + tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); 869 + if (!tt) { 870 + ret = -ENOMEM; 871 + goto out_of_node_put; 872 + } 873 + 874 + *ntrips = count; 875 + 876 + count = 0; 877 + for_each_child_of_node(trips, trip) { 878 + ret = thermal_of_populate_trip(trip, &tt[count++]); 879 + if (ret) 880 + goto out_kfree; 881 + } 882 + 883 + of_node_put(trips); 884 + 885 + return tt; 886 + 887 + out_kfree: 888 + kfree(tt); 889 + *ntrips = 0; 890 + out_of_node_put: 891 + of_node_put(trips); 892 + 893 + return ERR_PTR(ret); 855 894 } 856 895 857 896 /** ··· 956 909 tz->offset = 0; 957 910 } 958 911 959 - /* trips */ 960 - child = of_get_child_by_name(np, "trips"); 961 - 962 - /* No trips provided */ 963 - if (!child) 912 + tz->trips = thermal_of_trips_init(np, &tz->ntrips); 913 + if (IS_ERR(tz->trips)) { 914 + ret = PTR_ERR(tz->trips); 964 915 goto finish; 965 - 966 - tz->ntrips = of_get_child_count(child); 967 - if (tz->ntrips == 0) /* must have at least one child */ 968 - goto finish; 969 - 970 - tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); 971 - if (!tz->trips) { 972 - ret = -ENOMEM; 973 - goto free_tz; 974 916 } 975 - 976 - i = 0; 977 - for_each_child_of_node(child, gchild) { 978 - ret = thermal_of_populate_trip(gchild, &tz->trips[i++]); 979 - if (ret) 980 - goto free_trips; 981 - } 982 - 983 - of_node_put(child); 984 917 985 918 /* cooling-maps */ 986 919 child = of_get_child_by_name(np, "cooling-maps"); ··· 981 954 982 955 i = 0; 983 956 for_each_child_of_node(child, gchild) { 984 - ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], 985 - tz->trips, tz->ntrips); 986 - if (ret) 957 + ret = thermal_of_populate_bind_params(np, gchild, &tz->tbps[i++]); 958 + if (ret) { 959 + of_node_put(gchild); 987 960 goto free_tbps; 961 + } 988 962 } 989 963 990 964 finish: ··· 1006 978 1007 979 kfree(tz->tbps); 1008 980 free_trips: 1009 - for (i = 0; i < tz->ntrips; i++) 1010 - of_node_put(tz->trips[i].np); 1011 981 kfree(tz->trips); 1012 - of_node_put(gchild); 1013 982 free_tz: 1014 983 kfree(tz); 1015 984 of_node_put(child); ··· 1029 1004 } 1030 1005 1031 1006 kfree(tz->tbps); 1032 - for (i = 0; i < tz->ntrips; i++) 1033 - of_node_put(tz->trips[i].np); 1034 1007 kfree(tz->trips); 1035 1008 kfree(tz); 1036 1009 } ··· 1126 1103 tzp->slope = tz->slope; 1127 1104 tzp->offset = tz->offset; 1128 1105 1129 - zone = thermal_zone_device_register(child->name, tz->ntrips, 1130 - mask, tz, 1131 - ops, tzp, 1132 - tz->passive_delay, 1133 - tz->polling_delay); 1106 + zone = thermal_zone_device_register_with_trips(child->name, tz->trips, tz->ntrips, 1107 + mask, tz, ops, tzp, tz->passive_delay, 1108 + tz->polling_delay); 1134 1109 if (IS_ERR(zone)) { 1135 1110 pr_err("Failed to build %pOFn zone %ld\n", child, 1136 1111 PTR_ERR(zone));
+11 -11
drivers/thermal/thermal_sysfs.c
··· 416 416 int indx; 417 417 418 418 /* This function works only for zones with at least one trip */ 419 - if (tz->trips <= 0) 419 + if (tz->num_trips <= 0) 420 420 return -EINVAL; 421 421 422 - tz->trip_type_attrs = kcalloc(tz->trips, sizeof(*tz->trip_type_attrs), 422 + tz->trip_type_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_type_attrs), 423 423 GFP_KERNEL); 424 424 if (!tz->trip_type_attrs) 425 425 return -ENOMEM; 426 426 427 - tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs), 427 + tz->trip_temp_attrs = kcalloc(tz->num_trips, sizeof(*tz->trip_temp_attrs), 428 428 GFP_KERNEL); 429 429 if (!tz->trip_temp_attrs) { 430 430 kfree(tz->trip_type_attrs); ··· 432 432 } 433 433 434 434 if (tz->ops->get_trip_hyst) { 435 - tz->trip_hyst_attrs = kcalloc(tz->trips, 435 + tz->trip_hyst_attrs = kcalloc(tz->num_trips, 436 436 sizeof(*tz->trip_hyst_attrs), 437 437 GFP_KERNEL); 438 438 if (!tz->trip_hyst_attrs) { ··· 442 442 } 443 443 } 444 444 445 - attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); 445 + attrs = kcalloc(tz->num_trips * 3 + 1, sizeof(*attrs), GFP_KERNEL); 446 446 if (!attrs) { 447 447 kfree(tz->trip_type_attrs); 448 448 kfree(tz->trip_temp_attrs); ··· 451 451 return -ENOMEM; 452 452 } 453 453 454 - for (indx = 0; indx < tz->trips; indx++) { 454 + for (indx = 0; indx < tz->num_trips; indx++) { 455 455 /* create trip type attribute */ 456 456 snprintf(tz->trip_type_attrs[indx].name, THERMAL_NAME_LENGTH, 457 457 "trip_point_%d_type", indx); ··· 478 478 tz->trip_temp_attrs[indx].attr.store = 479 479 trip_point_temp_store; 480 480 } 481 - attrs[indx + tz->trips] = &tz->trip_temp_attrs[indx].attr.attr; 481 + attrs[indx + tz->num_trips] = &tz->trip_temp_attrs[indx].attr.attr; 482 482 483 483 /* create Optional trip hyst attribute */ 484 484 if (!tz->ops->get_trip_hyst) ··· 496 496 tz->trip_hyst_attrs[indx].attr.store = 497 497 trip_point_hyst_store; 498 498 } 499 - attrs[indx + tz->trips * 2] = 499 + attrs[indx + tz->num_trips * 2] = 500 500 &tz->trip_hyst_attrs[indx].attr.attr; 501 501 } 502 - attrs[tz->trips * 3] = NULL; 502 + attrs[tz->num_trips * 3] = NULL; 503 503 504 504 tz->trips_attribute_group.attrs = attrs; 505 505 ··· 540 540 for (i = 0; i < size - 2; i++) 541 541 groups[i] = thermal_zone_attribute_groups[i]; 542 542 543 - if (tz->trips) { 543 + if (tz->num_trips) { 544 544 result = create_trip_attrs(tz, mask); 545 545 if (result) { 546 546 kfree(groups); ··· 561 561 if (!tz) 562 562 return; 563 563 564 - if (tz->trips) 564 + if (tz->num_trips) 565 565 destroy_trip_attrs(tz); 566 566 567 567 kfree(tz->device.groups);
+1 -1
drivers/thermal/ti-soc-thermal/ti-bandgap.c
··· 226 226 /* 227 227 * One TALERT interrupt: Two sources 228 228 * If the interrupt is due to t_hot then mask t_hot and 229 - * and unmask t_cold else mask t_cold and unmask t_hot 229 + * unmask t_cold else mask t_cold and unmask t_hot 230 230 */ 231 231 if (t_hot) { 232 232 ctrl &= ~tsr->mask_hot_mask;
+22 -4
include/linux/thermal.h
··· 40 40 THERMAL_TREND_STABLE, /* temperature is stable */ 41 41 THERMAL_TREND_RAISING, /* temperature is raising */ 42 42 THERMAL_TREND_DROPPING, /* temperature is dropping */ 43 - THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */ 44 - THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */ 45 43 }; 46 44 47 45 /* Thermal notification reason */ ··· 78 80 void (*critical)(struct thermal_zone_device *); 79 81 }; 80 82 83 + /** 84 + * struct thermal_trip - representation of a point in temperature domain 85 + * @temperature: temperature value in miliCelsius 86 + * @hysteresis: relative hysteresis in miliCelsius 87 + * @type: trip point type 88 + */ 89 + struct thermal_trip { 90 + int temperature; 91 + int hysteresis; 92 + enum thermal_trip_type type; 93 + }; 94 + 81 95 struct thermal_cooling_device_ops { 82 96 int (*get_max_state) (struct thermal_cooling_device *, unsigned long *); 83 97 int (*get_cur_state) (struct thermal_cooling_device *, unsigned long *); ··· 123 113 * @trip_hyst_attrs: attributes for trip points for sysfs: trip hysteresis 124 114 * @mode: current mode of this thermal zone 125 115 * @devdata: private pointer for device private data 126 - * @trips: number of trip points the thermal zone supports 116 + * @trips: an array of struct thermal_trip 117 + * @num_trips: number of trip points the thermal zone supports 127 118 * @trips_disabled; bitmap for disabled trips 128 119 * @passive_delay_jiffies: number of jiffies to wait between polls when 129 120 * performing passive cooling. ··· 164 153 struct thermal_attr *trip_hyst_attrs; 165 154 enum thermal_device_mode mode; 166 155 void *devdata; 167 - int trips; 156 + struct thermal_trip *trips; 157 + int num_trips; 168 158 unsigned long trips_disabled; /* bitmap for disabled trips */ 169 159 unsigned long passive_delay_jiffies; 170 160 unsigned long polling_delay_jiffies; ··· 378 366 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, 379 367 void *, struct thermal_zone_device_ops *, 380 368 struct thermal_zone_params *, int, int); 369 + 381 370 void thermal_zone_device_unregister(struct thermal_zone_device *); 371 + 372 + struct thermal_zone_device * 373 + thermal_zone_device_register_with_trips(const char *, struct thermal_trip *, int, int, 374 + void *, struct thermal_zone_device_ops *, 375 + struct thermal_zone_params *, int, int); 382 376 383 377 int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int, 384 378 struct thermal_cooling_device *,
+8 -20
include/trace/events/thermal.h
··· 92 92 ); 93 93 94 94 #ifdef CONFIG_CPU_THERMAL 95 - TRACE_EVENT(thermal_power_cpu_get_power, 96 - TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load, 97 - size_t load_len, u32 dynamic_power), 95 + TRACE_EVENT(thermal_power_cpu_get_power_simple, 96 + TP_PROTO(int cpu, u32 power), 98 97 99 - TP_ARGS(cpus, freq, load, load_len, dynamic_power), 98 + TP_ARGS(cpu, power), 100 99 101 100 TP_STRUCT__entry( 102 - __bitmask(cpumask, num_possible_cpus()) 103 - __field(unsigned long, freq ) 104 - __dynamic_array(u32, load, load_len) 105 - __field(size_t, load_len ) 106 - __field(u32, dynamic_power ) 101 + __field(int, cpu) 102 + __field(u32, power) 107 103 ), 108 104 109 105 TP_fast_assign( 110 - __assign_bitmask(cpumask, cpumask_bits(cpus), 111 - num_possible_cpus()); 112 - __entry->freq = freq; 113 - memcpy(__get_dynamic_array(load), load, 114 - load_len * sizeof(*load)); 115 - __entry->load_len = load_len; 116 - __entry->dynamic_power = dynamic_power; 106 + __entry->cpu = cpu; 107 + __entry->power = power; 117 108 ), 118 109 119 - TP_printk("cpus=%s freq=%lu load={%s} dynamic_power=%d", 120 - __get_bitmask(cpumask), __entry->freq, 121 - __print_array(__get_dynamic_array(load), __entry->load_len, 4), 122 - __entry->dynamic_power) 110 + TP_printk("cpu=%d power=%u", __entry->cpu, __entry->power) 123 111 ); 124 112 125 113 TRACE_EVENT(thermal_power_cpu_limit,
+1 -1
tools/thermal/tmon/pid.c
··· 27 27 28 28 /************************************************************************** 29 29 * PID (Proportional-Integral-Derivative) controller is commonly used in 30 - * linear control system, consider the the process. 30 + * linear control system, consider the process. 31 31 * G(s) = U(s)/E(s) 32 32 * kp = proportional gain 33 33 * ki = integral gain
+3
tools/thermal/tmon/tmon.h
··· 27 27 #define NR_LINES_TZDATA 1 28 28 #define TMON_LOG_FILE "/var/tmp/tmon.log" 29 29 30 + #include <sys/time.h> 31 + #include <pthread.h> 32 + 30 33 extern unsigned long ticktime; 31 34 extern double time_elapsed; 32 35 extern unsigned long target_temp_user;