All of lore.kernel.org
 help / color / mirror / Atom feed
From: Domenico Andreoli <cavokz@gmail.com>
To: Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-serial@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Anmar Oueja <anmar.oueja@linaro.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RESEND] serial/amba-pl011: use devm_* managed resources
Date: Tue, 16 Oct 2012 06:34:30 +0200	[thread overview]
Message-ID: <20121016043430.GA24258@glitch> (raw)
In-Reply-To: <1350300961-7036-1-git-send-email-linus.walleij@stericsson.com>

On Mon, Oct 15, 2012 at 01:36:01PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This switches a bunch of allocation and remapping to use the
> devm_* garbage collected methods and cleans up the error
> path and remove() paths consequently.
> 
> devm_ioremap() is only in <linux/io.h> so fix up the
> erroneous <asm/*> include as well.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/tty/serial/amba-pl011.c | 25 +++++++++----------------
>  1 file changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index d7e1ede..7fca402 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -56,8 +56,7 @@
>  #include <linux/of_device.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/sizes.h>
> -
> -#include <asm/io.h>
> +#include <linux/io.h>
>  
>  #define UART_NR			14
>  
> @@ -1973,7 +1972,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		goto out;
>  	}
>  
> -	uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
> +	uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
> +			   GFP_KERNEL);
>  	if (uap == NULL) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  
>  	i = pl011_probe_dt_alias(i, &dev->dev);
>  
> -	base = ioremap(dev->res.start, resource_size(&dev->res));
> +	base = devm_ioremap(&dev->dev, dev->res.start,
> +			    resource_size(&dev->res));
>  	if (!base) {
>  		ret = -ENOMEM;
> -		goto free;
> +		goto out;
>  	}
>  
>  	uap->pinctrl = devm_pinctrl_get(&dev->dev);
>  	if (IS_ERR(uap->pinctrl)) {
>  		ret = PTR_ERR(uap->pinctrl);
> -		goto unmap;
> +		goto out;
>  	}
>  	uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>  						 PINCTRL_STATE_DEFAULT);
> @@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  	if (IS_ERR(uap->pins_sleep))
>  		dev_dbg(&dev->dev, "could not get sleep pinstate\n");
>  
> -	uap->clk = clk_get(&dev->dev, NULL);
> +	uap->clk = devm_clk_get(&dev->dev, NULL);
>  	if (IS_ERR(uap->clk)) {
>  		ret = PTR_ERR(uap->clk);
> -		goto unmap;
> +		goto out;
>  	}
>  
>  	uap->vendor = vendor;
> @@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		amba_set_drvdata(dev, NULL);
>  		amba_ports[i] = NULL;
>  		pl011_dma_remove(uap);
> -		clk_put(uap->clk);
> - unmap:
> -		iounmap(base);
> - free:
> -		kfree(uap);
>  	}
>   out:
>  	return ret;
> @@ -2062,9 +2058,6 @@ static int pl011_remove(struct amba_device *dev)
>  			amba_ports[i] = NULL;
>  
>  	pl011_dma_remove(uap);
> -	iounmap(uap->port.membase);
> -	clk_put(uap->clk);
> -	kfree(uap);
>  	return 0;
>  }
>  

Tested-by: Domenico Andreoli <domenico.andreoli@linux.com>

Thanks,
Domenido

WARNING: multiple messages have this Message-ID (diff)
From: cavokz@gmail.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RESEND] serial/amba-pl011: use devm_* managed resources
Date: Tue, 16 Oct 2012 06:34:30 +0200	[thread overview]
Message-ID: <20121016043430.GA24258@glitch> (raw)
In-Reply-To: <1350300961-7036-1-git-send-email-linus.walleij@stericsson.com>

On Mon, Oct 15, 2012 at 01:36:01PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This switches a bunch of allocation and remapping to use the
> devm_* garbage collected methods and cleans up the error
> path and remove() paths consequently.
> 
> devm_ioremap() is only in <linux/io.h> so fix up the
> erroneous <asm/*> include as well.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/tty/serial/amba-pl011.c | 25 +++++++++----------------
>  1 file changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index d7e1ede..7fca402 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -56,8 +56,7 @@
>  #include <linux/of_device.h>
>  #include <linux/pinctrl/consumer.h>
>  #include <linux/sizes.h>
> -
> -#include <asm/io.h>
> +#include <linux/io.h>
>  
>  #define UART_NR			14
>  
> @@ -1973,7 +1972,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		goto out;
>  	}
>  
> -	uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
> +	uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
> +			   GFP_KERNEL);
>  	if (uap == NULL) {
>  		ret = -ENOMEM;
>  		goto out;
> @@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  
>  	i = pl011_probe_dt_alias(i, &dev->dev);
>  
> -	base = ioremap(dev->res.start, resource_size(&dev->res));
> +	base = devm_ioremap(&dev->dev, dev->res.start,
> +			    resource_size(&dev->res));
>  	if (!base) {
>  		ret = -ENOMEM;
> -		goto free;
> +		goto out;
>  	}
>  
>  	uap->pinctrl = devm_pinctrl_get(&dev->dev);
>  	if (IS_ERR(uap->pinctrl)) {
>  		ret = PTR_ERR(uap->pinctrl);
> -		goto unmap;
> +		goto out;
>  	}
>  	uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
>  						 PINCTRL_STATE_DEFAULT);
> @@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  	if (IS_ERR(uap->pins_sleep))
>  		dev_dbg(&dev->dev, "could not get sleep pinstate\n");
>  
> -	uap->clk = clk_get(&dev->dev, NULL);
> +	uap->clk = devm_clk_get(&dev->dev, NULL);
>  	if (IS_ERR(uap->clk)) {
>  		ret = PTR_ERR(uap->clk);
> -		goto unmap;
> +		goto out;
>  	}
>  
>  	uap->vendor = vendor;
> @@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		amba_set_drvdata(dev, NULL);
>  		amba_ports[i] = NULL;
>  		pl011_dma_remove(uap);
> -		clk_put(uap->clk);
> - unmap:
> -		iounmap(base);
> - free:
> -		kfree(uap);
>  	}
>   out:
>  	return ret;
> @@ -2062,9 +2058,6 @@ static int pl011_remove(struct amba_device *dev)
>  			amba_ports[i] = NULL;
>  
>  	pl011_dma_remove(uap);
> -	iounmap(uap->port.membase);
> -	clk_put(uap->clk);
> -	kfree(uap);
>  	return 0;
>  }
>  

Tested-by: Domenico Andreoli <domenico.andreoli@linux.com>

Thanks,
Domenido

  parent reply	other threads:[~2012-10-16  4:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-15 11:36 [PATCH RESEND] serial/amba-pl011: use devm_* managed resources Linus Walleij
2012-10-15 11:36 ` Linus Walleij
2012-10-15 13:52 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-15 13:52   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-16  4:34 ` Domenico Andreoli [this message]
2012-10-16  4:34   ` Domenico Andreoli

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=20121016043430.GA24258@glitch \
    --to=cavokz@gmail.com \
    --cc=anmar.oueja@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.