sh: cdev lock_kernel() pushdown
authorJonathan Corbet <corbet@lwn.net>
Thu, 15 May 2008 15:11:26 +0000 (09:11 -0600)
committerJonathan Corbet <corbet@lwn.net>
Sun, 18 May 2008 21:43:40 +0000 (15:43 -0600)
Push the cdev lock_kernel() call down into the sh gio driver.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
arch/sh/boards/landisk/gio.c

index 17025080db35ea279903e36910294ceb6b48767b..0c15b0a50b99a2460011801fa37411acd5e217e7 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/smp_lock.h>
 #include <linux/kdev_t.h>
 #include <linux/cdev.h>
 #include <linux/fs.h>
@@ -32,17 +33,20 @@ static int openCnt;
 static int gio_open(struct inode *inode, struct file *filp)
 {
        int minor;
+       int ret = -ENOENT;
 
+       lock_kernel();
        minor = MINOR(inode->i_rdev);
        if (minor < DEVCOUNT) {
                if (openCnt > 0) {
-                       return -EALREADY;
+                       ret = -EALREADY;
                } else {
                        openCnt++;
-                       return 0;
+                       ret = 0;
                }
        }
-       return -ENOENT;
+       unlock_kernel();
+       return ret;
 }
 
 static int gio_close(struct inode *inode, struct file *filp)