Revert "input: touch: raydium: V61.7 code drop"
[linux-3.10.git] / fs / pipe.c
index 39bdec0..0e0752e 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -21,6 +21,7 @@
 #include <linux/audit.h>
 #include <linux/syscalls.h>
 #include <linux/fcntl.h>
+#include <linux/aio.h>
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
@@ -725,11 +726,25 @@ pipe_poll(struct file *filp, poll_table *wait)
        return mask;
 }
 
+static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
+{
+       int kill = 0;
+
+       spin_lock(&inode->i_lock);
+       if (!--pipe->files) {
+               inode->i_pipe = NULL;
+               kill = 1;
+       }
+       spin_unlock(&inode->i_lock);
+
+       if (kill)
+               free_pipe_info(pipe);
+}
+
 static int
 pipe_release(struct inode *inode, struct file *file)
 {
-       struct pipe_inode_info *pipe = inode->i_pipe;
-       int kill = 0;
+       struct pipe_inode_info *pipe = file->private_data;
 
        __pipe_lock(pipe);
        if (file->f_mode & FMODE_READ)
@@ -742,17 +757,9 @@ pipe_release(struct inode *inode, struct file *file)
                kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
                kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
        }
-       spin_lock(&inode->i_lock);
-       if (!--pipe->files) {
-               inode->i_pipe = NULL;
-               kill = 1;
-       }
-       spin_unlock(&inode->i_lock);
        __pipe_unlock(pipe);
 
-       if (kill)
-               __free_pipe_info(pipe);
-
+       put_pipe_info(inode, pipe);
        return 0;
 }
 
@@ -775,7 +782,7 @@ pipe_fasync(int fd, struct file *filp, int on)
        return retval;
 }
 
-struct pipe_inode_info * alloc_pipe_info(struct inode *inode)
+struct pipe_inode_info *alloc_pipe_info(void)
 {
        struct pipe_inode_info *pipe;
 
@@ -795,7 +802,7 @@ struct pipe_inode_info * alloc_pipe_info(struct inode *inode)
        return NULL;
 }
 
-void __free_pipe_info(struct pipe_inode_info *pipe)
+void free_pipe_info(struct pipe_inode_info *pipe)
 {
        int i;
 
@@ -810,12 +817,6 @@ void __free_pipe_info(struct pipe_inode_info *pipe)
        kfree(pipe);
 }
 
-void free_pipe_info(struct inode *inode)
-{
-       __free_pipe_info(inode->i_pipe);
-       inode->i_pipe = NULL;
-}
-
 static struct vfsmount *pipe_mnt __read_mostly;
 
 /*
@@ -841,7 +842,7 @@ static struct inode * get_pipe_inode(void)
 
        inode->i_ino = get_next_ino();
 
-       pipe = alloc_pipe_info(inode);
+       pipe = alloc_pipe_info();
        if (!pipe)
                goto fail_iput;
 
@@ -911,12 +912,12 @@ int create_pipe_files(struct file **res, int flags)
 err_file:
        put_filp(f);
 err_dentry:
-       free_pipe_info(inode);
+       free_pipe_info(inode->i_pipe);
        path_put(&path);
        return err;
 
 err_inode:
-       free_pipe_info(inode);
+       free_pipe_info(inode->i_pipe);
        iput(inode);
        return err;
 }
@@ -1019,7 +1020,6 @@ static int fifo_open(struct inode *inode, struct file *filp)
 {
        struct pipe_inode_info *pipe;
        bool is_pipe = inode->i_sb->s_magic == PIPEFS_MAGIC;
-       int kill = 0;
        int ret;
 
        filp->f_version = 0;
@@ -1031,7 +1031,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
                spin_unlock(&inode->i_lock);
        } else {
                spin_unlock(&inode->i_lock);
-               pipe = alloc_pipe_info(inode);
+               pipe = alloc_pipe_info();
                if (!pipe)
                        return -ENOMEM;
                pipe->files = 1;
@@ -1039,7 +1039,7 @@ static int fifo_open(struct inode *inode, struct file *filp)
                if (unlikely(inode->i_pipe)) {
                        inode->i_pipe->files++;
                        spin_unlock(&inode->i_lock);
-                       __free_pipe_info(pipe);
+                       free_pipe_info(pipe);
                        pipe = inode->i_pipe;
                } else {
                        inode->i_pipe = pipe;
@@ -1135,15 +1135,9 @@ err_wr:
        goto err;
 
 err:
-       spin_lock(&inode->i_lock);
-       if (!--pipe->files) {
-               inode->i_pipe = NULL;
-               kill = 1;
-       }
-       spin_unlock(&inode->i_lock);
        __pipe_unlock(pipe);
-       if (kill)
-               __free_pipe_info(pipe);
+
+       put_pipe_info(inode, pipe);
        return ret;
 }