Commit 72bb7314 authored by Philipp Zabel's avatar Philipp Zabel

reset: uniphier-glue: Use devm_add_action_or_reset()

Slightly simplify uniphier_glue_reset_probe() and drop
uniphier_glue_reset_remove() by using devm_add_action_or_reset()
for clock and reset cleanup.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link: https://lore.kernel.org/r/20211215093829.3209416-2-p.zabel@pengutronix.deSigned-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 176cae38
...@@ -28,6 +28,20 @@ struct uniphier_glue_reset_priv { ...@@ -28,6 +28,20 @@ struct uniphier_glue_reset_priv {
const struct uniphier_glue_reset_soc_data *data; const struct uniphier_glue_reset_soc_data *data;
}; };
static void uniphier_clk_disable(void *_priv)
{
struct uniphier_glue_reset_priv *priv = _priv;
clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
}
static void uniphier_rst_assert(void *_priv)
{
struct uniphier_glue_reset_priv *priv = _priv;
reset_control_bulk_assert(priv->data->nrsts, priv->rst);
}
static int uniphier_glue_reset_probe(struct platform_device *pdev) static int uniphier_glue_reset_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -68,9 +82,17 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev) ...@@ -68,9 +82,17 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = devm_add_action_or_reset(dev, uniphier_clk_disable, priv);
if (ret)
return ret;
ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst); ret = reset_control_bulk_deassert(priv->data->nrsts, priv->rst);
if (ret) if (ret)
goto out_clk_disable; return ret;
ret = devm_add_action_or_reset(dev, uniphier_rst_assert, priv);
if (ret)
return ret;
spin_lock_init(&priv->rdata.lock); spin_lock_init(&priv->rdata.lock);
priv->rdata.rcdev.owner = THIS_MODULE; priv->rdata.rcdev.owner = THIS_MODULE;
...@@ -81,30 +103,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev) ...@@ -81,30 +103,7 @@ static int uniphier_glue_reset_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
ret = devm_reset_controller_register(dev, &priv->rdata.rcdev); return devm_reset_controller_register(dev, &priv->rdata.rcdev);
if (ret)
goto out_rst_assert;
return 0;
out_rst_assert:
reset_control_bulk_assert(priv->data->nrsts, priv->rst);
out_clk_disable:
clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
return ret;
}
static int uniphier_glue_reset_remove(struct platform_device *pdev)
{
struct uniphier_glue_reset_priv *priv = platform_get_drvdata(pdev);
reset_control_bulk_assert(priv->data->nrsts, priv->rst);
clk_bulk_disable_unprepare(priv->data->nclks, priv->clk);
return 0;
} }
static const char * const uniphier_pro4_clock_reset_names[] = { static const char * const uniphier_pro4_clock_reset_names[] = {
...@@ -172,7 +171,6 @@ MODULE_DEVICE_TABLE(of, uniphier_glue_reset_match); ...@@ -172,7 +171,6 @@ MODULE_DEVICE_TABLE(of, uniphier_glue_reset_match);
static struct platform_driver uniphier_glue_reset_driver = { static struct platform_driver uniphier_glue_reset_driver = {
.probe = uniphier_glue_reset_probe, .probe = uniphier_glue_reset_probe,
.remove = uniphier_glue_reset_remove,
.driver = { .driver = {
.name = "uniphier-glue-reset", .name = "uniphier-glue-reset",
.of_match_table = uniphier_glue_reset_match, .of_match_table = uniphier_glue_reset_match,
......
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