linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Christophe Lombard <clombard@linux.vnet.ibm.com>,
	Andrew Donnellan <andrew.donnellan@au1.ibm.com>,
	Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Subject: Re: [PATCH] ocxl: Clarify error path in setup_xsl_irq()
Date: Thu, 20 Dec 2018 15:52:32 +0100	[thread overview]
Message-ID: <20181220155232.31e8a778@bahia.lan> (raw)
In-Reply-To: <4e803758-08af-d774-9e50-1c64fb8545ff@au1.ibm.com>

On Tue, 11 Dec 2018 11:19:55 +1100
Andrew Donnellan <andrew.donnellan@au1.ibm.com> wrote:

> On 11/12/18 2:18 am, Greg Kurz wrote:
> > 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: Greg Kurz <groug@kaod.org>  
> 
> This is good, thanks.
> 
> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> 

Friendly ping before Xmas break :)

> > ---
> >   drivers/misc/ocxl/link.c |   23 ++++++++++++++---------
> >   1 file changed, 14 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> > index eed92055184d..659977a17405 100644
> > --- a/drivers/misc/ocxl/link.c
> > +++ b/drivers/misc/ocxl/link.c
> > @@ -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",
> >   				link->domain, link->bus, link->dev);
> >   	if (!spa->irq_name) {
> > -		unmap_irq_registers(spa);
> >   		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
> > @@ -283,11 +283,10 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> >   	 */
> >   	spa->virq = irq_create_mapping(NULL, hwirq);
> >   	if (!spa->virq) {
> > -		kfree(spa->irq_name);
> > -		unmap_irq_registers(spa);
> >   		dev_err(&dev->dev,
> >   			"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);
> > @@ -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,
> >   			link);
> >   	if (rc) {
> > -		irq_dispose_mapping(spa->virq);
> > -		kfree(spa->irq_name);
> > -		unmap_irq_registers(spa);
> >   		dev_err(&dev->dev,
> >   			"request_irq failed for translation interrupt: %d\n",
> >   			rc);
> > -		return -EINVAL;
> > +		rc = -EINVAL;
> > +		goto err_mapping;
> >   	}
> >   	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)
> >   
> 


  reply	other threads:[~2018-12-20 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 15:18 [PATCH] ocxl: Clarify error path in setup_xsl_irq() Greg Kurz
2018-12-10 17:18 ` Frederic Barrat
2018-12-11  0:19 ` Andrew Donnellan
2018-12-20 14:52   ` Greg Kurz [this message]
2018-12-22  9:54 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181220155232.31e8a778@bahia.lan \
    --to=groug@kaod.org \
    --cc=andrew.donnellan@au1.ibm.com \
    --cc=clombard@linux.vnet.ibm.com \
    --cc=fbarrat@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=vaibhav@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).