netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>,
	linux-can@vger.kernel.org, netdev@vger.kernel.org,
	Wolfgang Grandegger <wg@grandegger.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] can: c_can: convert to use devm * api
Date: Sun, 22 Jun 2014 12:56:24 +0200	[thread overview]
Message-ID: <53A6B658.6030709@pengutronix.de> (raw)
In-Reply-To: <1403265574-12923-1-git-send-email-prabhakar.csengg@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2264 bytes --]

On 06/20/2014 01:59 PM, Lad, Prabhakar wrote:
> From: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
> 
> this patch uses devm_* APIs as they are device managed
> and make code simpler.
> 
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Thanks for the patch. Applied to can-next with minor change (see inline).

> ---
>  Note: This patch is compile tested only.
>  
>  drivers/net/can/c_can/c_can_platform.c | 41 ++++++++--------------------------
>  1 file changed, 9 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
> index 1df0b32..e0dcbcf 100644
> --- a/drivers/net/can/c_can/c_can_platform.c
> +++ b/drivers/net/can/c_can/c_can_platform.c
> @@ -157,40 +157,31 @@ static int c_can_plat_probe(struct platform_device *pdev)
>  	}
>  
>  	/* get the appropriate clk */
> -	clk = clk_get(&pdev->dev, NULL);
> +	clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(clk)) {
> -		dev_err(&pdev->dev, "no clock defined\n");
> -		ret = -ENODEV;
> +		ret = PTR_ERR(clk);
>  		goto exit;
>  	}
>  
>  	/* get the platform data */
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	irq = platform_get_irq(pdev, 0);
> -	if (!mem || irq <= 0) {
> -		ret = -ENODEV;
> -		goto exit_free_clk;
> -	}
> -
> -	if (!request_mem_region(mem->start, resource_size(mem),
> -				KBUILD_MODNAME)) {
> -		dev_err(&pdev->dev, "resource unavailable\n");
> +	if (irq <= 0) {
>  		ret = -ENODEV;
> -		goto exit_free_clk;
> +		goto exit;
>  	}
>  
> -	addr = ioremap(mem->start, resource_size(mem));
> -	if (!addr) {
> -		dev_err(&pdev->dev, "failed to map can port\n");
> -		ret = -ENOMEM;
> -		goto exit_release_mem;

I've moved the mem = platform_get_resource() for slightly better
readability here....

> +	addr = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(addr)) {
> +		ret =  PTR_ERR(addr);
> +		goto exit;
>  	}

Thanks,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

  reply	other threads:[~2014-06-22 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 11:59 [PATCH] can: c_can: convert to use devm * api Lad, Prabhakar
2014-06-22 10:56 ` Marc Kleine-Budde [this message]
2014-06-22 11:54   ` Prabhakar Lad

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=53A6B658.6030709@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    --cc=wg@grandegger.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).