All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clocksource: em_sti: Convert to devm_* managed helpers
Date: Tue, 30 Jul 2013 02:06:46 +0000	[thread overview]
Message-ID: <20130730020640.GA27724@verge.net.au> (raw)
In-Reply-To: <1374848897-18545-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

[ CC John Stultz, Thomas Gleixner ]

On Fri, Jul 26, 2013 at 04:28:17PM +0200, Laurent Pinchart wrote:
> Replace kzalloc, clk_get, ioremap and request_irq by their managed
> counterparts to simplify error paths.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Hi Laurent,

I was recently asked for shmobile clocksource patches to be reviewed
by the clocksource maintainers. I believe that means John Stultz
and Thomas Gleixner who I have CCed on this email accordingly.

I have also CCed linux-arm-kernel@lists.infradead.org as many moons ago
I was asked for all patches that will go through my tree and on to arm-soc
to be sent there.

> ---
>  drivers/clocksource/em_sti.c | 49 +++++++++++++-------------------------------
>  1 file changed, 14 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
> index 4329a29..b9c81b7 100644
> --- a/drivers/clocksource/em_sti.c
> +++ b/drivers/clocksource/em_sti.c
> @@ -315,68 +315,47 @@ static int em_sti_probe(struct platform_device *pdev)
>  {
>  	struct em_sti_priv *p;
>  	struct resource *res;
> -	int irq, ret;
> +	int irq;
>  
> -	p = kzalloc(sizeof(*p), GFP_KERNEL);
> +	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
>  	if (p = NULL) {
>  		dev_err(&pdev->dev, "failed to allocate driver data\n");
> -		ret = -ENOMEM;
> -		goto err0;
> +		return -ENOMEM;
>  	}
>  
>  	p->pdev = pdev;
>  	platform_set_drvdata(pdev, p);
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "failed to get I/O memory\n");
> -		ret = -EINVAL;
> -		goto err0;
> -	}
> -
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_err(&pdev->dev, "failed to get irq\n");
> -		ret = -EINVAL;
> -		goto err0;
> +		return -EINVAL;
>  	}
>  
>  	/* map memory, let base point to the STI instance */
> -	p->base = ioremap_nocache(res->start, resource_size(res));
> -	if (p->base = NULL) {
> -		dev_err(&pdev->dev, "failed to remap I/O memory\n");
> -		ret = -ENXIO;
> -		goto err0;
> -	}
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	p->base = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(p->base))
> +		return PTR_ERR(p->base);
>  
>  	/* get hold of clock */
> -	p->clk = clk_get(&pdev->dev, "sclk");
> +	p->clk = devm_clk_get(&pdev->dev, "sclk");
>  	if (IS_ERR(p->clk)) {
>  		dev_err(&pdev->dev, "cannot get clock\n");
> -		ret = PTR_ERR(p->clk);
> -		goto err1;
> +		return PTR_ERR(p->clk);
>  	}
>  
> -	if (request_irq(irq, em_sti_interrupt,
> -			IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
> -			dev_name(&pdev->dev), p)) {
> +	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
> +			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
> +			     dev_name(&pdev->dev), p)) {
>  		dev_err(&pdev->dev, "failed to request low IRQ\n");
> -		ret = -ENOENT;
> -		goto err2;
> +		return -ENOENT;
>  	}
>  
>  	raw_spin_lock_init(&p->lock);
>  	em_sti_register_clockevent(p);
>  	em_sti_register_clocksource(p);
>  	return 0;
> -
> -err2:
> -	clk_put(p->clk);
> -err1:
> -	iounmap(p->base);
> -err0:
> -	kfree(p);
> -	return ret;
>  }
>  
>  static int em_sti_remove(struct platform_device *pdev)
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

WARNING: multiple messages have this Message-ID (diff)
From: horms@verge.net.au (Simon Horman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] clocksource: em_sti: Convert to devm_* managed helpers
Date: Tue, 30 Jul 2013 11:06:46 +0900	[thread overview]
Message-ID: <20130730020640.GA27724@verge.net.au> (raw)
In-Reply-To: <1374848897-18545-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

[ CC John Stultz, Thomas Gleixner ]

