[MTD] mtdoops: fix a bit of spin lock usage

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Mar 20 14:59:58 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=48ec00ac895074f8a47bda8f3925ccaa46abb7a8
Commit:     48ec00ac895074f8a47bda8f3925ccaa46abb7a8
Parent:     e2a0f25b4f520adbd82c0caafcde0470ed11053d
Author:     Adrian Hunter <adrian.hunter at nokia.com>
AuthorDate: Wed Mar 4 09:53:40 2009 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Mar 20 18:39:25 2009 +0000

    [MTD] mtdoops: fix a bit of spin lock usage
    
    - do not leave spin lock locked
    - initialise spin lock
    
    Signed-off-by: Adrian Hunter <adrian.hunter at nokia.com>
    Acked-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdoops.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index fdf504f..1060337 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -361,8 +361,10 @@ mtdoops_console_write(struct console *co, const char *s, unsigned int count)
 	spin_lock_irqsave(&cxt->writecount_lock, flags);
 
 	/* Check ready status didn't change whilst waiting for the lock */
-	if (!cxt->ready)
+	if (!cxt->ready) {
+		spin_unlock_irqrestore(&cxt->writecount_lock, flags);
 		return;
+	}
 
 	if (cxt->writecount == 0) {
 		u32 *stamp = cxt->oops_buf;
@@ -420,6 +422,7 @@ static int __init mtdoops_console_init(void)
 
 	cxt->mtd_index = -1;
 	cxt->oops_buf = vmalloc(OOPS_PAGE_SIZE);
+	spin_lock_init(&cxt->writecount_lock);
 
 	if (!cxt->oops_buf) {
 		printk(KERN_ERR "Failed to allocate mtdoops buffer workspace\n");



More information about the linux-mtd-cvs mailing list