mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 06:49:52 +00:00
irqchip/renesas-rzv2h: Simplify rzv2h_icu_init()
Use devm_add_action_or_reset() for calling put_device in error path of rzv2h_icu_init() to simplify the code by using the recently added devm_* helpers. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Link: https://lore.kernel.org/all/20250224131253.134199-5-biju.das.jz@bp.renesas.com
This commit is contained in:
parent
c56cab0c3e
commit
f5de954388
@ -419,6 +419,11 @@ static int rzv2h_icu_parse_interrupts(struct rzv2h_icu_priv *priv, struct device
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rzv2h_icu_put_device(void *data)
|
||||
{
|
||||
put_device(data);
|
||||
}
|
||||
|
||||
static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
|
||||
{
|
||||
struct irq_domain *irq_domain, *parent_domain;
|
||||
@ -431,41 +436,39 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
|
||||
if (!pdev)
|
||||
return -ENODEV;
|
||||
|
||||
ret = devm_add_action_or_reset(&pdev->dev, rzv2h_icu_put_device,
|
||||
&pdev->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
parent_domain = irq_find_host(parent);
|
||||
if (!parent_domain) {
|
||||
dev_err(&pdev->dev, "cannot find parent domain\n");
|
||||
ret = -ENODEV;
|
||||
goto put_dev;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
rzv2h_icu_data = devm_kzalloc(&pdev->dev, sizeof(*rzv2h_icu_data), GFP_KERNEL);
|
||||
if (!rzv2h_icu_data) {
|
||||
ret = -ENOMEM;
|
||||
goto put_dev;
|
||||
}
|
||||
if (!rzv2h_icu_data)
|
||||
return -ENOMEM;
|
||||
|
||||
rzv2h_icu_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL);
|
||||
if (IS_ERR(rzv2h_icu_data->base)) {
|
||||
ret = PTR_ERR(rzv2h_icu_data->base);
|
||||
goto put_dev;
|
||||
}
|
||||
if (IS_ERR(rzv2h_icu_data->base))
|
||||
return PTR_ERR(rzv2h_icu_data->base);
|
||||
|
||||
ret = rzv2h_icu_parse_interrupts(rzv2h_icu_data, node);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "cannot parse interrupts: %d\n", ret);
|
||||
goto put_dev;
|
||||
return ret;
|
||||
}
|
||||
|
||||
resetn = devm_reset_control_get_exclusive(&pdev->dev, NULL);
|
||||
if (IS_ERR(resetn)) {
|
||||
ret = PTR_ERR(resetn);
|
||||
goto put_dev;
|
||||
}
|
||||
if (IS_ERR(resetn))
|
||||
return PTR_ERR(resetn);
|
||||
|
||||
ret = reset_control_deassert(resetn);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to deassert resetn pin, %d\n", ret);
|
||||
goto put_dev;
|
||||
return ret;
|
||||
}
|
||||
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
@ -496,8 +499,6 @@ pm_put:
|
||||
pm_disable:
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
reset_control_assert(resetn);
|
||||
put_dev:
|
||||
put_device(&pdev->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user