From patchwork Tue Mar 8 13:06:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kalle.jokiniemi@nokia.com X-Patchwork-Id: 618231 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p28D8wdf023886 for ; Tue, 8 Mar 2011 13:08:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754837Ab1CHNI6 (ORCPT ); Tue, 8 Mar 2011 08:08:58 -0500 Received: from smtp.nokia.com ([147.243.128.26]:51317 "EHLO mgw-da02.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753099Ab1CHNI5 (ORCPT ); Tue, 8 Mar 2011 08:08:57 -0500 Received: from nokia.com (localhost [127.0.0.1]) by mgw-da02.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id p28D8tvm018483; Tue, 8 Mar 2011 15:08:55 +0200 Received: from kalle-t43.nmp.nokia.com ([trdhcp215135.nmp.nokia.com [172.22.215.135]]) by mgw-da02.nokia.com with RELAY id p28D84T7017870 ; Tue, 8 Mar 2011 15:08:25 +0200 From: Kalle Jokiniemi To: linux-omap@vger.kernel.org, khilman@ti.com, tony@atomide.com Cc: ilkka.koskinen@nokia.com, wim@iguana.be, Kalle Jokiniemi , Atal Shargorodsky Subject: [PATCH 2/2] Watchdog: omap_wdt: fix interface clock handling Date: Tue, 8 Mar 2011 15:06:23 +0200 Message-Id: <1299589583-22632-3-git-send-email-kalle.jokiniemi@nokia.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1299589583-22632-1-git-send-email-kalle.jokiniemi@nokia.com> References: <1299589583-22632-1-git-send-email-kalle.jokiniemi@nokia.com> X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 08 Mar 2011 13:08:59 +0000 (UTC) diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c index 81e3d61..f74eca2 100644 --- a/drivers/watchdog/omap_wdt.c +++ b/drivers/watchdog/omap_wdt.c @@ -126,6 +126,7 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev) u32 pre_margin = GET_WLDR_VAL(timer_margin); void __iomem *base = wdev->base; + clk_enable(wdev->ick); /* just count up at 32 KHz */ while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x04) cpu_relax(); @@ -133,6 +134,7 @@ static void omap_wdt_set_timeout(struct omap_wdt_dev *wdev) __raw_writel(pre_margin, base + OMAP_WATCHDOG_LDR); while (__raw_readl(base + OMAP_WATCHDOG_WPS) & 0x04) cpu_relax(); + clk_disable(wdev->ick); } /* @@ -162,6 +164,7 @@ static int omap_wdt_open(struct inode *inode, struct file *file) omap_wdt_set_timeout(wdev); omap_wdt_ping(wdev); /* trigger loading of new timeout value */ omap_wdt_enable(wdev); + clk_disable(wdev->ick); return nonseekable_open(inode, file); } @@ -175,6 +178,7 @@ static int omap_wdt_release(struct inode *inode, struct file *file) */ #ifndef CONFIG_WATCHDOG_NOWAYOUT + clk_enable(wdev->ick); omap_wdt_disable(wdev); clk_disable(wdev->ick); @@ -194,9 +198,11 @@ static ssize_t omap_wdt_write(struct file *file, const char __user *data, /* Refresh LOAD_TIME. */ if (len) { + clk_enable(wdev->ick); spin_lock(&wdt_lock); omap_wdt_ping(wdev); spin_unlock(&wdt_lock); + clk_disable(wdev->ick); } return len; } @@ -228,15 +234,18 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, return put_user(omap_prcm_get_reset_sources(), (int __user *)arg); case WDIOC_KEEPALIVE: + clk_enable(wdev->ick); spin_lock(&wdt_lock); omap_wdt_ping(wdev); spin_unlock(&wdt_lock); + clk_disable(wdev->ick); return 0; case WDIOC_SETTIMEOUT: if (get_user(new_margin, (int __user *)arg)) return -EFAULT; omap_wdt_adjust_timeout(new_margin); + clk_enable(wdev->ick); spin_lock(&wdt_lock); omap_wdt_disable(wdev); omap_wdt_set_timeout(wdev); @@ -244,6 +253,7 @@ static long omap_wdt_ioctl(struct file *file, unsigned int cmd, omap_wdt_ping(wdev); spin_unlock(&wdt_lock); + clk_disable(wdev->ick); /* Fall */ case WDIOC_GETTIMEOUT: return put_user(timer_margin, (int __user *)arg); @@ -371,8 +381,11 @@ static void omap_wdt_shutdown(struct platform_device *pdev) { struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); - if (wdev->omap_wdt_users) + if (wdev->omap_wdt_users) { + clk_enable(wdev->ick); omap_wdt_disable(wdev); + clk_disable(wdev->ick); + } } static int __devexit omap_wdt_remove(struct platform_device *pdev) @@ -409,8 +422,11 @@ static int omap_wdt_suspend(struct platform_device *pdev, pm_message_t state) { struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); - if (wdev->omap_wdt_users) + if (wdev->omap_wdt_users) { + clk_enable(wdev->ick); omap_wdt_disable(wdev); + clk_disable(wdev->ick); + } return 0; } @@ -420,8 +436,10 @@ static int omap_wdt_resume(struct platform_device *pdev) struct omap_wdt_dev *wdev = platform_get_drvdata(pdev); if (wdev->omap_wdt_users) { + clk_enable(wdev->ick); omap_wdt_enable(wdev); omap_wdt_ping(wdev); + clk_disable(wdev->ick); } return 0;