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

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

Pull more thermal control updates from Rafael Wysocki:
"These fix a Power Allocator thermal governor issue reported recently,
update the Intel int3400 thermal driver and simplify DT data parsing
in the thermal control subsystem:

- Add a NULL pointer check that was missed by recent modifications of
the Power Allocator thermal governor (Rafael Wysocki)

- Remove the data_vault attribute_group from int3400 because it is
only used for exposing one binary file that can be exposed directly
(Thomas Weißschuh)

- Prevent the current_uuid sysfs attribute in int3400 from mistakenly
treating valid UUID values as invalid on some older systems
(Srinivas Pandruvada)

- Use the cleanup.h mechanics to simplify DT data parsing in the
thermal core and some drivers (Krzysztof Kozlowski)"

* tag 'thermal-6.13-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
thermal: sun8i: Use scoped device node handling to simplify error paths
thermal: tegra: Simplify with scoped for each OF child loop
thermal: qcom-spmi-adc-tm5: Simplify with scoped for each OF child loop
thermal: of: Use scoped device node handling to simplify of_thermal_zone_find()
thermal: of: Use scoped memory and OF handling to simplify thermal_of_trips_init()
thermal: of: Simplify thermal_of_should_bind with scoped for each OF child
thermal: gov_power_allocator: Add missing NULL pointer check
thermal: int3400: Remove unneeded data_vault attribute_group
thermal: int3400: Fix reading of current_uuid for active policy

