public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kiran Padwal <kiran.padwal@smartplayin.com>
To: Vinod Koul <vinod.koul@intel.com>
Cc: dan.j.williams@intel.com, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma: cppi41: Switch to using managed resource in probe
Date: Wed, 24 Sep 2014 11:12:34 +0530	[thread overview]
Message-ID: <542259CA.5080002@smartplayin.com> (raw)
In-Reply-To: <20140923154035.GP24663@intel.com>

On Tuesday 23 September 2014 09:10 PM, Vinod Koul wrote:
> On Tue, Sep 23, 2014 at 06:20:46PM +0530, Kiran Padwal wrote:
>> This change uses managed resource APIs to allocate resources such as,
>> mem, irq in order to simplify the driver unload or failure cases.
>>
>> Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
>> ---
>>  drivers/dma/cppi41.c |   15 ++++-----------
>>  1 file changed, 4 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
>> index 5921ce3..d3700fb 100644
>> --- a/drivers/dma/cppi41.c
>> +++ b/drivers/dma/cppi41.c
>> @@ -938,7 +938,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
>>  	if (!glue_info)
>>  		return -EINVAL;
>>  
>> -	cdd = kzalloc(sizeof(*cdd), GFP_KERNEL);
>> +	cdd = devm_kzalloc(&pdev->dev, sizeof(*cdd), GFP_KERNEL);
>>  	if (!cdd)
>>  		return -ENOMEM;
>>  
>> @@ -959,10 +959,8 @@ static int cppi41_dma_probe(struct platform_device *pdev)
>>  	cdd->qmgr_mem = of_iomap(dev->of_node, 3);
>>  
>>  	if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem ||
>> -			!cdd->qmgr_mem) {
>> -		ret = -ENXIO;
>> -		goto err_remap;
>> -	}
>> +			!cdd->qmgr_mem)
>> +		return -ENXIO;
>>  
>>  	pm_runtime_enable(dev);
>>  	ret = pm_runtime_get_sync(dev);
>> @@ -989,7 +987,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
>>  
>>  	cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
>>  
>> -	ret = request_irq(irq, glue_info->isr, IRQF_SHARED,
>> +	ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED,
>>  			dev_name(dev), cdd);
>>  	if (ret)
>>  		goto err_irq;
>> @@ -1009,7 +1007,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
>>  err_of:
>>  	dma_async_device_unregister(&cdd->ddev);
>>  err_dma_reg:
>> -	free_irq(irq, cdd);
>>  err_irq:
>>  	cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
>>  	cleanup_chans(cdd);
>> @@ -1023,8 +1020,6 @@ err_get_sync:
>>  	iounmap(cdd->ctrl_mem);
>>  	iounmap(cdd->sched_mem);
>>  	iounmap(cdd->qmgr_mem);
>> -err_remap:
>> -	kfree(cdd);
>>  	return ret;
>>  }
>>  
>> @@ -1036,7 +1031,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
>>  	dma_async_device_unregister(&cdd->ddev);
>>  
>>  	cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
>> -	free_irq(cdd->irq, cdd);
> pls use devm_free_irq() explicitly here, other wise your controller is active and able
> to send interrupts and driver object is getting removed. It is the role of
> driver to quiesce device before releasing
> 

Thanks, I will take care of that and resend the patch.




      reply	other threads:[~2014-09-24  5:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 12:50 [PATCH] dma: cppi41: Switch to using managed resource in probe Kiran Padwal
2014-09-23 15:40 ` Vinod Koul
2014-09-24  5:42   ` Kiran Padwal [this message]

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=542259CA.5080002@smartplayin.com \
    --to=kiran.padwal@smartplayin.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vinod.koul@intel.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