Commit 759bc015 authored by Greg Kurz's avatar Greg Kurz Committed by Michael Ellerman

ocxl: Clarify error path in setup_xsl_irq()

Implementing rollback with goto and labels is a common practice that
leads to prettier and more maintainable code. FWIW, this design pattern
is already being used in alloc_link() a few lines below in this file.

Do the same in setup_xsl_irq().
Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
Acked-by: default avatarFrederic Barrat <fbarrat@linux.ibm.com>
Acked-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 3cfb9ebe
...@@ -273,9 +273,9 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link) ...@@ -273,9 +273,9 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
spa->irq_name = kasprintf(GFP_KERNEL, "ocxl-xsl-%x-%x-%x", spa->irq_name = kasprintf(GFP_KERNEL, "ocxl-xsl-%x-%x-%x",
link->domain, link->bus, link->dev); link->domain, link->bus, link->dev);
if (!spa->irq_name) { if (!spa->irq_name) {
unmap_irq_registers(spa);
dev_err(&dev->dev, "Can't allocate name for xsl interrupt\n"); dev_err(&dev->dev, "Can't allocate name for xsl interrupt\n");
return -ENOMEM; rc = -ENOMEM;
goto err_xsl;
} }
/* /*
* At some point, we'll need to look into allowing a higher * At some point, we'll need to look into allowing a higher
...@@ -283,11 +283,10 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link) ...@@ -283,11 +283,10 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
*/ */
spa->virq = irq_create_mapping(NULL, hwirq); spa->virq = irq_create_mapping(NULL, hwirq);
if (!spa->virq) { if (!spa->virq) {
kfree(spa->irq_name);
unmap_irq_registers(spa);
dev_err(&dev->dev, dev_err(&dev->dev,
"irq_create_mapping failed for translation interrupt\n"); "irq_create_mapping failed for translation interrupt\n");
return -EINVAL; rc = -EINVAL;
goto err_name;
} }
dev_dbg(&dev->dev, "hwirq %d mapped to virq %d\n", hwirq, spa->virq); dev_dbg(&dev->dev, "hwirq %d mapped to virq %d\n", hwirq, spa->virq);
...@@ -295,15 +294,21 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link) ...@@ -295,15 +294,21 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
rc = request_irq(spa->virq, xsl_fault_handler, 0, spa->irq_name, rc = request_irq(spa->virq, xsl_fault_handler, 0, spa->irq_name,
link); link);
if (rc) { if (rc) {
irq_dispose_mapping(spa->virq);
kfree(spa->irq_name);
unmap_irq_registers(spa);
dev_err(&dev->dev, dev_err(&dev->dev,
"request_irq failed for translation interrupt: %d\n", "request_irq failed for translation interrupt: %d\n",
rc); rc);
return -EINVAL; rc = -EINVAL;
goto err_mapping;
} }
return 0; return 0;
err_mapping:
irq_dispose_mapping(spa->virq);
err_name:
kfree(spa->irq_name);
err_xsl:
unmap_irq_registers(spa);
return rc;
} }
static void release_xsl_irq(struct link *link) static void release_xsl_irq(struct link *link)
......
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