+34 -64
+6 -1
drivers/thermal/gov_power_allocator.c
··· 588 588 static int check_power_actors(struct thermal_zone_device *tz, 589 589 struct power_allocator_params *params) 590 590 { 591 - const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max); 591 + const struct thermal_trip_desc *td; 592 592 struct thermal_instance *instance; 593 593 int ret = 0; 594 + 595 + if (!params->trip_max) 596 + return 0; 597 + 598 + td = trip_to_trip_desc(params->trip_max); 594 599 595 600 list_for_each_entry(instance, &td->thermal_instances, trip_node) { 596 601 if (!cdev_is_power_actor(instance->cdev)) {
+4 -14
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 75 75 76 76 static BIN_ATTR_SIMPLE_RO(data_vault); 77 77 78 - static struct bin_attribute *data_attributes[] = { 79 - &bin_attr_data_vault, 80 - NULL, 81 - }; 82 - 83 78 static ssize_t imok_store(struct device *dev, struct device_attribute *attr, 84 79 const char *buf, size_t count) 85 80 { ··· 103 108 .attrs = imok_attr, 104 109 }; 105 110 106 - static const struct attribute_group data_attribute_group = { 107 - .bin_attrs = data_attributes, 108 - }; 109 - 110 111 static ssize_t available_uuids_show(struct device *dev, 111 112 struct device_attribute *attr, 112 113 char *buf) ··· 128 137 struct int3400_thermal_priv *priv = dev_get_drvdata(dev); 129 138 int i, length = 0; 130 139 131 - if (priv->current_uuid_index > 0) 140 + if (priv->current_uuid_index >= 0) 132 141 return sprintf(buf, "%s\n", 133 142 int3400_thermal_uuids[priv->current_uuid_index]); 134 143 ··· 615 624 } 616 625 617 626 if (!ZERO_OR_NULL_PTR(priv->data_vault)) { 618 - result = sysfs_create_group(&pdev->dev.kobj, 619 - &data_attribute_group); 627 + result = device_create_bin_file(&pdev->dev, &bin_attr_data_vault); 620 628 if (result) 621 629 goto free_uuid; 622 630 } ··· 638 648 free_sysfs: 639 649 cleanup_odvp(priv); 640 650 if (!ZERO_OR_NULL_PTR(priv->data_vault)) { 641 - sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group); 651 + device_remove_bin_file(&pdev->dev, &bin_attr_data_vault); 642 652 kfree(priv->data_vault); 643 653 } 644 654 free_uuid: ··· 673 683 acpi_thermal_rel_misc_device_remove(priv->adev->handle); 674 684 675 685 if (!ZERO_OR_NULL_PTR(priv->data_vault)) 676 - sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group); 686 + device_remove_bin_file(&pdev->dev, &bin_attr_data_vault); 677 687 sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group); 678 688 sysfs_remove_group(&pdev->dev.kobj, &imok_attribute_group); 679 689 thermal_zone_device_unregister(priv->thermal);
+2 -5
drivers/thermal/qcom/qcom-spmi-adc-tm5.c
··· 938 938 static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *node) 939 939 { 940 940 struct adc_tm5_channel *channels; 941 - struct device_node *child; 942 941 u32 value; 943 942 int ret; 944 943 struct device *dev = adc_tm->dev; ··· 981 982 adc_tm->avg_samples = VADC_DEF_AVG_SAMPLES; 982 983 } 983 984 984 - for_each_available_child_of_node(node, child) { 985 + for_each_available_child_of_node_scoped(node, child) { 985 986 ret = adc_tm5_get_dt_channel_data(adc_tm, channels, child); 986 - if (ret) { 987 - of_node_put(child); 987 + if (ret) 988 988 return ret; 989 - } 990 989 991 990 channels++; 992 991 }
+5 -6
drivers/thermal/sun8i_thermal.c
··· 9 9 */ 10 10 11 11 #include <linux/bitmap.h> 12 + #include <linux/cleanup.h> 12 13 #include <linux/clk.h> 13 14 #include <linux/device.h> 14 15 #include <linux/interrupt.h> ··· 349 348 350 349 static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) 351 350 { 352 - struct device_node *sram_node; 353 351 struct platform_device *sram_pdev; 354 352 struct regmap *regmap = NULL; 355 353 356 - sram_node = of_parse_phandle(node, "allwinner,sram", 0); 354 + struct device_node *sram_node __free(device_node) = 355 + of_parse_phandle(node, "allwinner,sram", 0); 357 356 if (!sram_node) 358 357 return ERR_PTR(-ENODEV); 359 358 360 359 sram_pdev = of_find_device_by_node(sram_node); 361 360 if (!sram_pdev) { 362 361 /* platform device might not be probed yet */ 363 - regmap = ERR_PTR(-EPROBE_DEFER); 364 - goto out_put_node; 362 + return ERR_PTR(-EPROBE_DEFER); 365 363 } 366 364 367 365 /* If no regmap is found then the other device driver is at fault */ ··· 369 369 regmap = ERR_PTR(-EINVAL); 370 370 371 371 platform_device_put(sram_pdev); 372 - out_put_node: 373 - of_node_put(sram_node); 372 + 374 373 return regmap; 375 374 } 376 375
+2 -3
drivers/thermal/tegra/soctherm.c
··· 1651 1651 { 1652 1652 struct device *dev = &pdev->dev; 1653 1653 struct tegra_soctherm *ts = dev_get_drvdata(dev); 1654 - struct device_node *np_stc, *np_stcc; 1654 + struct device_node *np_stc; 1655 1655 const char *name; 1656 1656 int i; 1657 1657 ··· 1668 1668 return; 1669 1669 } 1670 1670 1671 - for_each_child_of_node(np_stc, np_stcc) { 1671 + for_each_child_of_node_scoped(np_stc, np_stcc) { 1672 1672 struct soctherm_throt_cfg *stc; 1673 1673 struct thermal_cooling_device *tcd; 1674 1674 int err; ··· 1683 1683 1684 1684 if (stc->init) { 1685 1685 dev_err(dev, "throttle-cfg: %s: redefined!\n", name); 1686 - of_node_put(np_stcc); 1687 1686 break; 1688 1687 } 1689 1688
+15 -35
drivers/thermal/thermal_of.c
··· 95 95 96 96 static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips) 97 97 { 98 - struct thermal_trip *tt; 99 - struct device_node *trips; 100 98 int ret, count; 101 99 102 100 *ntrips = 0; 103 101 104 - trips = of_get_child_by_name(np, "trips"); 102 + struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips"); 105 103 if (!trips) 106 104 return NULL; 107 105 ··· 107 109 if (!count) 108 110 return NULL; 109 111 110 - tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); 111 - if (!tt) { 112 - ret = -ENOMEM; 113 - goto out_of_node_put; 114 - } 115 - 116 - *ntrips = count; 112 + struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL); 113 + if (!tt) 114 + return ERR_PTR(-ENOMEM); 117 115 118 116 count = 0; 119 117 for_each_child_of_node_scoped(trips, trip) { 120 118 ret = thermal_of_populate_trip(trip, &tt[count++]); 121 119 if (ret) 122 - goto out_kfree; 120 + return ERR_PTR(ret); 123 121 } 124 122 125 - of_node_put(trips); 123 + *ntrips = count; 126 124 127 - return tt; 128 - 129 - out_kfree: 130 - kfree(tt); 131 - out_of_node_put: 132 - of_node_put(trips); 133 - 134 - return ERR_PTR(ret); 125 + return no_free_ptr(tt); 135 126 } 136 127 137 128 static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) 138 129 { 139 - struct device_node *np, *tz; 140 130 struct of_phandle_args sensor_specs; 141 131 142 - np = of_find_node_by_name(NULL, "thermal-zones"); 132 + struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones"); 143 133 if (!np) { 144 134 pr_debug("No thermal zones description\n"); 145 135 return ERR_PTR(-ENODEV); ··· 145 159 "#thermal-sensor-cells"); 146 160 if (count <= 0) { 147 161 pr_err("%pOFn: missing thermal sensor\n", child); 148 - tz = ERR_PTR(-EINVAL); 149 - goto out; 162 + return ERR_PTR(-EINVAL); 150 163 } 151 164 152 165 for (i = 0; i < count; i++) { ··· 157 172 i, &sensor_specs); 158 173 if (ret < 0) { 159 174 pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret); 160 - tz = ERR_PTR(ret); 161 - goto out; 175 + return ERR_PTR(ret); 162 176 } 163 177 164 178 if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? 165 179 sensor_specs.args[0] : 0)) { 166 180 pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child); 167 - tz = no_free_ptr(child); 168 - goto out; 181 + return no_free_ptr(child); 169 182 } 170 183 } 171 184 } 172 - tz = ERR_PTR(-ENODEV); 173 - out: 174 - of_node_put(np); 175 - return tz; 185 + 186 + return ERR_PTR(-ENODEV); 176 187 } 177 188 178 189 static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelay) ··· 278 297 struct thermal_cooling_device *cdev, 279 298 struct cooling_spec *c) 280 299 { 281 - struct device_node *tz_np, *cm_np, *child; 300 + struct device_node *tz_np, *cm_np; 282 301 bool result = false; 283 302 284 303 tz_np = thermal_of_zone_get_by_name(tz); ··· 292 311 goto out; 293 312 294 313 /* Look up the trip and the cdev in the cooling maps. */ 295 - for_each_child_of_node(cm_np, child) { 314 + for_each_child_of_node_scoped(cm_np, child) { 296 315 struct device_node *tr_np; 297 316 int count, i; 298 317 ··· 311 330 break; 312 331 } 313 332 314 - of_node_put(child); 315 333 break; 316 334 } 317 335