public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Jingoo Han <jg1.han@samsung.com>,
	"'Andrew Morton'" <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>,
	"'Alessandro Zummo'" <a.zummo@towertech.it>,
	<rtc-linux@googlegroups.com>,
	"'Kevin Hilman'" <khilman@linaro.org>,
	"'Tony Lindgren'" <tony@atomide.com>,
	"'Peter Ujfalusi'" <peter.ujfalusi@ti.com>
Subject: Re: [PATCH 1/2] rtc: rtc-twl: Use devm_*() functions
Date: Thu, 5 Dec 2013 18:50:37 +0200	[thread overview]
Message-ID: <52A0AEDD.7060509@ti.com> (raw)
In-Reply-To: <000001cef155$be1674e0$3a435ea0$%han@samsung.com>

On 12/05/2013 03:03 AM, Jingoo Han wrote:
> Use devm_*() functions to make cleanup paths simpler, and remove
> unnecessary remove().
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> ---
>   drivers/rtc/rtc-twl.c |   38 +++++++++++++-------------------------
>   1 file changed, 13 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
> index c2e80d7..1915464 100644
> --- a/drivers/rtc/rtc-twl.c
> +++ b/drivers/rtc/rtc-twl.c
> @@ -479,7 +479,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
>   	u8 rd_reg;
>   
>   	if (irq <= 0)
> -		goto out1;
> +		return ret;
>   
>   	/* Initialize the register map */
>   	if (twl_class_is_4030())
> @@ -489,7 +489,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
>   
>   	ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
>   	if (ret < 0)
> -		goto out1;
> +		return ret;
>   
>   	if (rd_reg & BIT_RTC_STATUS_REG_POWER_UP_M)
>   		dev_warn(&pdev->dev, "Power up reset detected.\n");
> @@ -500,7 +500,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
>   	/* Clear RTC Power up reset and pending alarm interrupts */
>   	ret = twl_rtc_write_u8(rd_reg, REG_RTC_STATUS_REG);
>   	if (ret < 0)
> -		goto out1;
> +		return ret;
>   
>   	if (twl_class_is_6030()) {
>   		twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
> @@ -512,7 +512,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
>   	dev_info(&pdev->dev, "Enabling TWL-RTC\n");
>   	ret = twl_rtc_write_u8(BIT_RTC_CTRL_REG_STOP_RTC_M, REG_RTC_CTRL_REG);
>   	if (ret < 0)
> -		goto out1;
> +		return ret;
>   
>   	/* ensure interrupts are disabled, bootloaders can be strange */
>   	ret = twl_rtc_write_u8(0, REG_RTC_INTERRUPTS_REG);
> @@ -522,34 +522,29 @@ static int twl_rtc_probe(struct platform_device *pdev)
>   	/* init cached IRQ enable bits */
>   	ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
>   	if (ret < 0)
> -		goto out1;
> +		return ret;
>   
>   	device_init_wakeup(&pdev->dev, 1);
>   
> -	rtc = rtc_device_register(pdev->name,
> -				  &pdev->dev, &twl_rtc_ops, THIS_MODULE);
> +	rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
> +					&twl_rtc_ops, THIS_MODULE);
>   	if (IS_ERR(rtc)) {
> -		ret = PTR_ERR(rtc);
>   		dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
>   			PTR_ERR(rtc));
> -		goto out1;
> +		return PTR_ERR(rtc);
>   	}
>   
> -	ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt,
> -				   IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> -				   dev_name(&rtc->dev), rtc);
> +	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
> +					twl_rtc_interrupt,
> +					IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> +					dev_name(&rtc->dev), rtc);

Looks like this will change driver release order and free_irq
will be called after RTC device is unregistered.
I think, you need to request irq first -> then register RTC device.
Right?

>   	if (ret < 0) {
>   		dev_err(&pdev->dev, "IRQ is not free.\n");
> -		goto out2;
> +		return ret;
>   	}
>   
>   	platform_set_drvdata(pdev, rtc);
>   	return 0;
> -
> -out2:
> -	rtc_device_unregister(rtc);
> -out1:
> -	return ret;
>   }
>   
>   /*
> @@ -559,9 +554,6 @@ out1:
>   static int twl_rtc_remove(struct platform_device *pdev)
>   {
>   	/* leave rtc running, but disable irqs */
> -	struct rtc_device *rtc = platform_get_drvdata(pdev);
> -	int irq = platform_get_irq(pdev, 0);
> -
>   	mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);
>   	mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
>   	if (twl_class_is_6030()) {
> @@ -571,10 +563,6 @@ static int twl_rtc_remove(struct platform_device *pdev)
>   			REG_INT_MSK_STS_A);
>   	}
>   
> -
> -	free_irq(irq, rtc);
> -
> -	rtc_device_unregister(rtc);
>   	return 0;
>   }
>   
> 


  parent reply	other threads:[~2013-12-05 15:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05  1:03 [PATCH 1/2] rtc: rtc-twl: Use devm_*() functions Jingoo Han
2013-12-05  1:05 ` [PATCH 2/2] rtc: rtc-vr41xx: " Jingoo Han
2013-12-05 16:50 ` Grygorii Strashko [this message]
2013-12-06  1:49   ` [PATCH 1/2] rtc: rtc-twl: " Jingoo Han
2013-12-06 14:53     ` Grygorii Strashko

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=52A0AEDD.7060509@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=a.zummo@towertech.it \
    --cc=akpm@linux-foundation.org \
    --cc=jg1.han@samsung.com \
    --cc=khilman@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@ti.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=tony@atomide.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