* [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable
@ 2026-04-24 16:00 Daniel Lezcano
2026-04-24 16:00 ` [PATCH 2/2] thermal/drivers/tegra/soctherma: Switch to devm cooling device registration Daniel Lezcano
2026-05-05 12:10 ` [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Lezcano @ 2026-04-24 16:00 UTC (permalink / raw)
To: rafael, daniel.lezcano, thierry.reding, jonathanh
Cc: rui.zhang, lukasz.luba, linux-pm, linux-tegra
Replace the manual error handling paths disabling the clocks with
devm_add_action_or_reset(). This ensures the clocks are properly
disabled on probe failure and driver removal, while simplifying the
code by removing the explicit error paths.
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/thermal/tegra/soctherm.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 5d26b52beaba..40c3715e84c5 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -1499,6 +1499,13 @@ static int soctherm_clk_enable(struct platform_device *pdev, bool enable)
return 0;
}
+static void soctherm_clk_disable(void *data)
+{
+ struct platform_device *pdev = data;
+
+ soctherm_clk_enable(pdev, false);
+}
+
static int throt_get_cdev_max_state(struct thermal_cooling_device *cdev,
unsigned long *max_state)
{
@@ -2175,6 +2182,10 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
if (err)
return err;
+ err = devm_add_action_or_reset(&pdev->dev, soctherm_clk_disable, pdev);
+ if (err)
+ return err;
+
soctherm_thermtrips_parse(pdev);
soctherm_init_hw_throt_cdev(pdev);
@@ -2184,10 +2195,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
for (i = 0; i < soc->num_ttgs; ++i) {
struct tegra_thermctl_zone *zone =
devm_kzalloc(&pdev->dev, sizeof(*zone), GFP_KERNEL);
- if (!zone) {
- err = -ENOMEM;
- goto disable_clocks;
- }
+ if (!zone)
+ return -ENOMEM;
zone->reg = tegra->regs + soc->ttgs[i]->sensor_temp_offset;
zone->dev = &pdev->dev;
@@ -2201,7 +2210,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
err = PTR_ERR(z);
dev_err(&pdev->dev, "failed to register sensor: %d\n",
err);
- goto disable_clocks;
+ return err;
}
zone->tz = z;
@@ -2210,7 +2219,7 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
/* Configure hw trip points */
err = tegra_soctherm_set_hwtrips(&pdev->dev, soc->ttgs[i], z);
if (err)
- goto disable_clocks;
+ return err;
}
err = soctherm_interrupts_init(pdev, tegra);
@@ -2218,11 +2227,6 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
soctherm_debug_init(pdev);
return 0;
-
-disable_clocks:
- soctherm_clk_enable(pdev, false);
-
- return err;
}
static void tegra_soctherm_remove(struct platform_device *pdev)
@@ -2230,8 +2234,6 @@ static void tegra_soctherm_remove(struct platform_device *pdev)
struct tegra_soctherm *tegra = platform_get_drvdata(pdev);
debugfs_remove_recursive(tegra->debugfs_dir);
-
- soctherm_clk_enable(pdev, false);
}
static int __maybe_unused soctherm_suspend(struct device *dev)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] thermal/drivers/tegra/soctherma: Switch to devm cooling device registration
2026-04-24 16:00 [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
@ 2026-04-24 16:00 ` Daniel Lezcano
2026-05-05 12:10 ` [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
1 sibling, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2026-04-24 16:00 UTC (permalink / raw)
To: rafael, daniel.lezcano, thierry.reding, jonathanh
Cc: rui.zhang, lukasz.luba, linux-pm, linux-tegra
Use devm_thermal_of_cooling_device_register() to simplify resource
management and avoid manual cleanup in error paths.
As a side effect this change has the benefit of solving an existing
issue. Before, the function tegra_soctherm_remove() only called
debugfs_remove_recursive() and never called thermal_cooling_device_unregister()
for any of the cooling devices registered here.
After the driver removal, the thermal framework's cdev list would
still hold references to thermal_cooling_device objects whose devdata
pointer (ts) pointed to memory already freed by the platform device's
devm cleanup.
With this change, the cooling device is unregistered when the driver
is removed, thus fixing the issue above.
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/thermal/tegra/soctherm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 40c3715e84c5..6a56638c98f1 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -1707,9 +1707,9 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
stc->init = true;
} else {
- tcd = thermal_of_cooling_device_register(np_stcc,
- (char *)name, ts,
- &throt_cooling_ops);
+ tcd = devm_thermal_of_cooling_device_register(dev, np_stcc,
+ (char *)name, ts,
+ &throt_cooling_ops);
if (IS_ERR_OR_NULL(tcd)) {
dev_err(dev,
"throttle-cfg: %s: failed to register cooling device\n",
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable
2026-04-24 16:00 [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
2026-04-24 16:00 ` [PATCH 2/2] thermal/drivers/tegra/soctherma: Switch to devm cooling device registration Daniel Lezcano
@ 2026-05-05 12:10 ` Daniel Lezcano
2026-05-06 9:37 ` Daniel Lezcano
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2026-05-05 12:10 UTC (permalink / raw)
To: rafael, daniel.lezcano, thierry.reding, jonathanh
Cc: rui.zhang, lukasz.luba, linux-pm, linux-tegra
On 4/24/26 18:00, Daniel Lezcano wrote:
> Replace the manual error handling paths disabling the clocks with
> devm_add_action_or_reset(). This ensures the clocks are properly
> disabled on probe failure and driver removal, while simplifying the
> code by removing the explicit error paths.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
> ---
If nobody is against these two changes, I'll apply them
Thanks
-- Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable
2026-05-05 12:10 ` [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
@ 2026-05-06 9:37 ` Daniel Lezcano
2026-05-06 10:26 ` Lukasz Luba
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2026-05-06 9:37 UTC (permalink / raw)
To: rafael, daniel.lezcano, thierry.reding, jonathanh
Cc: rui.zhang, lukasz.luba, linux-pm, linux-tegra
On 5/5/26 14:10, Daniel Lezcano wrote:
> On 4/24/26 18:00, Daniel Lezcano wrote:
>> Replace the manual error handling paths disabling the clocks with
>> devm_add_action_or_reset(). This ensures the clocks are properly
>> disabled on probe failure and driver removal, while simplifying the
>> code by removing the explicit error paths.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
>> ---
>
> If nobody is against these two changes, I'll apply them
>
> Thanks
>
> -- Daniel
>
Applied, thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable
2026-05-06 9:37 ` Daniel Lezcano
@ 2026-05-06 10:26 ` Lukasz Luba
2026-05-06 10:27 ` Daniel Lezcano
0 siblings, 1 reply; 6+ messages in thread
From: Lukasz Luba @ 2026-05-06 10:26 UTC (permalink / raw)
To: Daniel Lezcano
Cc: rui.zhang, linux-pm, jonathanh, linux-tegra, thierry.reding,
rafael, daniel.lezcano
Hi Daniel,
On 5/6/26 10:37, Daniel Lezcano wrote:
> On 5/5/26 14:10, Daniel Lezcano wrote:
>> On 4/24/26 18:00, Daniel Lezcano wrote:
>>> Replace the manual error handling paths disabling the clocks with
>>> devm_add_action_or_reset(). This ensures the clocks are properly
>>> disabled on probe failure and driver removal, while simplifying the
>>> code by removing the explicit error paths.
>>>
>>> Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
>>> ---
>>
>> If nobody is against these two changes, I'll apply them
>>
>> Thanks
>>
>> -- Daniel
>>
>
> Applied, thanks
My apologies for being late. The changes make perfect sense.
Feel free to add to both patches:
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable
2026-05-06 10:26 ` Lukasz Luba
@ 2026-05-06 10:27 ` Daniel Lezcano
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2026-05-06 10:27 UTC (permalink / raw)
To: Lukasz Luba
Cc: rui.zhang, linux-pm, jonathanh, linux-tegra, thierry.reding,
rafael, daniel.lezcano
On 5/6/26 12:26, Lukasz Luba wrote:
> Hi Daniel,
>
> On 5/6/26 10:37, Daniel Lezcano wrote:
>> On 5/5/26 14:10, Daniel Lezcano wrote:
>>> On 4/24/26 18:00, Daniel Lezcano wrote:
>>>> Replace the manual error handling paths disabling the clocks with
>>>> devm_add_action_or_reset(). This ensures the clocks are properly
>>>> disabled on probe failure and driver removal, while simplifying the
>>>> code by removing the explicit error paths.
>>>>
>>>> Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
>>>> ---
>>>
>>> If nobody is against these two changes, I'll apply them
>>>
>>> Thanks
>>>
>>> -- Daniel
>>>
>>
>> Applied, thanks
>
> My apologies for being late. The changes make perfect sense.
> Feel free to add to both patches:
>
> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Thanks for the review
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-05-06 10:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 16:00 [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
2026-04-24 16:00 ` [PATCH 2/2] thermal/drivers/tegra/soctherma: Switch to devm cooling device registration Daniel Lezcano
2026-05-05 12:10 ` [PATCH 1/2] drivers/thermal/tegra/soctherm: Use devm_add_action_or_reset() for clock disable Daniel Lezcano
2026-05-06 9:37 ` Daniel Lezcano
2026-05-06 10:26 ` Lukasz Luba
2026-05-06 10:27 ` Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox