Skip to content

Commit b498256

Browse files
AngeloGioacchino Del Regnodlezcano
authored andcommitted
thermal/drivers/mediatek/lvts: Fix debugfs unregister on failure
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: f5f633b ("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> Link: https://lore.kernel.org/r/20250402083852.20624-1-angelogioacchino.delregno@collabora.com Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
1 parent 0f2bd5a commit b498256

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/thermal/mediatek/lvts_thermal.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ static const struct debugfs_reg32 lvts_regs[] = {
213213
LVTS_DEBUG_FS_REGS(LVTS_CLKEN),
214214
};
215215

216+
static void lvts_debugfs_exit(void *data)
217+
{
218+
struct lvts_domain *lvts_td = data;
219+
220+
debugfs_remove_recursive(lvts_td->dom_dentry);
221+
}
222+
216223
static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
217224
{
218225
struct debugfs_regset32 *regset;
@@ -245,12 +252,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
245252
debugfs_create_regset32("registers", 0400, dentry, regset);
246253
}
247254

248-
return 0;
249-
}
250-
251-
static void lvts_debugfs_exit(struct lvts_domain *lvts_td)
252-
{
253-
debugfs_remove_recursive(lvts_td->dom_dentry);
255+
return devm_add_action_or_reset(dev, lvts_debugfs_exit, lvts_td);
254256
}
255257

256258
#else
@@ -1374,8 +1376,6 @@ static void lvts_remove(struct platform_device *pdev)
13741376

13751377
for (i = 0; i < lvts_td->num_lvts_ctrl; i++)
13761378
lvts_ctrl_set_enable(&lvts_td->lvts_ctrl[i], false);
1377-
1378-
lvts_debugfs_exit(lvts_td);
13791379
}
13801380

13811381
static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl[] = {

0 commit comments

Comments
 (0)