Commit 85f0b61a authored by Anson Huang's avatar Anson Huang Committed by Daniel Lezcano

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: default avatarAnson Huang <Anson.Huang@nxp.com>
Reviewed-by: default avatarAmit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/1583903252-2058-1-git-send-email-Anson.Huang@nxp.com
parent 0fa04202
...@@ -228,6 +228,14 @@ static const struct regmap_access_table qoriq_rd_table = { ...@@ -228,6 +228,14 @@ static const struct regmap_access_table qoriq_rd_table = {
.n_yes_ranges = ARRAY_SIZE(qoriq_yes_ranges), .n_yes_ranges = ARRAY_SIZE(qoriq_yes_ranges),
}; };
static void qoriq_tmu_action(void *p)
{
struct qoriq_tmu_data *data = p;
regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
clk_disable_unprepare(data->clk);
}
static int qoriq_tmu_probe(struct platform_device *pdev) static int qoriq_tmu_probe(struct platform_device *pdev)
{ {
int ret; int ret;
...@@ -278,6 +286,10 @@ static int qoriq_tmu_probe(struct platform_device *pdev) ...@@ -278,6 +286,10 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
return ret; return ret;
} }
ret = devm_add_action_or_reset(dev, qoriq_tmu_action, data);
if (ret)
return ret;
/* version register offset at: 0xbf8 on both v1 and v2 */ /* version register offset at: 0xbf8 on both v1 and v2 */
ret = regmap_read(data->regmap, REGS_IPBRR(0), &ver); ret = regmap_read(data->regmap, REGS_IPBRR(0), &ver);
if (ret) { if (ret) {
...@@ -290,34 +302,16 @@ static int qoriq_tmu_probe(struct platform_device *pdev) ...@@ -290,34 +302,16 @@ static int qoriq_tmu_probe(struct platform_device *pdev)
ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */ ret = qoriq_tmu_calibration(dev, data); /* TMU calibration */
if (ret < 0) if (ret < 0)
goto err; return ret;
ret = qoriq_tmu_register_tmu_zone(dev, data); ret = qoriq_tmu_register_tmu_zone(dev, data);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to register sensors\n"); dev_err(dev, "Failed to register sensors\n");
ret = -ENODEV; return ret;
goto err;
} }
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
return 0;
err:
clk_disable_unprepare(data->clk);
return ret;
}
static int qoriq_tmu_remove(struct platform_device *pdev)
{
struct qoriq_tmu_data *data = platform_get_drvdata(pdev);
/* Disable monitoring */
regmap_write(data->regmap, REGS_TMR, TMR_DISABLE);
clk_disable_unprepare(data->clk);
return 0; return 0;
} }
...@@ -365,7 +359,6 @@ static struct platform_driver qoriq_tmu = { ...@@ -365,7 +359,6 @@ static struct platform_driver qoriq_tmu = {
.of_match_table = qoriq_tmu_match, .of_match_table = qoriq_tmu_match,
}, },
.probe = qoriq_tmu_probe, .probe = qoriq_tmu_probe,
.remove = qoriq_tmu_remove,
}; };
module_platform_driver(qoriq_tmu); module_platform_driver(qoriq_tmu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment