public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: sergei.shtylyov@cogentembedded•com (Sergei Shtylyov)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v4 1/5] net: ethernet: cpsw: switch to devres allocations
Date: Fri, 23 Aug 2013 22:10:54 +0400	[thread overview]
Message-ID: <5217A5AE.6090704@cogentembedded.com> (raw)
In-Reply-To: <1377267365-24057-2-git-send-email-zonque@gmail.com>

On 08/23/2013 06:16 PM, Daniel Mack wrote:

> This patch cleans up the allocation and error unwind paths, which
> allows us to carry less information in struct cpsw_priv and reduce the
> amount of jump labels in the probe functions.

> Signed-off-by: Daniel Mack <zonque@gmail•com>
> ---
>   drivers/net/ethernet/ti/cpsw.c | 147 +++++++++++++----------------------------
>   1 file changed, 45 insertions(+), 102 deletions(-)

> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 79974e3..849af52 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
[...]
> @@ -1977,55 +1963,41 @@ static int cpsw_probe(struct platform_device *pdev)
>   	priv->slaves[0].ndev = ndev;
>   	priv->emac_port = 0;
>
> -	priv->clk = clk_get(&pdev->dev, "fck");
> +	priv->clk = devm_clk_get(&pdev->dev, "fck");
>   	if (IS_ERR(priv->clk)) {
> -		dev_err(&pdev->dev, "fck is not found\n");
> +		dev_err(priv->dev, "fck is not found\n");
>   		ret = -ENODEV;
> -		goto clean_slave_ret;
> +		goto clean_runtime_disable_ret;
>   	}
>   	priv->coal_intvl = 0;
>   	priv->bus_freq_mhz = clk_get_rate(priv->clk) / 1000000;
>
> -	priv->cpsw_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!priv->cpsw_res) {
> +	ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!ss_res) {

    You don't need to check the result of platform_get_resource() if you call
devm_ioremap_resource() right afterwards -- it will check resource ptr for 
NULL the first thing. :-)

>   		dev_err(priv->dev, "error getting i/o resource\n");
>   		ret = -ENOENT;
> -		goto clean_clk_ret;
> +		goto clean_runtime_disable_ret;
>   	}
> -	if (!request_mem_region(priv->cpsw_res->start,
> -				resource_size(priv->cpsw_res), ndev->name)) {
> -		dev_err(priv->dev, "failed request i/o region\n");
> -		ret = -ENXIO;
> -		goto clean_clk_ret;
> -	}
> -	ss_regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res));
> -	if (!ss_regs) {
> +	ss_regs = devm_ioremap_resource(&pdev->dev, ss_res);
> +	if (IS_ERR(ss_regs)) {
>   		dev_err(priv->dev, "unable to map i/o region\n");

    Don't need the error message anymore -- devm_ioremap_resource() will print 
it. And you missed:

		ret = PTR_ERR(ss_regs);

> -		goto clean_cpsw_iores_ret;
> +		goto clean_runtime_disable_ret;
>   	}
>   	priv->regs = ss_regs;
>   	priv->version = __raw_readl(&priv->regs->id_ver);
>   	priv->host_port = HOST_PORT_NUM;
>
> -	priv->cpsw_wr_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> -	if (!priv->cpsw_wr_res) {
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +	if (!res) {

    Same comment about resource check here...

>   		dev_err(priv->dev, "error getting i/o resource\n");
>   		ret = -ENOENT;
> -		goto clean_iomap_ret;
> -	}
> -	if (!request_mem_region(priv->cpsw_wr_res->start,
> -			resource_size(priv->cpsw_wr_res), ndev->name)) {
> -		dev_err(priv->dev, "failed request i/o region\n");
> -		ret = -ENXIO;
> -		goto clean_iomap_ret;
> +		goto clean_runtime_disable_ret;
>   	}
> -	wr_regs = ioremap(priv->cpsw_wr_res->start,
> -				resource_size(priv->cpsw_wr_res));
> -	if (!wr_regs) {
> +	priv->wr_regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(priv->wr_regs)) {
>   		dev_err(priv->dev, "unable to map i/o region\n");

    And same comments about the unneeded error message and missing 'ret' 
assignment here...

> -		goto clean_cpsw_wr_iores_ret;
> +		goto clean_runtime_disable_ret;
>   	}
> -	priv->wr_regs = wr_regs;
>
>   	memset(&dma_params, 0, sizeof(dma_params));
>   	memset(&ale_params, 0, sizeof(ale_params));
[...]

WBR, Sergei

  reply	other threads:[~2013-08-23 18:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-23 14:16 [PATCH v4 0/5] cpsw: support for control module register Daniel Mack
2013-08-23 14:16 ` [PATCH v4 1/5] net: ethernet: cpsw: switch to devres allocations Daniel Mack
2013-08-23 18:10   ` Sergei Shtylyov [this message]
2013-08-23 18:34     ` Daniel Mack
2013-08-23 14:16 ` [PATCH v4 2/5] net: ethernet: cpsw: add optional third memory region for CONTROL module Daniel Mack
2013-08-23 14:59   ` Sergei Shtylyov
2013-08-23 16:21     ` Daniel Mack
2013-08-23 17:37       ` Sergei Shtylyov
2013-08-23 14:16 ` [PATCH v4 3/5] net: ethernet: cpsw: introduce ti, am3352-cpsw compatible string Daniel Mack
2013-08-23 14:23   ` [PATCH v4 3/5] net: ethernet: cpsw: introduce ti,am3352-cpsw " Santosh Shilimkar
2013-08-23 15:22     ` Benoit Cousson
2013-08-23 15:54       ` Santosh Shilimkar
2013-08-23 16:30     ` Daniel Mack
2013-08-23 16:56       ` Santosh Shilimkar
2013-08-23 17:09         ` Sekhar Nori
2013-08-23 17:17           ` Daniel Mack
2013-08-23 17:19           ` Santosh Shilimkar
2013-08-23 17:24             ` Daniel Mack
2013-08-23 17:28               ` Santosh Shilimkar
2013-08-23 17:39                 ` Sekhar Nori
2013-08-23 18:10                   ` Santosh Shilimkar
2013-08-23 18:29                     ` Mugunthan V N
2013-08-23 19:54                       ` Santosh Shilimkar
2013-08-26  5:59                         ` Mugunthan V N
2013-08-26  6:45                           ` Sekhar Nori
2013-08-23 17:23         ` Mugunthan V N
2013-08-26  5:22           ` Gupta, Pekon
2013-08-23 16:31     ` Sekhar Nori
2013-08-23 16:45     ` Mugunthan V N
2013-08-23 17:05       ` Santosh Shilimkar
2013-08-23 14:16 ` [PATCH v4 4/5] net: ethernet: cpsw: add support for hardware interface mode config Daniel Mack
2013-08-23 16:50   ` Mugunthan V N
2013-08-23 14:16 ` [PATCH v4 5/5] ARM: dts: am33xx: adopt to cpsw changes Daniel Mack

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=5217A5AE.6090704@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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