linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jbe@pengutronix.de (Juergen Beisert)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance (2nd try)
Date: Tue, 8 Dec 2009 13:01:25 +0100	[thread overview]
Message-ID: <200912081301.25597.jbe@pengutronix.de> (raw)
In-Reply-To: <200912081123.06630.jbe@pengutronix.de>

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 <jbe@pengutronix.de>
Acked-by: Wolfram Sang <wsa@pengutronix.de>

---
 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

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

  reply	other threads:[~2009-12-08 12:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08  9:56 [PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance Juergen Beisert
2009-12-08 10:23 ` Juergen Beisert
2009-12-08 12:01   ` Juergen Beisert [this message]
2009-12-08 13:17     ` [PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance (2nd try) Ladislav Michl
     [not found] ` <4B1E3815.9020901@ru.mvista.com>
2009-12-08 12:07   ` [PATCH] [NAND] S3C2410: Fix NFC clock enable/disable imbalance Juergen Beisert
2009-12-08 12:16     ` Ben Dooks

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=200912081301.25597.jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --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).