On Fri, Jul 26, 2013 at 04:28:17PM +0200, Laurent Pinchart wrote:
> Replace kzalloc, clk_get, ioremap and request_irq by their managed
> counterparts to simplify error paths.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Hi Laurent,

I was recently asked for shmobile clocksource patches to be reviewed
by the clocksource maintainers. I believe that means John Stultz
and Thomas Gleixner who I have CCed on this email accordingly.

I have also CCed linux-arm-kernel at lists.infradead.org as many moons ago
I was asked for all patches that will go through my tree and on to arm-soc
to be sent there.

> ---
>  drivers/clocksource/em_sti.c | 49 +++++++++++++-------------------------------
>  1 file changed, 14 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
> index 4329a29..b9c81b7 100644
> --- a/drivers/clocksource/em_sti.c
> +++ b/drivers/clocksource/em_sti.c
> @@ -315,68 +315,47 @@ static int em_sti_probe(struct platform_device *pdev)
>  {
>  	struct em_sti_priv *p;
>  	struct resource *res;
> -	int irq, ret;
> +	int irq;
>  
> -	p = kzalloc(sizeof(*p), GFP_KERNEL);
> +	p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
>  	if (p == NULL) {
>  		dev_err(&pdev->dev, "failed to allocate driver data\n");
> -		ret = -ENOMEM;
> -		goto err0;
> +		return -ENOMEM;
>  	}
>  
>  	p->pdev = pdev;
>  	platform_set_drvdata(pdev, p);
>  
> -	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	if (!res) {
> -		dev_err(&pdev->dev, "failed to get I/O memory\n");
> -		ret = -EINVAL;
> -		goto err0;
> -	}
> -
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_err(&pdev->dev, "failed to get irq\n");
> -		ret = -EINVAL;
> -		goto err0;
> +		return -EINVAL;
>  	}
>  
>  	/* map memory, let base point to the STI instance */
> -	p->base = ioremap_nocache(res->start, resource_size(res));
> -	if (p->base == NULL) {
> -		dev_err(&pdev->dev, "failed to remap I/O memory\n");
> -		ret = -ENXIO;
> -		goto err0;
> -	}
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	p->base = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(p->base))
> +		return PTR_ERR(p->base);
>  
>  	/* get hold of clock */
> -	p->clk = clk_get(&pdev->dev, "sclk");
> +	p->clk = devm_clk_get(&pdev->dev, "sclk");
>  	if (IS_ERR(p->clk)) {
>  		dev_err(&pdev->dev, "cannot get clock\n");
> -		ret = PTR_ERR(p->clk);
> -		goto err1;
> +		return PTR_ERR(p->clk);
>  	}
>  
> -	if (request_irq(irq, em_sti_interrupt,
> -			IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
> -			dev_name(&pdev->dev), p)) {
> +	if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
> +			     IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
> +			     dev_name(&pdev->dev), p)) {
>  		dev_err(&pdev->dev, "failed to request low IRQ\n");
> -		ret = -ENOENT;
> -		goto err2;
> +		return -ENOENT;
>  	}
>  
>  	raw_spin_lock_init(&p->lock);
>  	em_sti_register_clockevent(p);
>  	em_sti_register_clocksource(p);
>  	return 0;
> -
> -err2:
> -	clk_put(p->clk);
> -err1:
> -	iounmap(p->base);
> -err0:
> -	kfree(p);
> -	return ret;
>  }
>  
>  static int em_sti_remove(struct platform_device *pdev)
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2013-07-30  2:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 14:28 [PATCH] clocksource: em_sti: Convert to devm_* managed helpers Laurent Pinchart
2013-07-30  2:06 ` Simon Horman [this message]
2013-07-30  2:06   ` Simon Horman
2013-07-30  2:19   ` John Stultz
2013-07-30  2:19     ` John Stultz
2013-07-30 10:03     ` Laurent Pinchart
2013-07-30 10:03       ` Laurent Pinchart
2013-07-30 14:15       ` Daniel Lezcano
2013-07-30 14:15         ` Daniel Lezcano

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=20130730020640.GA27724@verge.net.au \
    --to=horms@verge.net.au \
    --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 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.