From patchwork Tue Dec 8 12:01:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Borleis X-Patchwork-Id: 40608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CB13FB7BBC for ; Tue, 8 Dec 2009 23:04:07 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NHylw-0002dQ-Nq; Tue, 08 Dec 2009 12:02:28 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1NHyl4-0002P0-50 for linux-mtd@lists.infradead.org; Tue, 08 Dec 2009 12:01:38 +0000 Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=jupiter.intranet.kreuzholzen.de) by metis.ext.pengutronix.de with esmtp (Exim 4.69) (envelope-from ) id 1NHykx-0004eY-FO; Tue, 08 Dec 2009 13:01:28 +0100 From: Juergen Beisert Organization: Pengutronix - Linux Solutions for Science and Industry To: linux-mtd@lists.infradead.org Date: Tue, 8 Dec 2009 13:01:25 +0100 User-Agent: KMail/1.9.9 References: <200912081056.40210.jbe@pengutronix.de> <200912081123.06630.jbe@pengutronix.de> In-Reply-To: <200912081123.06630.jbe@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200912081301.25597.jbe@pengutronix.de> X-SA-Exim-Connect-IP: 92.198.50.58 X-SA-Exim-Mail-From: jbe@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on metis.extern.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-14.6 required=4.5 tests=AWL, BAYES_00 shortcircuit=no autolearn=ham version=3.2.5 Subject: Re: [PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance (2nd try) X-SA-Exim-Version: 4.2.1 (built Wed, 25 Jun 2008 17:14:11 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091208_070134_586229_F0C554C0 X-CRM114-Status: GOOD ( 19.76 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When unmounting an mtd filesystem the s3c2410_nand_select_chip() function gets called again with "chip == -1". In this case the current code disables the NFC clock at least a second time, so it does not work anymore. Clock disabling should only happen if it was really enabled. Due to a lack of a query function if a clock is already enabled (and how often), we must count enable/disable calls by our own here. Note: Other enable/disable sequences can be found in the power management functions. I'm not sure if they interfere with this local enable/disable count. Signed-off-by: Juergen Beisert Acked-by: Wolfram Sang --- drivers/mtd/nand/s3c2410.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Index: linux-2.6.32/drivers/mtd/nand/s3c2410.c =================================================================== --- linux-2.6.32.orig/drivers/mtd/nand/s3c2410.c +++ linux-2.6.32/drivers/mtd/nand/s3c2410.c @@ -329,12 +329,15 @@ static void s3c2410_nand_select_chip(str struct s3c2410_nand_mtd *nmtd; struct nand_chip *this = mtd->priv; unsigned long cur; + static int clock_enable_cnt = 0; nmtd = this->priv; info = nmtd->info; - if (chip != -1 && allow_clk_stop(info)) + if (chip != -1 && allow_clk_stop(info)) { clk_enable(info->clk); + clock_enable_cnt++; + } cur = readl(info->sel_reg); @@ -356,8 +359,10 @@ static void s3c2410_nand_select_chip(str writel(cur, info->sel_reg); - if (chip == -1 && allow_clk_stop(info)) + if (chip == -1 && allow_clk_stop(info) && clock_enable_cnt > 0) { clk_disable(info->clk); + clock_enable_cnt--; + } } /* s3c2410_nand_hwcontrol