Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / oprofile / oprofilefs.c
index b80990d..b62da9b 100644 (file)
@@ -21,7 +21,7 @@
 
 #define OPROFILEFS_MAGIC 0x6f70726f
 
-spinlock_t oprofilefs_lock = SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(oprofilefs_lock);
 
 static struct inode * oprofilefs_get_inode(struct super_block * sb, int mode)
 {
@@ -47,23 +47,7 @@ static struct super_operations s_ops = {
 
 ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count, loff_t * offset)
 {
-       size_t len = strlen(str);
-
-       if (!count)
-               return 0;
-
-       if (*offset > len)
-               return 0;
-
-       if (count > len - *offset)
-               count = len - *offset;
-
-       if (copy_to_user(buf, str + *offset, count))
-               return -EFAULT;
-
-       *offset += count;
-
-       return count;
+       return simple_read_from_buffer(buf, count, offset, str, strlen(str));
 }
 
 
@@ -72,29 +56,10 @@ ssize_t oprofilefs_str_to_user(char const * str, char __user * buf, size_t count
 ssize_t oprofilefs_ulong_to_user(unsigned long val, char __user * buf, size_t count, loff_t * offset)
 {
        char tmpbuf[TMPBUFSIZE];
-       size_t maxlen;
-
-       if (!count)
-               return 0;
-
-       spin_lock(&oprofilefs_lock);
-       maxlen = snprintf(tmpbuf, TMPBUFSIZE, "%lu\n", val);
-       spin_unlock(&oprofilefs_lock);
+       size_t maxlen = snprintf(tmpbuf, TMPBUFSIZE, "%lu\n", val);
        if (maxlen > TMPBUFSIZE)
                maxlen = TMPBUFSIZE;
-
-       if (*offset > maxlen)
-               return 0;
-
-       if (count > maxlen - *offset)
-               count = maxlen - *offset;
-
-       if (copy_to_user(buf, tmpbuf + *offset, count))
-               return -EFAULT;
-
-       *offset += count;
-
-       return count;
+       return simple_read_from_buffer(buf, count, offset, tmpbuf, maxlen);
 }
 
 
@@ -165,16 +130,13 @@ static struct file_operations ulong_ro_fops = {
 
 
 static struct dentry * __oprofilefs_create_file(struct super_block * sb,
-       struct dentry * root, char const * name, struct file_operations * fops,
+       struct dentry * root, char const * name, const struct file_operations * fops,
        int perm)
 {
        struct dentry * dentry;
        struct inode * inode;
-       struct qstr qname;
-       qname.name = name;
-       qname.len = strlen(name);
-       qname.hash = full_name_hash(qname.name, qname.len);
-       dentry = d_alloc(root, &qname);
+
+       dentry = d_alloc_name(root, name);
        if (!dentry)
                return NULL;
        inode = oprofilefs_get_inode(sb, S_IFREG | perm);
@@ -241,7 +203,7 @@ int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
 
  
 int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
-       char const * name, struct file_operations * fops)
+       char const * name, const struct file_operations * fops)
 {
        if (!__oprofilefs_create_file(sb, root, name, fops, 0644))
                return -EFAULT;
@@ -250,7 +212,7 @@ int oprofilefs_create_file(struct super_block * sb, struct dentry * root,
 
 
 int oprofilefs_create_file_perm(struct super_block * sb, struct dentry * root,
-       char const * name, struct file_operations * fops, int perm)
+       char const * name, const struct file_operations * fops, int perm)
 {
        if (!__oprofilefs_create_file(sb, root, name, fops, perm))
                return -EFAULT;
@@ -263,11 +225,8 @@ struct dentry * oprofilefs_mkdir(struct super_block * sb,
 {
        struct dentry * dentry;
        struct inode * inode;
-       struct qstr qname;
-       qname.name = name;
-       qname.len = strlen(name);
-       qname.hash = full_name_hash(qname.name, qname.len);
-       dentry = d_alloc(root, &qname);
+
+       dentry = d_alloc_name(root, name);
        if (!dentry)
                return NULL;
        inode = oprofilefs_get_inode(sb, S_IFDIR | 0755);
@@ -291,6 +250,7 @@ static int oprofilefs_fill_super(struct super_block * sb, void * data, int silen
        sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
        sb->s_magic = OPROFILEFS_MAGIC;
        sb->s_op = &s_ops;
+       sb->s_time_gran = 1;
 
        root_inode = oprofilefs_get_inode(sb, S_IFDIR | 0755);
        if (!root_inode)