linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ASoC: atmel-ssc: use devm_xxx() managed function
Date: Tue, 16 Oct 2012 10:05:25 +0200	[thread overview]
Message-ID: <507D1545.8020903@atmel.com> (raw)
In-Reply-To: <1350359819-2461-1-git-send-email-voice.shen@atmel.com>

On 10/16/2012 05:56 AM, Bo Shen :
> Using the devm_xxx() managed function to stripdown the error
> and remove code.
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>

Maybe too late, but:

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>  drivers/misc/atmel-ssc.c |   47 +++++++++++++++-------------------------------
>  1 file changed, 15 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index 5bb1877..23dcb76 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -70,37 +70,33 @@ EXPORT_SYMBOL(ssc_free);
>  
>  static int __init ssc_probe(struct platform_device *pdev)
>  {
> -	int retval = 0;
>  	struct resource *regs;
>  	struct ssc_device *ssc;
>  
> -	ssc = kzalloc(sizeof(struct ssc_device), GFP_KERNEL);
> +	ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
>  	if (!ssc) {
>  		dev_dbg(&pdev->dev, "out of memory\n");
> -		retval = -ENOMEM;
> -		goto out;
> +		return -ENOMEM;
>  	}
>  
> +	ssc->pdev = pdev;
> +
>  	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!regs) {
>  		dev_dbg(&pdev->dev, "no mmio resource defined\n");
> -		retval = -ENXIO;
> -		goto out_free;
> +		return -ENXIO;
>  	}
>  
> -	ssc->clk = clk_get(&pdev->dev, "pclk");
> -	if (IS_ERR(ssc->clk)) {
> -		dev_dbg(&pdev->dev, "no pclk clock defined\n");
> -		retval = -ENXIO;
> -		goto out_free;
> -	}
> -
> -	ssc->pdev = pdev;
> -	ssc->regs = ioremap(regs->start, resource_size(regs));
> +	ssc->regs = devm_request_and_ioremap(&pdev->dev, regs);
>  	if (!ssc->regs) {
>  		dev_dbg(&pdev->dev, "ioremap failed\n");
> -		retval = -EINVAL;
> -		goto out_clk;
> +		return -EINVAL;
> +	}
> +
> +	ssc->clk = devm_clk_get(&pdev->dev, "pclk");
> +	if (IS_ERR(ssc->clk)) {
> +		dev_dbg(&pdev->dev, "no pclk clock defined\n");
> +		return -ENXIO;
>  	}
>  
>  	/* disable all interrupts */
> @@ -112,8 +108,7 @@ static int __init ssc_probe(struct platform_device *pdev)
>  	ssc->irq = platform_get_irq(pdev, 0);
>  	if (!ssc->irq) {
>  		dev_dbg(&pdev->dev, "could not get irq\n");
> -		retval = -ENXIO;
> -		goto out_unmap;
> +		return -ENXIO;
>  	}
>  
>  	spin_lock(&user_lock);
> @@ -125,16 +120,7 @@ static int __init ssc_probe(struct platform_device *pdev)
>  	dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
>  			ssc->regs, ssc->irq);
>  
> -	goto out;
> -
> -out_unmap:
> -	iounmap(ssc->regs);
> -out_clk:
> -	clk_put(ssc->clk);
> -out_free:
> -	kfree(ssc);
> -out:
> -	return retval;
> +	return 0;
>  }
>  
>  static int __devexit ssc_remove(struct platform_device *pdev)
> @@ -142,10 +128,7 @@ static int __devexit ssc_remove(struct platform_device *pdev)
>  	struct ssc_device *ssc = platform_get_drvdata(pdev);
>  
>  	spin_lock(&user_lock);
> -	iounmap(ssc->regs);
> -	clk_put(ssc->clk);
>  	list_del(&ssc->list);
> -	kfree(ssc);
>  	spin_unlock(&user_lock);
>  
>  	return 0;
> 


-- 
Nicolas Ferre

      parent reply	other threads:[~2012-10-16  8:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16  3:56 [PATCH 1/2] ASoC: atmel-ssc: use devm_xxx() managed function Bo Shen
2012-10-16  3:56 ` [PATCH 2/2] ASoC: atmel-ssc: use module_platform_driver macro Bo Shen
2012-10-16  8:07   ` Nicolas Ferre
2012-10-16  8:49     ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-16  8:59       ` Bo Shen
2012-10-16  9:07       ` Russell King - ARM Linux
2012-10-16  9:32   ` Fabio Porcedda
2012-10-16  5:12 ` [PATCH 1/2] ASoC: atmel-ssc: use devm_xxx() managed function Mark Brown
2012-10-16  8:05 ` Nicolas Ferre [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=507D1545.8020903@atmel.com \
    --to=nicolas.ferre@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).