* [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure
@ 2025-04-02 8:38 AngeloGioacchino Del Regno
2025-04-02 9:20 ` Chen-Yu Tsai
2025-04-18 10:16 ` Daniel Lezcano
0 siblings, 2 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-04-02 8:38 UTC (permalink / raw)
To: rafael
Cc: daniel.lezcano, rui.zhang, lukasz.luba, matthias.bgg,
angelogioacchino.delregno, npitre, jpanis, nfraprado, wenst,
bchihi, linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek,
kernel
When running the probe function for this driver, the function
lvts_debugfs_init() gets called in lvts_domain_init() which, in
turn, gets called in lvts_probe() before registering threaded
interrupt handlers.
Even though it's unlikely, the last call may fail and, if it does,
there's nothing removing the already created debugfs folder and
files.
In order to fix that, instead of calling the lvts debugfs cleanup
function upon failure, register a devm action that will take care
of calling that upon failure or driver removal.
Since devm was used, also delete the call to lvts_debugfs_exit()
in the lvts_remove() callback, as now that's done automatically.
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/thermal/mediatek/lvts_thermal.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 088481d91e6e..c0be4ca55c7b 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -213,6 +213,13 @@ static const struct debugfs_reg32 lvts_regs[] = {
LVTS_DEBUG_FS_REGS(LVTS_CLKEN),
};
+static void lvts_debugfs_exit(void *data)
+{
+ struct lvts_domain *lvts_td = data;
+
+ debugfs_remove_recursive(lvts_td->dom_dentry);
+}
+
static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
{
struct debugfs_regset32 *regset;
@@ -245,12 +252,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
debugfs_create_regset32("registers", 0400, dentry, regset);
}
- return 0;
-}
-
-static void lvts_debugfs_exit(struct lvts_domain *lvts_td)
-{
- debugfs_remove_recursive(lvts_td->dom_dentry);
+ return devm_add_action_or_reset(dev, lvts_debugfs_exit, lvts_td);
}
#else
@@ -1374,8 +1376,6 @@ static void lvts_remove(struct platform_device *pdev)
for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
-
- lvts_debugfs_exit(lvts_td);
}
static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure
2025-04-02 8:38 [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure AngeloGioacchino Del Regno
@ 2025-04-02 9:20 ` Chen-Yu Tsai
2025-04-18 10:16 ` Daniel Lezcano
1 sibling, 0 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2025-04-02 9:20 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: rafael, daniel.lezcano, rui.zhang, lukasz.luba, matthias.bgg,
npitre, jpanis, nfraprado, bchihi, linux-pm, linux-kernel,
linux-arm-kernel, linux-mediatek, kernel
On Wed, Apr 2, 2025 at 4:39 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> When running the probe function for this driver, the function
> lvts_debugfs_init() gets called in lvts_domain_init() which, in
> turn, gets called in lvts_probe() before registering threaded
> interrupt handlers.
>
> Even though it's unlikely, the last call may fail and, if it does,
> there's nothing removing the already created debugfs folder and
> files.
>
> In order to fix that, instead of calling the lvts debugfs cleanup
> function upon failure, register a devm action that will take care
> of calling that upon failure or driver removal.
>
> Since devm was used, also delete the call to lvts_debugfs_exit()
> in the lvts_remove() callback, as now that's done automatically.
>
> Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure
2025-04-02 8:38 [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure AngeloGioacchino Del Regno
2025-04-02 9:20 ` Chen-Yu Tsai
@ 2025-04-18 10:16 ` Daniel Lezcano
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2025-04-18 10:16 UTC (permalink / raw)
To: AngeloGioacchino Del Regno
Cc: rafael, rui.zhang, lukasz.luba, matthias.bgg, npitre, jpanis,
nfraprado, wenst, bchihi, linux-pm, linux-kernel,
linux-arm-kernel, linux-mediatek, kernel
On Wed, Apr 02, 2025 at 10:38:52AM +0200, AngeloGioacchino Del Regno wrote:
> When running the probe function for this driver, the function
> lvts_debugfs_init() gets called in lvts_domain_init() which, in
> turn, gets called in lvts_probe() before registering threaded
> interrupt handlers.
>
> Even though it's unlikely, the last call may fail and, if it does,
> there's nothing removing the already created debugfs folder and
> files.
>
> In order to fix that, instead of calling the lvts debugfs cleanup
> function upon failure, register a devm action that will take care
> of calling that upon failure or driver removal.
>
> Since devm was used, also delete the call to lvts_debugfs_exit()
> in the lvts_remove() callback, as now that's done automatically.
>
> Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-18 10:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 8:38 [PATCH] thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure AngeloGioacchino Del Regno
2025-04-02 9:20 ` Chen-Yu Tsai
2025-04-18 10:16 ` Daniel Lezcano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).