musb: reenable high-speed for hostmode
[h-e-n] / fs / read_write.c
index c4d3d17..969a6d9 100644 (file)
@@ -31,57 +31,63 @@ const struct file_operations generic_ro_fops = {
 
 EXPORT_SYMBOL(generic_ro_fops);
 
-loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
+/**
+ * generic_file_llseek_unlocked - lockless generic llseek implementation
+ * @file:      file structure to seek on
+ * @offset:    file offset to seek to
+ * @origin:    type of seek
+ *
+ * Updates the file offset to the value specified by @offset and @origin.
+ * Locking must be provided by the caller.
+ */
+loff_t
+generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin)
 {
-       long long retval;
        struct inode *inode = file->f_mapping->host;
 
-       mutex_lock(&inode->i_mutex);
        switch (origin) {
-               case SEEK_END:
-                       offset += inode->i_size;
-                       break;
-               case SEEK_CUR:
-                       offset += file->f_pos;
+       case SEEK_END:
+               offset += inode->i_size;
+               break;
+       case SEEK_CUR:
+               offset += file->f_pos;
+               break;
        }
-       retval = -EINVAL;
-       if (offset>=0 && offset<=inode->i_sb->s_maxbytes) {
-               if (offset != file->f_pos) {
-                       file->f_pos = offset;
-                       file->f_version = 0;
-               }
-               retval = offset;
+
+       if (offset < 0 || offset > inode->i_sb->s_maxbytes)
+               return -EINVAL;
+
+       /* Special lock needed here? */
+       if (offset != file->f_pos) {
+               file->f_pos = offset;
+               file->f_version = 0;
        }
-       mutex_unlock(&inode->i_mutex);
-       return retval;
-}
 
-EXPORT_SYMBOL(generic_file_llseek);
+       return offset;
+}
+EXPORT_SYMBOL(generic_file_llseek_unlocked);
 
-loff_t remote_llseek(struct file *file, loff_t offset, int origin)
+/**
+ * generic_file_llseek - generic llseek implementation for regular files
+ * @file:      file structure to seek on
+ * @offset:    file offset to seek to
+ * @origin:    type of seek
+ *
+ * This is a generic implemenation of ->llseek useable for all normal local
+ * filesystems.  It just updates the file offset to the value specified by
+ * @offset and @origin under i_mutex.
+ */
+loff_t generic_file_llseek(struct file *file, loff_t offset, int origin)
 {
-       long long retval;
+       loff_t rval;
 
-       lock_kernel();
-       switch (origin) {
-               case SEEK_END:
-                       offset += i_size_read(file->f_path.dentry->d_inode);
-                       break;
-               case SEEK_CUR:
-                       offset += file->f_pos;
-       }
-       retval = -EINVAL;
-       if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) {
-               if (offset != file->f_pos) {
-                       file->f_pos = offset;
-                       file->f_version = 0;
-               }
-               retval = offset;
-       }
-       unlock_kernel();
-       return retval;
+       mutex_lock(&file->f_dentry->d_inode->i_mutex);
+       rval = generic_file_llseek_unlocked(file, offset, origin);
+       mutex_unlock(&file->f_dentry->d_inode->i_mutex);
+
+       return rval;
 }
-EXPORT_SYMBOL(remote_llseek);
+EXPORT_SYMBOL(generic_file_llseek);
 
 loff_t no_llseek(struct file *file, loff_t offset, int origin)
 {
@@ -91,7 +97,7 @@ EXPORT_SYMBOL(no_llseek);
 
 loff_t default_llseek(struct file *file, loff_t offset, int origin)
 {
-       long long retval;
+       loff_t retval;
 
        lock_kernel();
        switch (origin) {
@@ -366,7 +372,6 @@ asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
 
        return ret;
 }
-EXPORT_UNUSED_SYMBOL_GPL(sys_read); /* to be deleted for 2.6.25 */
 
 asmlinkage ssize_t sys_write(unsigned int fd, const char __user * buf, size_t count)
 {
@@ -446,6 +451,7 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to)
        }
        return seg;
 }
+EXPORT_SYMBOL(iov_shorten);
 
 ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
                unsigned long nr_segs, size_t len, loff_t *ppos, iov_fn_t fn)