From: haojian.zhuang@gmail.com (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [V2 PATCH 1/2] rtc: sa1100: move clock enable/disable to probe/remove
Date: Wed, 5 Dec 2012 15:05:00 +0800 [thread overview]
Message-ID: <CAN1soZwHigQNxRv17oDbX87wntxh_NjwDmhFkDabc4HW-ZH6bw@mail.gmail.com> (raw)
In-Reply-To: <1354690149-3043-1-git-send-email-chao.xie@marvell.com>
On Wed, Dec 5, 2012 at 2:49 PM, Chao Xie <chao.xie@marvell.com> wrote:
> The original sa1100_rtc_open/sa1100_rtc_release will be called
> when the /dev/rtc0 is opened or closed.
> In fact, these two functions will enable/disable the clock.
> Disabling clock will make rtc not work.
> So only enable/disable clock when probe/remove the device.
>
> Signed-off-by: Chao Xie <chao.xie@marvell.com>
> ---
> drivers/rtc/rtc-sa1100.c | 11 ++++++-----
> 1 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
> index 50a5c4a..34f66b8 100644
> --- a/drivers/rtc/rtc-sa1100.c
> +++ b/drivers/rtc/rtc-sa1100.c
> @@ -108,9 +108,6 @@ static int sa1100_rtc_open(struct device *dev)
> struct rtc_device *rtc = info->rtc;
> int ret;
>
> - ret = clk_prepare_enable(info->clk);
> - if (ret)
> - goto fail_clk;
> ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev);
> if (ret) {
> dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz);
> @@ -130,7 +127,6 @@ static int sa1100_rtc_open(struct device *dev)
> free_irq(info->irq_1hz, dev);
> fail_ui:
> clk_disable_unprepare(info->clk);
> - fail_clk:
> return ret;
> }
>
> @@ -144,7 +140,6 @@ static void sa1100_rtc_release(struct device *dev)
>
> free_irq(info->irq_alarm, dev);
> free_irq(info->irq_1hz, dev);
> - clk_disable_unprepare(info->clk);
> }
>
> static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
> @@ -253,6 +248,9 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
> spin_lock_init(&info->lock);
> platform_set_drvdata(pdev, info);
>
> + ret = clk_prepare_enable(info->clk);
> + if (ret)
> + goto err_enable_clk;
> /*
> * According to the manual we should be able to let RTTR be zero
> * and then a default diviser for a 32.768KHz clock is used.
> @@ -305,6 +303,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
>
> return 0;
> err_dev:
> + clk_disable_unprepare(info->clk);
> +err_enable_clk:
> platform_set_drvdata(pdev, NULL);
> clk_put(info->clk);
> err_clk:
> @@ -318,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
>
> if (info) {
> rtc_device_unregister(info->rtc);
> + clk_disable_unprepare(info->clk);
> clk_put(info->clk);
> platform_set_drvdata(pdev, NULL);
> kfree(info);
> --
> 1.7.4.1
>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
prev parent reply other threads:[~2012-12-05 7:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1354690149-3043-1-git-send-email-chao.xie@marvell.com>
[not found] ` <1354690149-3043-2-git-send-email-chao.xie@marvell.com>
2012-12-05 7:04 ` [V2 PATCH 2/2] rtc: pxa: add pxa95x rtc support Haojian Zhuang
2012-12-06 1:28 ` Chao Xie
2012-12-05 7:05 ` Haojian Zhuang [this message]
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=CAN1soZwHigQNxRv17oDbX87wntxh_NjwDmhFkDabc4HW-ZH6bw@mail.gmail.com \
--to=haojian.zhuang@gmail.com \
--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 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).