From patchwork Wed Dec 5 06:49:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Xie X-Patchwork-Id: 203790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-yh0-f58.google.com (mail-yh0-f58.google.com [209.85.213.58]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0518D2C00BE for ; Wed, 5 Dec 2012 17:49:37 +1100 (EST) Received: by mail-yh0-f58.google.com with SMTP id m54sf2838459yhm.3 for ; Tue, 04 Dec 2012 22:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:x-originalarrivaltime:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=w9etd0tRpaL6RtP29oWKROQnSqXujeOobRmWTGoaFyo=; b=xr7TzpBtXQ4Fft8IT1yTt9N+aV7af4MYsRjpar0RhLYK1M34hwua9kz0lKjDBBBsmA +1BAuKUfIfNbI+0mwqSngTSJtJBwiQKt0F00fm5x/Si14vklSJoMC6jkRjhtJbaLvF7U Ktudg6Qg+Dl/wEjasSJlzbsBpwCc/fy5UAhft34vTYzFjMl4zt1PtQoxcwVYiscBnzUd VITjvo+NJ78kgivOd3uijD39p9RV5XQizcchszC2aIVkHkkYdnlktCQtvQO02xmqYR/Q k8RAdTEI9Qyl68Ma5dYqUlbQ2sC9Mr2NsGUWRW0xNmkEDJNsIkgOdaTmZysl5LhWYNAZ +GHQ== Received: by 10.50.0.166 with SMTP id 6mr313598igf.7.1354690173820; Tue, 04 Dec 2012 22:49:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.208.2 with SMTP id ma2ls3302584igc.22.canary; Tue, 04 Dec 2012 22:49:33 -0800 (PST) Received: by 10.66.85.102 with SMTP id g6mr3270314paz.5.1354690173136; Tue, 04 Dec 2012 22:49:33 -0800 (PST) Received: by 10.66.85.102 with SMTP id g6mr3270313paz.5.1354690173125; Tue, 04 Dec 2012 22:49:33 -0800 (PST) Received: from na3sys009aog128.obsmtp.com (na3sys009aog128.obsmtp.com [74.125.149.141]) by gmr-mx.google.com with SMTP id m8si730398pav.2.2012.12.04.22.49.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Dec 2012 22:49:33 -0800 (PST) Received-SPF: neutral (google.com: 74.125.149.141 is neither permitted nor denied by best guess record for domain of cxie4@marvell.com) client-ip=74.125.149.141; Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob128.postini.com ([74.125.148.12]) with SMTP ID DSNKUL7ua+6I4KF0pp4a1gN5KLx55ad/uqzx@postini.com; Tue, 04 Dec 2012 22:49:32 PST Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 4 Dec 2012 22:49:12 -0800 Received: from localhost (unknown [10.38.36.205]) by maili.marvell.com (Postfix) with ESMTP id 6E8374E510; Tue, 4 Dec 2012 22:49:12 -0800 (PST) From: Chao Xie To: haojian.zhuang@gmail.com, xiechao.mail@gmail.com, linux@arm.linux.org.uk, a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead, robert.jarzmik@free.fr Cc: Chao Xie Subject: [rtc-linux] [V2 PATCH 1/2] rtc: sa1100: move clock enable/disable to probe/remove Date: Wed, 5 Dec 2012 01:49:08 -0500 Message-Id: <1354690149-3043-1-git-send-email-chao.xie@marvell.com> X-Mailer: git-send-email 1.7.4.1 X-OriginalArrivalTime: 05 Dec 2012 06:49:12.0417 (UTC) FILETIME=[A2664510:01CDD2B4] X-Original-Sender: cxie4@marvell.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 74.125.149.141 is neither permitted nor denied by best guess record for domain of cxie4@marvell.com) smtp.mail=cxie4@marvell.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , 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 Acked-by: Haojian Zhuang --- 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);