Skip to content

Commit 85f0b61

Browse files
Anson-Huangdlezcano
authored andcommitted
thermal: qoriq: Use devm_add_action_or_reset() to handle all cleanups
Use devm_add_action_or_reset() to handle all cleanups of failure in .probe and .remove, then .remove callback can be dropped. Signed-off-by: Anson Huang <[email protected]> Reviewed-by: Amit Kucheria <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0fa0420 commit 85f0b61

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

drivers/thermal/qoriq_thermal.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ static const struct regmap_access_table qoriq_rd_table = {
228228
.n_yes_ranges = ARRAY_SIZE(qoriq_yes_ranges),
229229
};
230230

231+
static void qoriq_tmu_action(void *p)
232+
{
233+
struct qoriq_tmu_data *data = p;
234+
235+
regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
236+
clk_disable_unprepare(data->clk);
237+
}
238+
231239
static int qoriq_tmu_probe(struct platform_device *pdev)
232240
{
233241
int ret;
@@ -278,6 +286,10 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
278286
return ret;
279287
}
280288

289+
ret = devm_add_action_or_reset(dev, qoriq_tmu_action, data);
290+
if (ret)
291+
return ret;
292+
281293
/* version register offset at: 0xbf8 on both v1 and v2 */
282294
ret = regmap_read(data->regmap, REGS_IPBRR(0), &ver);
283295
if (ret) {
@@ -290,34 +302,16 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
290302

291303
ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */
292304
if (ret < 0)
293-
goto err;
305+
return ret;
294306

295307
ret = qoriq_tmu_register_tmu_zone(dev, data);
296308
if (ret < 0) {
297309
dev_err(dev, "Failed to register sensors\n");
298-
ret = -ENODEV;
299-
goto err;
310+
return ret;
300311
}
301312

302313
platform_set_drvdata(pdev, data);
303314

304-
return 0;
305-
306-
err:
307-
clk_disable_unprepare(data->clk);
308-
309-
return ret;
310-
}
311-
312-
static int qoriq_tmu_remove(struct platform_device *pdev)
313-
{
314-
struct qoriq_tmu_data *data = platform_get_drvdata(pdev);
315-
316-
/* Disable monitoring */
317-
regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
318-
319-
clk_disable_unprepare(data->clk);
320-
321315
return 0;
322316
}
323317

@@ -365,7 +359,6 @@ static struct platform_driver qoriq_tmu = {
365359
.of_match_table = qoriq_tmu_match,
366360
},
367361
.probe = qoriq_tmu_probe,
368-
.remove = qoriq_tmu_remove,
369362
};
370363
module_platform_driver(qoriq_tmu);
371364

0 commit comments

Comments
 (0)