Skip to content

Commit 92b459d

Browse files
committed
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
2 parents 64e6fc2 + 4dc333c commit 92b459d

File tree

6 files changed

+34
-64
lines changed

6 files changed

+34
-64
lines changed

drivers/thermal/gov_power_allocator.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,15 @@ static void allow_maximum_power(struct thermal_zone_device *tz)
588588
static int check_power_actors(struct thermal_zone_device *tz,
589589
struct power_allocator_params *params)
590590
{
591-
const struct thermal_trip_desc *td = trip_to_trip_desc(params->trip_max);
591+
const struct thermal_trip_desc *td;
592592
struct thermal_instance *instance;
593593
int ret = 0;
594594

595+
if (!params->trip_max)
596+
return 0;
597+
598+
td = trip_to_trip_desc(params->trip_max);
599+
595600
list_for_each_entry(instance, &td->thermal_instances, trip_node) {
596601
if (!cdev_is_power_actor(instance->cdev)) {
597602
dev_warn(&tz->device, "power_allocator: %s is not a power actor\n",

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ struct odvp_attr {
7575

7676
static BIN_ATTR_SIMPLE_RO(data_vault);
7777

78-
static struct bin_attribute *data_attributes[] = {
79-
&bin_attr_data_vault,
80-
NULL,
81-
};
82-
8378
static ssize_t imok_store(struct device *dev, struct device_attribute *attr,
8479
const char *buf, size_t count)
8580
{
@@ -108,10 +103,6 @@ static const struct attribute_group imok_attribute_group = {
108103
.attrs = imok_attr,
109104
};
110105

111-
static const struct attribute_group data_attribute_group = {
112-
.bin_attrs = data_attributes,
113-
};
114-
115106
static ssize_t available_uuids_show(struct device *dev,
116107
struct device_attribute *attr,
117108
char *buf)
@@ -137,7 +128,7 @@ static ssize_t current_uuid_show(struct device *dev,
137128
struct int3400_thermal_priv *priv = dev_get_drvdata(dev);
138129
int i, length = 0;
139130

140-
if (priv->current_uuid_index > 0)
131+
if (priv->current_uuid_index >= 0)
141132
return sprintf(buf, "%s\n",
142133
int3400_thermal_uuids[priv->current_uuid_index]);
143134

@@ -624,8 +615,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
624615
}
625616

626617
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
627-
result = sysfs_create_group(&pdev->dev.kobj,
628-
&data_attribute_group);
618+
result = device_create_bin_file(&pdev->dev, &bin_attr_data_vault);
629619
if (result)
630620
goto free_uuid;
631621
}
@@ -648,7 +638,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
648638
free_sysfs:
649639
cleanup_odvp(priv);
650640
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
651-
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
641+
device_remove_bin_file(&pdev->dev, &bin_attr_data_vault);
652642
kfree(priv->data_vault);
653643
}
654644
free_uuid:
@@ -683,7 +673,7 @@ static void int3400_thermal_remove(struct platform_device *pdev)
683673
acpi_thermal_rel_misc_device_remove(priv->adev->handle);
684674

685675
if (!ZERO_OR_NULL_PTR(priv->data_vault))
686-
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
676+
device_remove_bin_file(&pdev->dev, &bin_attr_data_vault);
687677
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
688678
sysfs_remove_group(&pdev->dev.kobj, &imok_attribute_group);
689679
thermal_zone_device_unregister(priv->thermal);

drivers/thermal/qcom/qcom-spmi-adc-tm5.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,6 @@ static const struct adc_tm5_data adc_tm5_gen2_data_pmic = {
938938
static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *node)
939939
{
940940
struct adc_tm5_channel *channels;
941-
struct device_node *child;
942941
u32 value;
943942
int ret;
944943
struct device *dev = adc_tm->dev;
@@ -982,12 +981,10 @@ static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *
982981
adc_tm->avg_samples = VADC_DEF_AVG_SAMPLES;
983982
}
984983

985-
for_each_available_child_of_node(node, child) {
984+
for_each_available_child_of_node_scoped(node, child) {
986985
ret = adc_tm5_get_dt_channel_data(adc_tm, channels, child);
987-
if (ret) {
988-
of_node_put(child);
986+
if (ret)
989987
return ret;
990-
}
991988

992989
channels++;
993990
}

drivers/thermal/sun8i_thermal.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/bitmap.h>
12+
#include <linux/cleanup.h>
1213
#include <linux/clk.h>
1314
#include <linux/device.h>
1415
#include <linux/interrupt.h>
@@ -348,19 +349,18 @@ static void sun8i_ths_reset_control_assert(void *data)
348349

349350
static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
350351
{
351-
struct device_node *sram_node;
352352
struct platform_device *sram_pdev;
353353
struct regmap *regmap = NULL;
354354

355-
sram_node = of_parse_phandle(node, "allwinner,sram", 0);
355+
struct device_node *sram_node __free(device_node) =
356+
of_parse_phandle(node, "allwinner,sram", 0);
356357
if (!sram_node)
357358
return ERR_PTR(-ENODEV);
358359

359360
sram_pdev = of_find_device_by_node(sram_node);
360361
if (!sram_pdev) {
361362
/* platform device might not be probed yet */
362-
regmap = ERR_PTR(-EPROBE_DEFER);
363-
goto out_put_node;
363+
return ERR_PTR(-EPROBE_DEFER);
364364
}
365365

366366
/* If no regmap is found then the other device driver is at fault */
@@ -369,8 +369,7 @@ static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node)
369369
regmap = ERR_PTR(-EINVAL);
370370

371371
platform_device_put(sram_pdev);
372-
out_put_node:
373-
of_node_put(sram_node);
372+
374373
return regmap;
375374
}
376375

drivers/thermal/tegra/soctherm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
16511651
{
16521652
struct device *dev = &pdev->dev;
16531653
struct tegra_soctherm *ts = dev_get_drvdata(dev);
1654-
struct device_node *np_stc, *np_stcc;
1654+
struct device_node *np_stc;
16551655
const char *name;
16561656
int i;
16571657

@@ -1668,7 +1668,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
16681668
return;
16691669
}
16701670

1671-
for_each_child_of_node(np_stc, np_stcc) {
1671+
for_each_child_of_node_scoped(np_stc, np_stcc) {
16721672
struct soctherm_throt_cfg *stc;
16731673
struct thermal_cooling_device *tcd;
16741674
int err;
@@ -1683,7 +1683,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
16831683

16841684
if (stc->init) {
16851685
dev_err(dev, "throttle-cfg: %s: redefined!\n", name);
1686-
of_node_put(np_stcc);
16871686
break;
16881687
}
16891688

drivers/thermal/thermal_of.c

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,53 +95,39 @@ static int thermal_of_populate_trip(struct device_node *np,
9595

9696
static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips)
9797
{
98-
struct thermal_trip *tt;
99-
struct device_node *trips;
10098
int ret, count;
10199

102100
*ntrips = 0;
103101

104-
trips = of_get_child_by_name(np, "trips");
102+
struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips");
105103
if (!trips)
106104
return NULL;
107105

108106
count = of_get_child_count(trips);
109107
if (!count)
110108
return NULL;
111109

112-
tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
113-
if (!tt) {
114-
ret = -ENOMEM;
115-
goto out_of_node_put;
116-
}
117-
118-
*ntrips = count;
110+
struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
111+
if (!tt)
112+
return ERR_PTR(-ENOMEM);
119113

120114
count = 0;
121115
for_each_child_of_node_scoped(trips, trip) {
122116
ret = thermal_of_populate_trip(trip, &tt[count++]);
123117
if (ret)
124-
goto out_kfree;
118+
return ERR_PTR(ret);
125119
}
126120

127-
of_node_put(trips);
128-
129-
return tt;
130-
131-
out_kfree:
132-
kfree(tt);
133-
out_of_node_put:
134-
of_node_put(trips);
121+
*ntrips = count;
135122

136-
return ERR_PTR(ret);
123+
return no_free_ptr(tt);
137124
}
138125

139126
static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id)
140127
{
141-
struct device_node *np, *tz;
142128
struct of_phandle_args sensor_specs;
143129

144-
np = of_find_node_by_name(NULL, "thermal-zones");
130+
struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones");
145131
if (!np) {
146132
pr_debug("No thermal zones description\n");
147133
return ERR_PTR(-ENODEV);
@@ -159,8 +145,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
159145
"#thermal-sensor-cells");
160146
if (count <= 0) {
161147
pr_err("%pOFn: missing thermal sensor\n", child);
162-
tz = ERR_PTR(-EINVAL);
163-
goto out;
148+
return ERR_PTR(-EINVAL);
164149
}
165150

166151
for (i = 0; i < count; i++) {
@@ -172,22 +157,18 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int
172157
i, &sensor_specs);
173158
if (ret < 0) {
174159
pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret);
175-
tz = ERR_PTR(ret);
176-
goto out;
160+
return ERR_PTR(ret);
177161
}
178162

179163
if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ?
180164
sensor_specs.args[0] : 0)) {
181165
pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child);
182-
tz = no_free_ptr(child);
183-
goto out;
166+
return no_free_ptr(child);
184167
}
185168
}
186169
}
187-
tz = ERR_PTR(-ENODEV);
188-
out:
189-
of_node_put(np);
190-
return tz;
170+
171+
return ERR_PTR(-ENODEV);
191172
}
192173

193174
static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelay)
@@ -297,7 +278,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz,
297278
struct thermal_cooling_device *cdev,
298279
struct cooling_spec *c)
299280
{
300-
struct device_node *tz_np, *cm_np, *child;
281+
struct device_node *tz_np, *cm_np;
301282
bool result = false;
302283

303284
tz_np = thermal_of_zone_get_by_name(tz);
@@ -311,7 +292,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz,
311292
goto out;
312293

313294
/* Look up the trip and the cdev in the cooling maps. */
314-
for_each_child_of_node(cm_np, child) {
295+
for_each_child_of_node_scoped(cm_np, child) {
315296
struct device_node *tr_np;
316297
int count, i;
317298

@@ -330,7 +311,6 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz,
330311
break;
331312
}
332313

333-
of_node_put(child);
334314
break;
335315
}
336316

0 commit comments

Comments
 (0)