Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 15 additions & 41 deletions drivers/irqchip/irq-sifive-plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,11 @@ static int plic_probe(struct fwnode_handle *fwnode)

error = plic_parse_nr_irqs_and_contexts(fwnode, &nr_irqs, &nr_contexts, &gsi_base, &id);
if (error)
goto fail_free_regs;
return error;

priv = kzalloc_obj(*priv);
if (!priv) {
error = -ENOMEM;
goto fail_free_regs;
}
if (!priv)
return -ENOMEM;

priv->fwnode = fwnode;
priv->plic_quirks = plic_quirks;
Expand All @@ -668,10 +666,8 @@ static int plic_probe(struct fwnode_handle *fwnode)
priv->acpi_plic_id = id;

priv->prio_save = bitmap_zalloc(nr_irqs, GFP_KERNEL);
if (!priv->prio_save) {
error = -ENOMEM;
goto fail_free_priv;
}
if (!priv->prio_save)
return -ENOMEM;

for (i = 0; i < nr_contexts; i++) {
error = plic_parse_context_parent(fwnode, i, &parent_hwirq, &cpu,
Expand Down Expand Up @@ -735,10 +731,8 @@ static int plic_probe(struct fwnode_handle *fwnode)

handler->enable_save = kcalloc(priv->irq_groups, sizeof(*handler->enable_save),
GFP_KERNEL);
if (!handler->enable_save) {
error = -ENOMEM;
goto fail_cleanup_contexts;
}
if (!handler->enable_save)
return -ENOMEM;
done:
for_each_device_irq(hwirq, priv) {
plic_toggle(handler, hwirq, 0);
Expand All @@ -748,10 +742,8 @@ static int plic_probe(struct fwnode_handle *fwnode)
}

priv->irqdomain = irq_domain_create_linear(fwnode, nr_irqs, &plic_irqdomain_ops, priv);
if (WARN_ON(!priv->irqdomain)) {
error = -ENOMEM;
goto fail_cleanup_contexts;
}
if (!priv->irqdomain)
return -ENOMEM;

/*
* We can have multiple PLIC instances so setup global state
Expand Down Expand Up @@ -799,33 +791,13 @@ static int plic_probe(struct fwnode_handle *fwnode)
pr_info("%pfwP: mapped %d interrupts with %d handlers for %d contexts.\n",
fwnode, nr_irqs, nr_handlers, nr_contexts);
return 0;

fail_cleanup_contexts:
for (i = 0; i < nr_contexts; i++) {
if (plic_parse_context_parent(fwnode, i, &parent_hwirq, &cpu, priv->acpi_plic_id))
continue;
if (parent_hwirq != RV_IRQ_EXT || cpu < 0)
continue;

handler = per_cpu_ptr(&plic_handlers, cpu);
handler->present = false;
handler->hart_base = NULL;
handler->enable_base = NULL;
kfree(handler->enable_save);
handler->enable_save = NULL;
handler->priv = NULL;
}
bitmap_free(priv->prio_save);
fail_free_priv:
kfree(priv);
fail_free_regs:
iounmap(regs);
return error;
}

static int plic_platform_probe(struct platform_device *pdev)
{
return plic_probe(pdev->dev.fwnode);
if (plic_probe(pdev->dev.fwnode))
panic("%pfwP: Failed to initialize\n", pdev->dev.fwnode);
return 0;
}

static struct platform_driver plic_driver = {
Expand All @@ -842,7 +814,9 @@ builtin_platform_driver(plic_driver);
static int __init plic_early_probe(struct device_node *node,
struct device_node *parent)
{
return plic_probe(&node->fwnode);
if (plic_probe(&node->fwnode))
panic("%pfwP: Failed to initialize\n", &node->fwnode);
return 0;
}

IRQCHIP_DECLARE(riscv, "allwinner,sun20i-d1-plic", plic_early_probe);
Loading