acpi-wmi: Unmark as 'experimental'
[safe/jmp/linux-2.6] / drivers / char / vc_screen.c
index 45e9bd8..4f3b3f9 100644 (file)
 #include <linux/major.h>
 #include <linux/errno.h>
 #include <linux/tty.h>
-#include <linux/sched.h>
 #include <linux/interrupt.h>
 #include <linux/mm.h>
 #include <linux/init.h>
+#include <linux/mutex.h>
 #include <linux/vt_kern.h>
 #include <linux/selection.h>
 #include <linux/kbd_kern.h>
 #include <linux/console.h>
-#include <linux/smp_lock.h>
 #include <linux/device.h>
+#include <linux/smp_lock.h>
+
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -71,11 +72,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
 {
        int size;
 
-       down(&con_buf_sem);
-       size = vcs_size(file->f_dentry->d_inode);
+       mutex_lock(&con_buf_mtx);
+       size = vcs_size(file->f_path.dentry->d_inode);
        switch (orig) {
                default:
-                       up(&con_buf_sem);
+                       mutex_unlock(&con_buf_mtx);
                        return -EINVAL;
                case 2:
                        offset += size;
@@ -86,11 +87,11 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
                        break;
        }
        if (offset < 0 || offset > size) {
-               up(&con_buf_sem);
+               mutex_unlock(&con_buf_mtx);
                return -EINVAL;
        }
        file->f_pos = offset;
-       up(&con_buf_sem);
+       mutex_unlock(&con_buf_mtx);
        return file->f_pos;
 }
 
@@ -98,7 +99,7 @@ static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
 static ssize_t
 vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        unsigned int currcons = iminor(inode);
        struct vc_data *vc;
        long pos;
@@ -107,7 +108,7 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
        unsigned short *org = NULL;
        ssize_t ret;
 
-       down(&con_buf_sem);
+       mutex_lock(&con_buf_mtx);
 
        pos = *ppos;
 
@@ -264,14 +265,14 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
                ret = read;
 unlock_out:
        release_console_sem();
-       up(&con_buf_sem);
+       mutex_unlock(&con_buf_mtx);
        return ret;
 }
 
 static ssize_t
 vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 {
-       struct inode *inode = file->f_dentry->d_inode;
+       struct inode *inode = file->f_path.dentry->d_inode;
        unsigned int currcons = iminor(inode);
        struct vc_data *vc;
        long pos;
@@ -281,7 +282,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
        u16 *org0 = NULL, *org = NULL;
        size_t ret;
 
-       down(&con_buf_sem);
+       mutex_lock(&con_buf_mtx);
 
        pos = *ppos;
 
@@ -451,7 +452,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
 unlock_out:
        release_console_sem();
 
-       up(&con_buf_sem);
+       mutex_unlock(&con_buf_mtx);
 
        return ret;
 }
@@ -460,12 +461,16 @@ static int
 vcs_open(struct inode *inode, struct file *filp)
 {
        unsigned int currcons = iminor(inode) & 127;
+       int ret = 0;
+       
+       lock_kernel();
        if(currcons && !vc_cons_allocated(currcons-1))
-               return -ENXIO;
-       return 0;
+               ret = -ENXIO;
+       unlock_kernel();
+       return ret;
 }
 
-static struct file_operations vcs_fops = {
+static const struct file_operations vcs_fops = {
        .llseek         = vcs_lseek,
        .read           = vcs_read,
        .write          = vcs_write,
@@ -474,17 +479,18 @@ static struct file_operations vcs_fops = {
 
 static struct class *vc_class;
 
-void vcs_make_devfs(struct tty_struct *tty)
+void vcs_make_sysfs(struct tty_struct *tty)
 {
-       class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
-                       NULL, "vcs%u", tty->index + 1);
-       class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
-                       NULL, "vcsa%u", tty->index + 1);
+       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL,
+                     "vcs%u", tty->index + 1);
+       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL,
+                     "vcsa%u", tty->index + 1);
 }
-void vcs_remove_devfs(struct tty_struct *tty)
+
+void vcs_remove_sysfs(struct tty_struct *tty)
 {
-       class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
-       class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
+       device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
+       device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
 }
 
 int __init vcs_init(void)
@@ -493,7 +499,7 @@ int __init vcs_init(void)
                panic("unable to get major %d for vcs device", VCS_MAJOR);
        vc_class = class_create(THIS_MODULE, "vc");
 
-       class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
-       class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
+       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
        return 0;
 }