linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Tushar Behera <tushar.b@samsung.com>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	jslaby@suse.cz, gregkh@linuxfoundation.org,
	linux@arm.linux.org.uk
Cc: trblinux@gmail.com
Subject: Re: [PATCH 2/2] serial: amba-pl010: Use devres APIs
Date: Mon, 23 Jun 2014 13:46:47 +0100	[thread overview]
Message-ID: <53A821B7.2000702@linaro.org> (raw)
In-Reply-To: <1403503151-4166-3-git-send-email-tushar.b@samsung.com>

On 23/06/14 06:59, Tushar Behera wrote:
> Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
> devm_clk_get.
> 
> Signed-off-by: Tushar Behera <tushar.b@samsung.com>
> ---
>  drivers/tty/serial/amba-pl010.c |   46 ++++++++++++++-------------------------
>  1 file changed, 16 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
> index 971af1e..af8deba 100644
> --- a/drivers/tty/serial/amba-pl010.c
> +++ b/drivers/tty/serial/amba-pl010.c
> @@ -46,6 +46,7 @@
>  #include <linux/amba/serial.h>
>  #include <linux/clk.h>
>  #include <linux/slab.h>
> +#include <linux/io.h>
>  
>  #include <asm/io.h>

Adding <linux/io.h> makes including <asm/io.h> redundant.


> @@ -688,28 +689,22 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
>  		if (amba_ports[i] == NULL)
>  			break;
>  
> -	if (i == ARRAY_SIZE(amba_ports)) {
> -		ret = -EBUSY;
> -		goto out;
> -	}
> +	if (i == ARRAY_SIZE(amba_ports))
> +		return -EBUSY;
>  
> -	uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
> -	if (!uap) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
> +			   GFP_KERNEL);
> +	if (!uap)
> +		return -ENOMEM;
>  
> -	base = ioremap(dev->res.start, resource_size(&dev->res));
> -	if (!base) {
> -		ret = -ENOMEM;
> -		goto free;
> -	}
> +	base = devm_ioremap(&dev->dev, dev->res.start,
> +			    resource_size(&dev->res));
> +	if (!base)
> +		return -ENOMEM;
>  
> -	uap->clk = clk_get(&dev->dev, NULL);
> -	if (IS_ERR(uap->clk)) {
> -		ret = PTR_ERR(uap->clk);
> -		goto unmap;
> -	}
> +	uap->clk = devm_clk_get(&dev->dev, NULL);
> +	if (IS_ERR(uap->clk))
> +		return PTR_ERR(uap->clk);
>  
>  	uap->port.dev = &dev->dev;
>  	uap->port.mapbase = dev->res.start;
> @@ -727,15 +722,9 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
>  
>  	amba_set_drvdata(dev, uap);
>  	ret = uart_add_one_port(&amba_reg, &uap->port);
> -	if (ret) {
> +	if (ret)
>  		amba_ports[i] = NULL;
> -		clk_put(uap->clk);
> - unmap:
> -		iounmap(base);
> - free:
> -		kfree(uap);
> -	}
> - out:
> +
>  	return ret;
>  }
>  
> @@ -750,9 +739,6 @@ static int pl010_remove(struct amba_device *dev)
>  		if (amba_ports[i] == uap)
>  			amba_ports[i] = NULL;
>  
> -	iounmap(uap->port.membase);
> -	clk_put(uap->clk);
> -	kfree(uap);
>  	return 0;
>  }

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


  reply	other threads:[~2014-06-23 12:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23  5:59 [PATCH 0/2] serial: amba-pl01x: Clean up patches Tushar Behera
2014-06-23  5:59 ` [PATCH 1/2] serial: amba-pl011: Remove redundant label Tushar Behera
2014-06-23 12:37   ` Daniel Thompson
2014-06-23  5:59 ` [PATCH 2/2] serial: amba-pl010: Use devres APIs Tushar Behera
2014-06-23 12:46   ` Daniel Thompson [this message]
2014-06-26  9:37     ` Tushar Behera

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=53A821B7.2000702@linaro.org \
    --to=daniel.thompson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=trblinux@gmail.com \
    --cc=tushar.b@samsung.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).